From: Albert G. <Dr....@t-...> - 2008-08-23 13:25:51
|
Albert Graef wrote: > John Cowan wrote: >> Here is the Common Lisp discussion of where the branch cuts of the >> transcendental functions are: http://tinyurl.com/5rbsng . > > Thanks a bunch for that link, that should help me to revise the complex > stuff in math.pure. Ok, I did some minor cosmetic surgery to the complex trigs and hyps, actually most of my definitions (originally pilfered from Bronstein) seemed to be pretty much in line with that document already. I also fixed up my completely nonsensical complex sqrt definition, wonder how that slipped in. ;-) What still remains to be done is to add some type guards on the mixed real/complex rules, so that we can later (when Eddie's GSL module materializes) overload the common operators for scalar+vector/matrix kind of stuff. One thing that keeps me wondering is Kahan's suggestion for the acosh: acosh z@(x+:y) | acosh z@(r<:t) = 2*ln (sqrt ((z+1)/2)+sqrt ((z-1)/2)); This is the definition I currently use (from Mathworld): acosh z@(x+:y) | acosh z@(r<:t) = ln (z+sqrt (z-1)*sqrt (z+1)); This has the same branch cut (-inf,1), and seems to yield the same results AFAICT (up to rounding of course). Kahan's definition looks more complicated and requires more operations, but given that Kahan wrote it, I guess that there must be some reason he wrote it that way. ;-) So can anyone think of a reason why one might prefer Kahan's definition? Numerical stability maybe? Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |