Change tanh
to produce inexact values when approximating near 0.
Since the approximation is that (tanh x) = x for small x, previously (tanh 1/10000000000000000000) produced an `exact?` answer, even though this is an approximation. Found by Typed Racket random testing: http://drdr.racket-lang.org/54493/racket/share/pkgs/typed-racket-test/tr-random-testing.rkt
This commit is contained in:
parent
8859d6596a
commit
e8202b7fa3
|
@ -329,6 +329,7 @@
|
||||||
(test 0 tanh 0)
|
(test 0 tanh 0)
|
||||||
(test #t double=? tanh+1 (tanh 1))
|
(test #t double=? tanh+1 (tanh 1))
|
||||||
(test 1.0 tanh 20)
|
(test 1.0 tanh 20)
|
||||||
|
(test #t flonum? (tanh (inexact->exact 1/100000000000)))
|
||||||
|
|
||||||
#reader "maybe-single.rkt"
|
#reader "maybe-single.rkt"
|
||||||
(begin
|
(begin
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
[(real? z)
|
[(real? z)
|
||||||
(let loop ([z z])
|
(let loop ([z z])
|
||||||
(cond [(z . < . 0) (- (loop (- z)))]
|
(cond [(z . < . 0) (- (loop (- z)))]
|
||||||
[(z . < . 1.29047841397589243466D-08) z]
|
[(z . < . 1.29047841397589243466D-08) (exact->inexact z)]
|
||||||
[(z . < . 0.54930614433405484570D+00)
|
[(z . < . 0.54930614433405484570D+00)
|
||||||
(define p0 -0.16134119023996228053D+04)
|
(define p0 -0.16134119023996228053D+04)
|
||||||
(define p1 -0.99225929672236083313D+02)
|
(define p1 -0.99225929672236083313D+02)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user