tango.math.Elliptic

Elliptic integrals. The functions are named similarly to the names used in Mathematica.

License:

BSD style: see license.txt

Authors:

Stephen L. Moshier (original C code). Conversion to D by Don Clugston

References:

real ellipticF(real phi, real m)
Incomplete elliptic integral of the first kind
Approximates the integral F(phi | m) = 0phi dt/ (sqrt( 1- m sin2 t))

of amplitude phi and modulus m, using the arithmetic - geometric mean algorithm.
real ellipticE(real phi, real m)
Incomplete elliptic integral of the second kind
Approximates the integral

E(phi | m) = 0phi sqrt( 1- m sin2 t) dt

of amplitude phi and modulus m, using the arithmetic - geometric mean algorithm.
real ellipticKComplete(real x)
Complete elliptic integral of the first kind
Approximates the integral

K(m) = 0π/2 dt/ (sqrt( 1- m sin2 t))

where m = 1 - x, using the approximation

P(x) - log x Q(x).

The argument x is used rather than m so that the logarithmic singularity at x = 1 will be shifted to the origin; this preserves maximum accuracy.

x must be in the range 0 <= x <= 1

This is equivalent to ellipticF(PI_2, 1-x).

K(0) = π/2.
real ellipticEComplete(real x)
Complete elliptic integral of the second kind
Approximates the integral

E(m) = 0π/2 sqrt( 1- m sin2 t) dt

where m = 1 - x, using the approximation

P(x) - x log x Q(x).

Though there are no singularities, the argument m1 is used rather than m for compatibility with ellipticKComplete().

E(1) = 1; E(0) = π/2. m must be in the range 0 <= m <= 1.
real ellipticPi(real phi, real m, real n)
Incomplete elliptic integral of the third kind
Approximates the integral

PI(n; phi | m) = t=0phi dt/((1 - n sin2t) * sqrt( 1- m sin2 t))

of amplitude phi, modulus m, and characteristic n using Gauss-Legendre quadrature. Note that ellipticPi(PI_2, m, 1) is infinite for any m.
real ellipticPiComplete(real m, real n)
Complete elliptic integral of the third kind