From: Taylor R Campbell Date: Sun, 18 Nov 2018 23:06:46 +0000 (+0000) Subject: Avoid overflow in sqrt(1 - z^2) with sqrt(1 - z)*sqrt(1 + z) in asin. X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~18 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=210f3c37d3af418bd9fddf6f2d85335a6ceaa9b8;p=mit-scheme.git Avoid overflow in sqrt(1 - z^2) with sqrt(1 - z)*sqrt(1 + z) in asin. Strike off a couple xfails. Others remain because the branch cuts are busted. --- diff --git a/src/runtime/arith.scm b/src/runtime/arith.scm index 4c143134c..54b2322f1 100644 --- a/src/runtime/arith.scm +++ b/src/runtime/arith.scm @@ -1796,7 +1796,9 @@ USA. (complex:-i* (complex:log (complex:+ (complex:+i* z) - (complex:sqrt (complex:- 1 (complex:* z z))))))))) + (complex:* + (complex:sqrt (complex:+ 1 z)) + (complex:sqrt (complex:- 1 z))))))))) (let ((unsafe-case (lambda (z) (complex:negate (safe-case (complex:negate z)))))) diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index 966d67236..391726d76 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -513,9 +513,9 @@ USA. (vector -1e150-0.i -1.5707963267948966-346.0809111296668i 'xfail) (vector 1e300 1.5707963267948966+691.4686750787736i 'xfail) (vector 1e300+0.i 1.5707963267948966+691.4686750787736i 'xfail) - (vector 1e300-0.i 1.5707963267948966-691.4686750787736i 'xfail) - (vector -1e300 -1.5707963267948966+691.4686750787736i 'xfail) - (vector -1e300+0.i -1.5707963267948966+691.4686750787736i 'xfail) + (vector 1e300-0.i 1.5707963267948966-691.4686750787736i) + (vector -1e300 -1.5707963267948966+691.4686750787736i) + (vector -1e300+0.i -1.5707963267948966+691.4686750787736i) (vector -1e300-0.i -1.5707963267948966-691.4686750787736i 'xfail)) (lambda (v) (let ((x (vector-ref v 0))