On Oct 30, 2013, at 11:30 PM, Bradley Lucier lucier@math.purdue.edu wrote:
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
If you define
(define (flsinh x) (fl* 0.5 (fl- (flexp x) (flexp (fl- x)))))
(define (flcosh x) (fl* 0.5 (fl+ (flexp x) (flexp (fl- x)))))
(define (fltanh x) (let ((a (flexp (fl* 2.0 x)))) (fl/ (fl- a 1.0) (fl+ a 1.0))))
can you use those functions to improve the precision of complex asin and acos? Can these Scheme definitions be improved? And how good is the precision when compared to the C sinh and cosh?
Marc