| 1 | ;; Elliptic integrals |
|---|
| 2 | ;; Liam Healy, Mon Mar 20 2006 - 21:50 |
|---|
| 3 | ;; Time-stamp: <2008-03-13 17:27:04EDT elliptic-integrals.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | ;;;;**************************************************************************** |
|---|
| 9 | ;;;; Legendre form of complete elliptic integrals |
|---|
| 10 | ;;;;**************************************************************************** |
|---|
| 11 | |
|---|
| 12 | (defmfun elliptic-integral-K-complete (k) |
|---|
| 13 | "gsl_sf_ellint_Kcomp_e" ((k :double) :mode (ret sf-result)) |
|---|
| 14 | :documentation ; FDL |
|---|
| 15 | "The complete elliptic integral of the first kind, K(k). Note that |
|---|
| 16 | Abramowitz & Stegun define this function in terms of the parameter m |
|---|
| 17 | = k^2.") |
|---|
| 18 | |
|---|
| 19 | (defmfun elliptic-integral-E-complete (k) |
|---|
| 20 | "gsl_sf_ellint_Ecomp_e" ((k :double) :mode (ret sf-result)) |
|---|
| 21 | :documentation ; FDL |
|---|
| 22 | "The complete elliptic integral of the second kind, E(k). |
|---|
| 23 | Note that Abramowitz & Stegun define this function in terms of the |
|---|
| 24 | parameter m = k^2.") |
|---|
| 25 | |
|---|
| 26 | ;;;;**************************************************************************** |
|---|
| 27 | ;;;; Legendre form of incomplete elliptic integrals |
|---|
| 28 | ;;;;**************************************************************************** |
|---|
| 29 | |
|---|
| 30 | (defmfun elliptic-integral-F (phi k) |
|---|
| 31 | "gsl_sf_ellint_F_e" ((phi :double) (k :double) :mode (ret sf-result)) |
|---|
| 32 | :documentation ; FDL |
|---|
| 33 | "The incomplete elliptic integral of the first kind, F(phi,k). Note |
|---|
| 34 | that Abramowitz & Stegun define this function in terms of the |
|---|
| 35 | parameter m = k^2.") |
|---|
| 36 | |
|---|
| 37 | (defmfun elliptic-integral-E (phi k) |
|---|
| 38 | "gsl_sf_ellint_E_e" ((phi :double) (k :double) :mode (ret sf-result)) |
|---|
| 39 | :documentation ; FDL |
|---|
| 40 | "The incomplete elliptic integral of the second kind, E(phi,k). Note |
|---|
| 41 | that Abramowitz & Stegun define this function in terms of the |
|---|
| 42 | parameter m = k^2.") |
|---|
| 43 | |
|---|
| 44 | (defmfun elliptic-integral-P (phi k n) |
|---|
| 45 | "gsl_sf_ellint_P_e" |
|---|
| 46 | ((phi :double) (k :double) (n :double) :mode (ret sf-result)) |
|---|
| 47 | :documentation ; FDL |
|---|
| 48 | "The incomplete elliptic integral of the third kind, P(phi,k,n). |
|---|
| 49 | Note that Abramowitz & Stegun define this function in terms of the |
|---|
| 50 | parameters m = k^2 and sin^2(alpha) = k^2, with the change of sign |
|---|
| 51 | n to -n.") |
|---|
| 52 | |
|---|
| 53 | (defmfun elliptic-integral-D (phi k n) |
|---|
| 54 | "gsl_sf_ellint_D_e" |
|---|
| 55 | ((phi :double) (k :double) (n :double) :mode (ret sf-result)) |
|---|
| 56 | :documentation ; FDL |
|---|
| 57 | "The incomplete elliptic integral D(phi,k,n) which is |
|---|
| 58 | defined through the Carlson form RD(x,y,z) |
|---|
| 59 | by the following relation: |
|---|
| 60 | D(phi,k,n) = RD (1-sin^2(phi), 1-k^2 sin^2(phi), 1).") |
|---|
| 61 | |
|---|
| 62 | ;;;;**************************************************************************** |
|---|
| 63 | ;;;; Carlson forms |
|---|
| 64 | ;;;;**************************************************************************** |
|---|
| 65 | |
|---|
| 66 | (defmfun elliptic-integral-RC (x y) |
|---|
| 67 | "gsl_sf_ellint_RC_e" ((x :double) (y :double) :mode (ret sf-result)) |
|---|
| 68 | :documentation ; FDL |
|---|
| 69 | "The incomplete elliptic integral RC(x,y).") |
|---|
| 70 | |
|---|
| 71 | (defmfun elliptic-integral-RD (x y z) |
|---|
| 72 | "gsl_sf_ellint_RD_e" |
|---|
| 73 | ((x :double) (y :double) (z :double) :mode (ret sf-result)) |
|---|
| 74 | :documentation ; FDL |
|---|
| 75 | "The incomplete elliptic integral RD(x,y,z).") |
|---|
| 76 | |
|---|
| 77 | (defmfun elliptic-integral-RF (x y z) |
|---|
| 78 | "gsl_sf_ellint_RF_e" |
|---|
| 79 | ((x :double) (y :double) (z :double) :mode (ret sf-result)) |
|---|
| 80 | :documentation ; FDL |
|---|
| 81 | "The incomplete elliptic integral RF(x,y,z).") |
|---|
| 82 | |
|---|
| 83 | (defmfun elliptic-integral-RJ (x y z p) |
|---|
| 84 | "gsl_sf_ellint_RJ_e" |
|---|
| 85 | ((x :double) (y :double) (z :double) (p :double) :mode (ret sf-result)) |
|---|
| 86 | :documentation ; FDL |
|---|
| 87 | "The incomplete elliptic integral RJ(x,y,z,p).") |
|---|
| 88 | |
|---|
| 89 | ;;;;**************************************************************************** |
|---|
| 90 | ;;;; Examples and unit test |
|---|
| 91 | ;;;;**************************************************************************** |
|---|
| 92 | |
|---|
| 93 | #| |
|---|
| 94 | (make-tests elliptic-integrals |
|---|
| 95 | (elliptic-integral-K-complete 0.0d0) |
|---|
| 96 | (elliptic-integral-E-complete 0.0d0) |
|---|
| 97 | (elliptic-integral-F -0.5d0 2.0d0) |
|---|
| 98 | (elliptic-integral-E -0.5d0 2.0d0) |
|---|
| 99 | (elliptic-integral-P -0.5d0 2.0d0 1.0d0) |
|---|
| 100 | (elliptic-integral-D -0.5d0 2.0d0 1.0d0) |
|---|
| 101 | (elliptic-integral-RC 2.0d0 1.0d0) |
|---|
| 102 | (elliptic-integral-RD 2.0d0 1.0d0 1.0d0) |
|---|
| 103 | (elliptic-integral-RF 2.0d0 1.0d0 1.0d0) |
|---|
| 104 | (elliptic-integral-RJ 2.0d0 1.0d0 1.0d0 2.0d0)) |
|---|
| 105 | |# |
|---|
| 106 | |
|---|
| 107 | (LISP-UNIT:DEFINE-TEST ELLIPTIC-INTEGRALS |
|---|
| 108 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 109 | (LIST 1.5707963267948966d0 4.598091522633788d-16) |
|---|
| 110 | (MULTIPLE-VALUE-LIST |
|---|
| 111 | (ELLIPTIC-INTEGRAL-K-COMPLETE 0.0d0))) |
|---|
| 112 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 113 | (LIST 1.5707963267948966d0 3.487868498008632d-16) |
|---|
| 114 | (MULTIPLE-VALUE-LIST |
|---|
| 115 | (ELLIPTIC-INTEGRAL-E-COMPLETE 0.0d0))) |
|---|
| 116 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 117 | (LIST -0.6774175382039307d0 3.008338192795582d-16) |
|---|
| 118 | (MULTIPLE-VALUE-LIST |
|---|
| 119 | (ELLIPTIC-INTEGRAL-F -0.5d0 2.0d0))) |
|---|
| 120 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 121 | (LIST -0.4018194805534952d0 4.232239429377521d-16) |
|---|
| 122 | (MULTIPLE-VALUE-LIST |
|---|
| 123 | (ELLIPTIC-INTEGRAL-E -0.5d0 2.0d0))) |
|---|
| 124 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 125 | (LIST -0.617791316339182d0 1.6365659051690947d-16) |
|---|
| 126 | (MULTIPLE-VALUE-LIST |
|---|
| 127 | (ELLIPTIC-INTEGRAL-P -0.5d0 2.0d0 1.0d0))) |
|---|
| 128 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 129 | (LIST -0.06889951441260889d0 3.059753091454848d-17) |
|---|
| 130 | (MULTIPLE-VALUE-LIST |
|---|
| 131 | (ELLIPTIC-INTEGRAL-D -0.5d0 2.0d0 1.0d0))) |
|---|
| 132 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 133 | (LIST 0.8813735870195432d0 1.9570424992111216d-16) |
|---|
| 134 | (MULTIPLE-VALUE-LIST |
|---|
| 135 | (ELLIPTIC-INTEGRAL-RC 2.0d0 1.0d0))) |
|---|
| 136 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 137 | (LIST 0.7992599630303281d0 1.7747136272346433d-16) |
|---|
| 138 | (MULTIPLE-VALUE-LIST |
|---|
| 139 | (ELLIPTIC-INTEGRAL-RD 2.0d0 1.0d0 1.0d0))) |
|---|
| 140 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 141 | (LIST 0.8813735870195432d0 1.9570424992111216d-16) |
|---|
| 142 | (MULTIPLE-VALUE-LIST |
|---|
| 143 | (ELLIPTIC-INTEGRAL-RF 2.0d0 1.0d0 1.0d0))) |
|---|
| 144 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 145 | (LIST 0.5228004174989865d0 1.160850121582039d-16) |
|---|
| 146 | (MULTIPLE-VALUE-LIST |
|---|
| 147 | (ELLIPTIC-INTEGRAL-RJ 2.0d0 1.0d0 1.0d0 2.0d0)))) |
|---|