>>>>> "Peter" == Peter Van Eynde <pvaneynd@...> writes:
Peter> On Tue, Jul 09, 2002 at 09:38:28AM -0400, Raymond Toy wrote:
Peter> These are part of the less useful history of ansi-test. It came from an
Peter> implementation that seems to have had its share of numeric bugs. So
Peter> there are a lot of simple tests like this. Of course they fall on their
Peter> face the moment you change fp format...
>> What do you propose? Leave them? Remove them? Change them to be be
>> an approximately equal type of test instead of equality?
Peter> Replace them with a better test would be nice. As most of them are fp
Peter> problems we should (IMHO) replace them with "zero knowledge" tests or
Peter> remove them.
Hmm, I seem not to have sent my proposals to this list. Here they
;; sin(8*pi/2) = sin(4*pi) = 0. Assume that our pi is a bit off. Say
;; pi*(1+eps). Then sin(8*pi*(1+eps)/2) = sin(4*pi + 4*pi*eps) =
;; sin(4*pi*eps) ~= 4*pi*eps. Test for this, but allow a fudge factor
;; of 2.
(let ((y (sin (* 8 (/ pi 2))))
(< (abs y) (* fudge (* 4 pi long-float-epsilon))))
;; As in 1045, cos(pi*(1+eps)/2) = cos(pi/2+pi*eps/2) = -sin(pi*eps/2)
;; ~= -pi*eps/2. Check that we are close enough.
(let ((y (cos (/ pi 2)))
(< (abs y) (* fudge (* pi long-float-epsilon 1/2))))
;; As in 1045, tan(x) = sin(x)/cos(x). When x = pi/2+pi*eps/2, sin(x)
;; is essentially 1, but cos(x) is about pi/2*eps. So tan(x) =
;; 1/cos(x). So we have 1/tan(x) = cos(x). But from 1061, we know
;; that cos(x) ~= -pi*eps/2. So our check is |1/tan(x) - cos(x)| is
;; close enough to zero.
(let* ((fudge 2)
(val (tan (/ pi 2)))
(ref (cos (/ pi 2)))
(rel-err (abs (/ (- (/ val) ref) ref))))
(< rel-err (* fudge long-float-epsilon)))
Note that Clisp fails test 1073 because, strangely, 1/tan(x) gives
a quite different value from cos(x) here.