Use of C99 extra long double math functions after r236148

Stephen Montgomery-Smith stephen at missouri.edu
Mon Aug 13 00:32:26 UTC 2012


On 07/27/2012 12:20 AM, Diane Bruce wrote:

> I was very curious about that. Any chance of running that test harness
> against the NetBSD routines? At least if we are very late we are very
> much better. ;-)

I just looked at the code used in NetBSD.  The code is rather simple, 
and no effort is made to avoid large numerical errors, nor to manage the 
edge cases:

https://www-asim.lip6.fr/trac/netbsdtsar/browser/vendor/netbsd/5/src/lib/libm/complex/cacosh.c?rev=2
https://www-asim.lip6.fr/trac/netbsdtsar/browser/vendor/netbsd/5/src/lib/libm/complex/cacos.c?rev=2
https://www-asim.lip6.fr/trac/netbsdtsar/browser/vendor/netbsd/5/src/lib/libm/complex/casin.c?rev=2

casin is like my proposed pseudo-code, which I realize is numerically 
unstable if |Re(z)| <= 1 and Im(z) is close to zero.

cacos(z) = Pi/2 - casin(z), which is subtracting two nearly equal 
quantities if z is close to 1.

cacosh computes the wrong branch: it should be sign(Im(z))*I*cacos(z).

clog is essentially log(cabs(z)) + I*arg(z), which can have a relative 
error close to infinity if |z|=1.

So I think we can do better.


More information about the freebsd-numerics mailing list