Commit d80256d66d585a69813f277b115d039cc620e62d

Authored by Raymond Toy
1 parent b1ae6953

Need to apply contagion for exp-integral-e.

Showing 1 changed file with 23 additions and 20 deletions
qd-gamma.lisp
... ... @@ -528,27 +528,30 @@
528 528 ;; for |arg(z)| < pi.
529 529 ;;
530 530 ;;
531   - (cond ((and (realp v) (minusp v))
532   - ;; E(-v, z) = z^(-v-1)*incomplete_gamma_tail(v+1,z)
533   - (let ((-v (- v)))
  531 + (let* ((prec (float-contagion v z))
  532 + (v (apply-contagion v prec))
  533 + (z (apply-contagion z prec)))
  534 + (cond ((and (realp v) (minusp v))
  535 + ;; E(-v, z) = z^(-v-1)*incomplete_gamma_tail(v+1,z)
  536 + (let ((-v (- v)))
  537 + (* (expt z (- v 1))
  538 + (incomplete-gamma-tail (+ -v 1) z))))
  539 + ((< (abs z) 1)
  540 + ;; Use series for small z
  541 + (s-exp-integral-e v z))
  542 + ((>= (abs (phase z)) 3.1)
  543 + ;; The continued fraction doesn't converge on the negative
  544 + ;; real axis, and converges very slowly near the negative
  545 + ;; real axis, so use the incomplete-gamma-tail function in
  546 + ;; this region. "Closeness" to the negative real axis is
  547 + ;; teken to mean that z is in a sector near the axis.
  548 + ;;
  549 + ;; E(v,z) = z^(v-1)*incomplete_gamma_tail(1-v,z)
534 550 (* (expt z (- v 1))
535   - (incomplete-gamma-tail (+ -v 1) z))))
536   - ((< (abs z) 1)
537   - ;; Use series for small z
538   - (s-exp-integral-e v z))
539   - ((>= (abs (phase z)) 3.1)
540   - ;; The continued fraction doesn't converge on the negative
541   - ;; real axis, and converges very slowly near the negative
542   - ;; real axis, so use the incomplete-gamma-tail function in
543   - ;; this region. "Closeness" to the negative real axis is
544   - ;; teken to mean that z is in a sector near the axis.
545   - ;;
546   - ;; E(v,z) = z^(v-1)*incomplete_gamma_tail(1-v,z)
547   - (* (expt z (- v 1))
548   - (incomplete-gamma-tail (- 1 v) z)))
549   - (t
550   - ;; Use continued fraction for everything else.
551   - (cf-exp-integral-e v z))))
  551 + (incomplete-gamma-tail (- 1 v) z)))
  552 + (t
  553 + ;; Use continued fraction for everything else.
  554 + (cf-exp-integral-e v z)))))
552 555  
553 556 ;; Series for Fresnel S
554 557 ;;
... ...