Commit e10e402d446339130042607357b0129b35a1faa7

Authored by Raymond Toy
1 parent 1d9ec007

Correct the computation of s-exp-integral-e when v is an integer. Add

tests.
Showing 2 changed files with 22 additions and 10 deletions
qd-gamma.lisp
... ... @@ -501,16 +501,14 @@
501 501 (- (* (/ (expt -z (- v 1))
502 502 (gamma v))
503 503 (- (psi v) (log z)))
504   - (loop for k from 0 below n
505   - for term = 1 then (* term (/ -z k))
506   - for sum = (/ (- 1 v)) then (+ sum (/ term (+ k 1 -v)))
507   - when (< (abs term) (* (abs sum) eps))
508   - return sum)
509   - (loop for k from n
510   - for term = 1 then (* term (/ -z k))
511   - for sum = 0 then (+ sum (/ term (+ k 1 -v)))
512   - when (< (abs term) (* (abs sum) eps))
513   - return sum)))
  504 + (loop for k from 0
  505 + for term = 1 then (* term (/ -z k))
  506 + for sum = (/ (- 1 v)) then (+ sum (let ((denom (+ k 1 (- n))))
  507 + (if (zerop denom)
  508 + 0
  509 + (/ term (+ k 1 -v)))))
  510 + when (< (abs term) (* (abs sum) eps))
  511 + return sum)))
514 512 (loop for k from 0
515 513 for term = 1 then (* term (/ -z k))
516 514 for sum = (/ (- 1 v)) then (+ sum (/ term (+ k 1 -v)))
... ...
rt-tests.lisp
... ... @@ -1464,3 +1464,17 @@
1464 1464 (expt x 4))))
1465 1465 (check-accuracy 210.8 e true))
1466 1466 nil)
  1467 +
  1468 +(rt:deftest expintegral-e.5d
  1469 + (let* ((x .5d0)
  1470 + (e (exp-integral-e 2d0 x))
  1471 + (true #q0.3266438623245530177304015653336378358284946903290101))
  1472 + (check-accuracy 51.2 e true))
  1473 + nil)
  1474 +
  1475 +(rt:deftest expintegral-e.5q
  1476 + (let* ((x #q.5)
  1477 + (e (exp-integral-e #q2 x))
  1478 + (true #q0.326643862324553017730401565333637835828494690329010198058745549181386569998611289568))
  1479 + (check-accuracy 208.4 e true))
  1480 + nil)
1467 1481 \ No newline at end of file
... ...