Commit 36403a83 authored by Raymond Toy's avatar Raymond Toy
Browse files

Correct bug in tan.

 * code/irrat.lisp
   * Fix typo in kernel-tan.
 * tests/trig.lisp
   * Add test case.
parent 7069ef9d
...@@ -489,11 +489,11 @@ ...@@ -489,11 +489,11 @@
r)))))))) r))))))))
(when (= iy 1) (when (= iy 1)
(return-from kernel-tan w)) (return-from kernel-tan w))
;; ;; Compute 1/w=1/(x+r) carefully
(let ((a 0d0) (let ((a 0d0)
(tt 0d0)) (tt 0d0))
(setf z (kernel:make-double-float (kernel:double-float-high-bits w) 0)) (setf z (kernel:make-double-float (kernel:double-float-high-bits w) 0))
(setf v (- r (- r x))) ; z + v = r + x (setf v (- r (- z x))) ; z + v = r + x
(setf a (/ -1 w)) (setf a (/ -1 w))
(setf tt (kernel:make-double-float (kernel:double-float-high-bits a) 0)) (setf tt (kernel:make-double-float (kernel:double-float-high-bits a) 0))
(setf s (+ 1 (* tt z))) (setf s (+ 1 (* tt z)))
......
...@@ -127,6 +127,12 @@ ...@@ -127,6 +127,12 @@
(tan (float 11/16 1d0)) (tan (float 11/16 1d0))
8.21141801589894121911423965374711700875371645309d-1) 8.21141801589894121911423965374711700875371645309d-1)
(rt:deftest tan.6
;; This was found by maxima's testsuite. A bug in kernel-tan when
;; returning cot(x).
(tan 1.107148717794091d0)
2.0000000000000028604455051971538975562294147582d0)
(rt:deftest tan.red.0 (rt:deftest tan.red.0
;; Test for argument reduction with n even ;; Test for argument reduction with n even
(tan (* 7/4 pi)) (tan (* 7/4 pi))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment