3 * Incomplete elliptic integral of the second kind
9 * float phi, m, y, ellief();
11 * y = ellief( phi, m );
17 * Approximates the integral
24 * E(phi\m) = | sqrt( 1 - m sin t ) dt
30 * of amplitude phi and modulus m, using the arithmetic -
31 * geometric mean algorithm.
37 * Tested at random arguments with phi in [0, 2] and m in
40 * arithmetic domain # trials peak rms
41 * IEEE 0,2 10000 4.5e-7 7.4e-8
48 Cephes Math Library Release 2.2: July, 1992
49 Copyright 1984, 1987, 1992 by Stephen L. Moshier
50 Direct inquiries to 30 Frost Street, Cambridge, MA 02140
53 /* Incomplete elliptic integral of second kind */
57 extern float PIF, PIO2F, MACHEPF;
59 #define fabsf(x) ( (x) < 0 ? -(x) : (x) )
62 float sqrtf(float), logf(float), sinf(float), tanf(float), atanf(float);
63 float ellpef(float), ellpkf(float);
65 float sqrtf(), logf(), sinf(), tanf(), atanf();
66 float ellpef(), ellpkf();
71 float ellief( float phia, float ma )
73 float ellief( phia, ma )
77 float phi, m, a, b, c, e, temp;
97 mod = (lphi + PIO2F)/PIF;
99 while( fabsf(c/a) > MACHEPF )
102 lphi = lphi + atanf(t*temp) + mod * PIF;
103 mod = (lphi + PIO2F)/PIF;
104 t = t * ( 1.0 + temp )/( 1.0 - temp * t * t );
106 temp = sqrtf( a * b );
114 temp = ellpef(b)/ellpkf(b);
115 temp *= (atanf(t) + mod * PIF)/(d * a);