Re: [pure-lang-users] math.pure
Status: Beta
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-08-25 01:06:38
|
Eddie Rucker wrote: > I pilfered that definition from a paper I found on Internet. Ah yes, I remember that now. But that definition just didn't work, I noticed that when testing some of the complex trig functions. > However, why didn't you use Kahan's suggestion for sqrt? > sqrt z = exp (0.5 * ln z); In fact, if you look at the formulas, that's just what my definition does in the rectangular case, although it uses the real sqrt instead of exp(0.5*ln _) to compute the square root of abs z, which saves one expensive operation. In the polar case, it's of course much faster to just halve arg z and take the real sqrt of abs z which are both readily available. That appears to have the branch cut in the right place, too. > Well, the Mathworld definition for actanh z didn't even give correct results comapred to the Common Lisp version. The Mathworld definition of atanh *is* the one suggested by Kahan, which is also the one I use, and I can assure you that it works very well. :) I tested all of these functions quite extensively against my HP 50G, which supposedly still runs the numeric algorithms orginally designed by Kahan for HP. Maybe you accidentally tried the first, bogus formula for atanh given in the CL document? 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 |