3 * Incomplete elliptic integral of the second kind
9 * double phi, m, y, ellie();
11 * y = ellie( 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 [-10, 10] and m in
40 * arithmetic domain # trials peak rms
41 * DEC 0,2 2000 1.9e-16 3.4e-17
42 * IEEE -10,10 150000 3.3e-15 1.4e-16
49 Cephes Math Library Release 2.8: June, 2000
50 Copyright 1984, 1987, 1993, 2000 by Stephen L. Moshier
53 /* Incomplete elliptic integral of second kind */
55 extern double PI, PIO2, MACHEP;
57 extern double sqrt ( double );
58 extern double fabs ( double );
59 extern double log ( double );
60 extern double sin ( double x );
61 extern double tan ( double x );
62 extern double atan ( double );
63 extern double floor ( double );
64 extern double ellpe ( double );
65 extern double ellpk ( double );
66 double ellie ( double, double );
68 double sqrt(), fabs(), log(), sin(), tan(), atan(), floor();
69 double ellpe(), ellpk(), ellie();
72 double ellie( phi, m )
75 double a, b, c, e, temp;
77 int d, mod, npio2, sign;
82 npio2 = floor( lphi/PIO2 );
85 lphi = lphi - npio2 * PIO2;
104 /* Thanks to Brian Fitzgerald <fitzgb@mml0.meche.rpi.edu>
105 for pointing out an instability near odd multiples of pi/2. */
108 /* Transform the amplitude */
110 /* ... but avoid multiple recursions. */
114 temp = E + m * sin( lphi ) * sin( e ) - ellie( e, m );
124 while( fabs(c/a) > MACHEP )
127 lphi = lphi + atan(t*temp) + mod * PI;
128 mod = (lphi + PIO2)/PI;
129 t = t * ( 1.0 + temp )/( 1.0 - temp * t * t );
131 temp = sqrt( a * b );
138 temp = E / ellpk( 1.0 - m );
139 temp *= (atan(t) + mod * PI)/(d * a);