Complex arg-trig functions
Stephen Montgomery-Smith
stephen at missouri.edu
Tue Aug 14 18:40:33 UTC 2012
I was thinking more about the formulas of the type
casinhl(z) = clogl(z+csqrtl(z^2+1)).
It seems to be far more inaccurate than I originally thought. mpc uses
this method, and it tries to adjust the number of bits it uses until it
get the right answer. If you give it something like z = 1L +
1e-3000L*I, mpc takes an extraordinarily large amount of time to do the
calculation (it is worse for acos than for asin).
I added some printf statements to the code for mpc. To calculate to 100
bits, mpc is sometimes using a precision of 7000 bits for its internal
calculations.
Also, for its acos and atan functions, it tries it with a certain number
of bits, then adds a small number to the precision, and tries again.
With asin, it at least multiples the precision by 1.5 with each retry.
I adjusted the code so that acos and atan do the same as asin, and now
it goes very much faster.
But they would still be better off using the Hull, Fairgrieve and Tang
algorithm, which seems to be very superior. And in their case they
wouldn't have to worry about underflow and overflow.
I also looked at Mathematica. It doesn't seem to use the above formula.
But whatever it does use, it is only marginally better.
More information about the freebsd-numerics
mailing list