[gambit-list] Which function in libm are portable enough to assume that they will be on all platforms?

Bradley Lucier lucier at math.purdue.edu
Wed Oct 30 23:30:47 EDT 2013


On Oct 30, 2013, at 5:32 PM, Marc Feeley wrote:

> 
> It is pretty easy to add flsinh, etc to Gambit and I can do that if needed.  Do you think the quality of the C sinh is higher than the alternative (i.e. using the existing transcendental functions to do the same computation)?  Can you show a few examples where using sinh is a win?

Our code fails some fairly simple tests:

;(asin 1234000000.+0.i) got 0.+inf.0i, but expected 1.5707963267949+21.62667394298955i
;(asin -1234000000.-0.i) got -0.-inf.0i, but expected -1.5707963267949+21.62667394298955i
;(acos 1234000000.+0.i) got 1.5707963267948966-inf.0i, but expected 0.-21.62667394298955i
;(acos -1234000000.-0.i) got 1.5707963267948966+inf.0i, but expected 3.14159265358979-21.62667394298955i

This is from a modified R6RS test file on Clinger's web site.  Looking at the complex asin and acos code shows that it is naive, does not try to avoid spurious underflows, etc.

Kahan in his paper "Much ado about the sign of nothing" gives algorithms for accurate and stable computations of complex functions (this was the basis for the routines in sbcl) but they use functions listed in math.h but not in standard scheme.

So my question is---is it reasonable to import these floating-point functions into Gambit to make better versions of the standard functions?

Brad


More information about the Gambit-list mailing list