Commit 4b332ed2 by Raymond Toy

### Fix bug in psi for -n/2 for n odd which was causing an overflow. Add

tests too.
parent 9d3daf46
 ... ... @@ -707,6 +707,8 @@ (realpart (ci z)) (ci z)))) ;; Array of values of the Bernoulli numbers. We only have enough for ;; the evaluation of the psi function. (defconstant bern-values (make-array 55 :initial-contents ... ... @@ -793,8 +795,15 @@ ;; formula to increase the argument and then apply the asymptotic formula. (cond ((minusp (realpart z)) (- (psi (- 1 z)) (* +pi+ (/ (tan (* +pi+ z)))))) (let ((p (float +pi+ (realpart z)))) (flet ((cot-pi (z) ;; cot(%pi*z), car (handler-case (/ (tan (* p z))) (division-by-zero () (* 0 z))))) (- (psi (- 1 z)) (* p (cot-pi z)))))) (t (let* ((k (* 2 (1+ (floor (* .41 (- (log (epsilon z) 10))))))) (m 0) ... ...
 ... ... @@ -1363,6 +1363,58 @@ (check-accuracy 212 s true)) nil) (rt:deftest psi.1d (let* ((z 1d0) (p (psi z)) (true (float (- +%gamma+) 1d0))) (check-accuracy 52 p true)) nil) (rt:deftest psi.1q (let* ((z #q1) (p (psi z)) (true (- +%gamma+))) (check-accuracy 208 p true)) nil) (rt:deftest psi.2d (let* ((z (float 4/3 1d0)) (p (psi z)) (true (- 3 +%gamma+ (/ +pi+ (* 2 (sqrt #q3))) (* 1.5 (log #q3))))) (check-accuracy 49.8 p true)) nil) (rt:deftest psi.2d (let* ((z (float 4/3 #q1)) (p (psi z)) (true (- 3 +%gamma+ (/ +pi+ (* 2 (sqrt #q3))) (* 1.5 (log #q3))))) (check-accuracy 205 p true)) nil) (rt:deftest psi.3d (let* ((z (float -1/2 1d0)) (p (psi z)) (true (- 2 +%gamma+ (log #q4)))) (check-accuracy 48 p true)) nil) (rt:deftest psi.3q (let* ((z (float -1/2 #q1)) (p (psi z)) (true (- 2 +%gamma+ (log #q4)))) (check-accuracy 204.1 p true)) nil) (rt:deftest expintegral-e.1d (let* ((z 1d0) (e (exp-integral-e 0 z)) ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!