I ran the trigonometric test suite alluded to at
http://groups.google.com/group/comp.lang.scheme/msg/3c7c4db3800e3c6f
and found a problem with complex acos; the following "fixes" it. Gambit now "fails" 4 tests (2 for acos, 2 for asin) due to "catastrophic cancellation" for very large arguments. I don't know how to fix them at the moment, or, indeed, whether they're worth fixing:
frying-pan:~/programs/gambc-v4_2_3/snd-9/tools> ../../gsi/gsi test.scm ;(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 ;all done!
Brad
hg diff lib/_num.scm diff -r 0e938061d9b6 lib/_num.scm --- a/lib/_num.scm Tue Jun 03 01:22:39 2008 -0400 +++ b/lib/_num.scm Mon Aug 11 01:04:40 2008 -0400 @@ -2160,9 +2160,7 @@ (##fail-check-number 1 acos x))
(define (complex-case x) - (##* (macro-cpxnum--i) - (##log (##+ x - (##* (macro-cpxnum-+i) (##sqrt (##- 1 (##* x x)))))))) + (##- (macro-inexact-+pi/2) (##asin x)))
(define (real-case x) (if (or (##< x -1) (##< 1 x))
Afficher les réponses par date
On Aug 11, 2008, at 1:14 AM, Bradley Lucier wrote:
Gambit now "fails" 4 tests (2 for acos, 2 for asin) due to "catastrophic cancellation" for very large arguments. I don't know how to fix them at the moment, or, indeed, whether they're worth fixing:
frying-pan:~/programs/gambc-v4_2_3/snd-9/tools> ../../gsi/gsi test.scm ;(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 ;all done!
The test suite is generated by a C program; the test generator calculates the expected results using the C math library on whatever machine it's run on.
When run on my PowerPC MacOS X 10.4.11 box, the above tests are generated; gambit with my suggested change to ##acos fails them on both my x86-64 linux box and on my PPC Mac.
When run on my x86-64 linux box, different tests are generated; gambit with my suggested change passes them on both my x86-64 linux box and on my PPC Mac.
There is still a problem (gambit's results shown above are not correct), but I'm not sure it's worth fixing.
Brad