Volume 107, Number 5, September–October 2002 Journal of Research of the National Institute of Standards and Technology

[J. Res. Natl. Inst. Stand. Technol. 107, 413–418 (2002)] Three Improvements in Reduction and Computation of Elliptic

Volume 107 Number 5 September–October 2002

B. C. Carlson Three improvements in reduction and com- for the symmetric elliptic of the putation of elliptic integrals are made. 1. first kind. Its usefulness for elliptic inte- Ames Laboratory and Department Reduction formulas, used to express many grals, in particular, is important. of Mathematics, elliptic integrals in terms of a few stan- Iowa State University, dard integrals, are simplified by modifying Key words: computational algorithm; ele- the definition of intermediate “basic inte- Ames, IA 50011-3020 mentary symmetric ; elliptic inte- grals.” 2. A faster than quadratically con- gral; hyperelliptic integral; hypergeometric vergent series is given for numerical R-function; recurrence relations; series computation of the complete symmetric el- expansion. liptic integral of the third kind. 3. A se- ries expansion of an elliptic or hyperelliptic integral in elementary symmetric func- Accepted: August 6, 2002 tions is given, illustrated with numerical co- efficients for terms through degree seven Available online: http://www.nist.gov/jres

Foreword

Elliptic integrals have many applications, for example references to extensions and generalizations, graphs, in mathematics and physics: brief descriptions of computational methods, a survey of • arclengths of plane curves (, , useful published tables, and sample applications. The Bernoulli’s lemniscate) Web site will include, in addition, interactive visualiza- • surface area of an in 3-dimensional space tions of 3-dimensional surfaces, a mathematics-aware • electric and magnetic fields associated with search engine, a downloading capability for equations, • periodicity of anharmonic oscillators live links to Web sites that provide mathematical soft- • mutual inductance of coaxial circles ware, and a limited facility for generating tables on • age of the universe in a Friedmann model demand. These applications are mentioned in the chapter on el- The DLMF is modeled after the Handbook of Mathe- liptic integrals, written by B. C. Carlson, that will ap- matical Functions, published in 1964 by the National pear in the NIST Digital Library of Mathematical Func- Bureau of Standards with M. Abramowitz and I. A. tions. Stegun as editors. This handbook has been enormously The DLMF is scheduled to begin service in 2003 successful: it has sold more than 500,000 copies, its from a NIST Web site. A hardcover book will be pub- sales remain high, and it is very frequently cited in lished also. These resources will provide a complete journal articles in physics and many other fields. But guide to the higher mathematical functions for use by new properties of the higher functions have been devel- experienced scientific professionals. The book will oped, and new functions have risen in importance in provide mathematical formulas, references to proofs, applications, since the publication of the Abramowitz

413 Volume 107, Number 5, September–October 2002 Journal of Research of the National Institute of Standards and Technology

and Stegun handbook. More than half of the old hand- which follows is an example. It is a further development book was devoted to tables, now made obsolete by the of material that appears in Carlson’s DLMF chapter on revolutionary improvements since 1964 in computers elliptic integrals. and software. The need for a modern reference is being filled by more than 30 expert authors who are working Daniel W. Lozier under contract to NIST and supervised by four NIST NIST Mathematical and Computational Sciences editors. The writing is being edited carefully to assure Division consistent style and level of content. Elliptic integrals have long been associated with the name of Legendre. Legendre’s incomplete elliptic inte- 1. Simplified Formulas for Reducing grals are Elliptic Integrals

␾ d␪ A large class of elliptic integrals can be written in the F(␾, k)=͵ , 2 2 0 ͙1 Ϫ k sin ␪ form

x h n Ϫ ␾ ͵ ͹ 1/2 ͹ mj I(m)= (ai + bi t) (aj + bj t) dt, (1.1) E(␾, k)=͵ ͙1 Ϫ k 2 sin2 ␪ d␪, y i=1 j=1 0 where m =(m1,...,mn )isann-tuple of integers (posi- and tive, negative or zero), x > y, h = 3 or 4, n Ն h, and the different linear factors are not proportional. The a’s and ␾ d␪ b’s may be complex (with the b’s not equal to zero), but ⌸(␾, ␣ 2, k)=͵ . 2 2 2 2 0 ͙1 Ϫ k sin ␪ (1 Ϫ ␣ sin ␪) the integral is assumed to be well defined, possibly as a Cauchy principal value. In particular the line segment

The complete forms of these integrals are obtained by with endpoints ai + bi x and ai + bi y is assumed to lie in setting ␾ = ␲/2. the cut plane C\(( Ϫϱ, 0) for 1 Յ i Յ h. ͚n Over a period of more than 35 years, Carlson has We write m = j=1 mj ej , where ej is an n-tuple with 1 published a series of papers that provide valuable new in the jth position and 0’s elsewhere, and we define mathematical and computational foundations for the 0 = (0, ..., 0). Reference [1] gives a general method of subject in terms of the symmetric elliptic integrals reducing I(m) to a linear combination of “basic inte-

grals,” defined as I(0), I(Ϫej ), 1 Յ j Յ n, and (if h =4) ϱ Յ Յ 1 ͵ dt I(ek ), 1 k 4. A simple example of such a reduction RF (x, y, z)= , 2 0 s(t) is

bi I(ej Ϫ ei )=dji I(Ϫei )+bj I(0), ϱ 3 ͵ dt RD (x, y, z)= , ʦ 2 0 s(t)(t + z) i, j {1, ..., n}, (1.2)

where dji = ajbi Ϫ aibj . This equation reduces all 36+72 ϱ 3 ͵ dt integrals in Ref. [2], Eqs. (3.142) and (3.168) and also RJ (x, y, z, p)= 2 2 0 s(t)(t + p) the 18 integrals in Ref. [2], Eq. (3.159) after taking x as a new variable of integration. The basic integrals are

where expressed in terms of symmetric standard integrals RF ,

RD ,andRJ in Ref. [1], Sec. 4. s(t)=͙t + x ͙t + y ͙t + z. The general method first reduces I(m) by Ref. [1], Eq. (2.19) to integrals in which m has at most one The complete forms are obtained by setting x =0.In nonzero component and then uses two recurrence rela- comparison with Legendre’s integrals, Carlson’s inte- tions Ref. [1] Eqs. (3.5) and (3.11) for further reduction grals simplify the reduction of general elliptic integrals to basic integrals. For example, the simplest recurrence to standard forms and open the way to efficient compu- relation is Ref. [1], Eq. (3.11): tations by application of a duplication theorem. q q Ϫ One of the purposes of the DLMF project is to stim- q ͸ͩ ͪ r q r ʦ ގ bi I(qej )= bj dji I(rei ), q . (1.3) ulate research into the theory, computation and applica- r=0 r tion of the higher mathematical functions. The paper

414 Volume 107, Number 5, September–October 2002 Journal of Research of the National Institute of Standards and Technology

n ␣ ␣ The b’s appear also in the other two formulas and there- ␩Ϯ1 (i)иии␩Ϯs (i) ⌬ ͹ mj ˆ ˆ ͸ 1 s i = rji , C0(i)=1, CϮs (i)= ␣ иии␣ , fore in all reduction formulas, sometimes in great profu- j=1 1! s ! sion if m is considerably more complicated than in Eq. ji Ϫ n (1.2). ␩ 1 ͸ Ϯp Ն Ϯp (i)= mj rij , p 1, (1.11) It has been found that the b’s disappear from all three p j=1 formulas, and therefore from all reduction formulas, if ji we define where upper (lower) signs go together and the first sum

Iˆ(m)=I(m)/B, Aˆ (m)=A(m)/B, extends over all nonnegative integers ␣1,...,␣s such that ␣1 +2␣2 +...+s␣s = s. A recurrence relation for the n d a a coefficients is ͹ mj ij i Ϫ j B = bj , rij = = . (1.4) j=1 bibj bi bj s ˆ ͸ ␩ ˆ Ն sCϮs (i)= p Ϯp (i) CϮ(sϪp)(i), s 1. (1.12) Here A(m) is the algebraic function p=1

A(m)=fm(x) Ϫ fm(y), (1.5) 2. Algorithms for Complete Elliptic where fm(t) is the integrand of Eq. (1.1). Note that Integrals of the Third Kind Iˆ(0)=I(0). For example, Eq. (1.2) becomes Complications formerly encountered in numerical computation of Legendre’s complete elliptic integral of

Iˆ(ej Ϫ ei )=rji Iˆ(Ϫei )+I(0), (1.6) the third kind were avoided by defining and tabulating Heuman’s Lambda function (for circular cases) and a and Eq. (1.3) becomes modification of Jacobi’s Zeta function (for hyperbolic cases). For example, the method of Ref. [3] was later q q Ϫ ˆ ͸ͩ ͪ q r ˆ ʦ ގ superseded by Bartky’s transformation and its applica- I(qej )= rji I(rei ), q . (1.7) r=0 r tion by Bulirsch [4] to his complete integral cel(kc , p, a, b). Bartky’s transformation for the com- The other recurrence relation, Ref. [1], Eq. (3.5), be- plete case of the symmetric integral of the third kind, comes obtained from Ref. [5], Eq. (4.14) with the help of

h ␲ Ϫ ͸ ˆ Ϫ (3 /4)RL (y, z, p)=3RF (0, y, z) pRJ (0, y, z, p), (2q + r)EhϪr (r1j ,...,rhj )I((q 1+r)ej ) r=0 (␲/2)RK (y, z)=RF (0, y, z), (2.1) h ˆ ͩ ͸ ͪ ʦ ޚ Յ Յ =2A qej + ei , q ,1 j n (1.8) i=1 can be written as

2 2 2 2 2 2 where EhϪr is the elementary symmetric function de- RJ (0, gn , an , pn )=snRJ (0, gn+1, an+1, pn+1) fined by 2 2 2 + (3/2pn )RF (0, gn+1, an+1), (2.2) h h ͹ ͸ k (1 + trij )= t Ek (r1j ,...,rhj ), (1.9) 4 Ϫ 2 2 4 i=1 k=0 where an , gn , pn are positive, sn =(pn an gn )/8pn ,and

2 whence Eh = 0 if 1 Յ j Յ h because rjj =0. an + gn pn + angn an+1 = , gn+1 = ͙angn , pn+1 = , The remaining formula, Ref. [1], Eq. (2.19), becomes 2 2pn

Ϫ M n mi ʦ ގ ˆ ͸ ˆ ˆ ͸⌬ ͸ ˆ ˆ Ϫ n . (2.3) I(m)= CMϪq (k)I(qek )+ i Cmi+q (i)I( qei ), q=0 i=1 q=1 (1.10) As n → ϱ, an and gn converge quadratically to

Gauss’s arithmetic-geometric mean, M(a0, g0), and ͚n where M = j=1 mj and each sum is empty if its upper 2 2 limit is less than its lower limit. The first term on the RF (0, gn , an )=␲/2M(a0, g0), n ʦ ގ, (2.4) right is independent of k, which is usually best chosen so that 1 Յ k Յ h. The coefficients are defined by by Ref. [6], Eqs. (6.10-8) and Eq. (2.1). It follows from

415 Volume 107, Number 5, September–October 2002 Journal of Research of the National Institute of Standards and Technology

2 (2.3) that where we have used Eq. (2.4) and chosen xi = a0 in Ref. [7], Eq. (4.6). Substitution of Eq. (2.9) gives 2 pn+1 Ϫ gn+1 =(pn Ϫ gn+1) /2pn . (2.5) Ϫ ␲ 2 2 Ϫ 2 3 RJ (0, g0 , a0 , q0 )= 2 2 Since gn+1 converges quadratically to M(a0, g0), so does 4M(a0, g0)(q0 + a0 ) pn ,andsn converges quadratically to 0. Iteration of Eq. ϱ 2 Ϫ 2 (2.2) gives ͩ a0 g0 ͸ ͪ 2+ 2 2 Qn . (2.12) q0 + g0 n=0 2 2 2 2 Qnpn 2 2 2 RJ (0, g0 , a0 , p0 )= 2 RJ (0, gn , an , pn ) p0 Equation (2.3) and the second line of Eq. (2.9) still

apply, with p0 given by Eq. (2.11). Ϫ 3␲ n͸1 For the complete case of Legendre’s third integral, + 2 Qm , (2.6) 4p0 M(a0, g0) m=0 2 2 2 2 2 ⌸(␣ , k)=(␣ /3)RJ (0, k' ,1,1Ϫ ␣ )+RF (0, k' , 1), where (2.13)

иии 2 Ϫ 2 Qm s0s1 smϪ1 Ն where k' =1 k , Eq. (2.9) implies Q0 =1, 2 = 2 , m 1, (2.7) p0 pm ϱ ␲ ␣ 2 ⌸ ␣ 2 ͩ ͸ ͪ ( , k)= 2+ Ϫ ␣ 2 Qn , and therefore 4M(1, k') 1 n=0

2 2 2 2 Qn+1 snpn 1 pn Ϫ angn Ϫϱ < k <1, Ϫϱ < ␣ < 1, (2.14) = 2 = 2 . (2.8) Qn pn+1 2 pn + angn where Eq. (2.3) applies with a0 =1, g0 = k',and 2 2 Letting n → ϱ in Eq. (2.6), we find, for positive p0 =1Ϫ ␣ . 2 a0, g0, p0, If ␣ > 1, Eq. (2.12) gives the Cauchy principal value,

ϱ ϱ ␲ Ϫ␲k 2 2 2 2 3 ͸ ⌸ ␣ 2 ͸ RJ (0, g0 , a0 , p0 )= 2 Qn , ( , k)= ␣ 2 Ϫ 2 Qn , 4p0 M(a0, g0) n=0 4M(1, k')( k ) n=0

2 Ϫ Ϫϱ 2 ␣ 2 ϱ 1 ⑀ ⑀ pn angn < k <1, 1< < , (2.15) Q0 =1, Qn+1 = Qn n , n = 2 , (2.9) 2 pn + angn where Eq. (2.3) and the second line of Eq. (2.9) apply 2 2 2 where ⑀n converges to 0 quadratically and Qn converges with a0 =1,g0 = k',andp0 =1Ϫ k /␣ . to 0 faster than quadratically.

If p0 = a0, Eq. (2.9) becomes 3. Expansion in Elementary Symmetric ␲ ϱ 2 2 3 ͸ Functions RD (0, g0 , a0 )= 2 Qn , 4a0 M(a0, g0) n=0 The duplication method of computing the symmetric

1 an Ϫ gn elliptic integrals RF and RJ (including their degenerate Q0 =1, Qn+1 = Qn⑀n , ⑀n = , (2.10) 2 an + gn cases RC and RD ) consists in iterating their duplication theorems until their variables are nearly equal and then

where RD is a complete integral of the second kind, expanding in a series of elementary symmetric functions

symmetric in only its first two arguments. If 0 < a0 Յ g0 of the small differences between the variables. In the then Ϫ1<⑀0 Յ 0, but ⑀n Ն 0andQn Յ 0forn Ն 1. absence of a duplication theorem the method is useful If the last variable of RJ is negative, the Cauchy prin- for a hyperelliptic integral only if the variables are cipal value is given by nearly equal. The series is truncated to a of fixed degree; the higher the degree, the fewer duplica- 2 2 2 2 2 2 2 2 2 2 (q0 + a0 )RJ (0, g0 , a0 , Ϫq0 )=(p0 Ϫ a0 )RJ (0, g0 , a0 , p0 ) tions are needed for a desired accuracy of the result but the larger the number of terms to be calculated. No tests ␲ 3 2 2 2 2 2 2 have been made to determine an optimal compromise, Ϫ , p0 = a0 (q0 + g0 )/(q0 + a0 ), (2.11) 2M(a0, g0) which would depend in large part on the speed of

416 Volume 107, Number 5, September–October 2002 Journal of Research of the National Institute of Standards and Technology extracting square roots in the duplication theorem and Applying Ref. [10], Eqs. (A.5) and (A.12) to the right therefore on the equipment used. In Ref. [8] polynomi- side of Eq. (3.5), we find als of degree five were chosen for simplicity, but later it seemed worthwhile to increase the degree for the com- RϪa (␤,...,␤; z1,...,zn ) paratively slow computation of RJ , and Ref. [9], Eq. ϱ R Ϫ a (A.11) gives the terms of degree six and seven for J . a͸ ( )N ␤ ␤ = A ␤ TN ( ,..., ; Z1,...,Zn ), (3.7) The change in speed would be significant only if a very N=0 (n )N large number of computations were performed, since ϱ m1 mn Ϫ a E иииE the result of a single computation is returned with no a͸ ( )N ͸ Ϫ N+M ␤ 1 n = A ␤ ( 1) ( )M иии , (3.8) delay apparent to the eye. We shall give here the corre- N=0 (n )N m1! mn ! sponding terms for RF and the general form of the in- ͚n finite series of which the are truncations. where (a)N is Pochhammer’s shifted factorial, M = i=1 Any R-function RϪa (b1,...,bk ; z1,...,zk ) (see Ref. mi , and the inner sum (representing TN ) extends over all [6]) in which all the b-parameters are positive integral nonnegative integers m1,...,mn such that m1 +2m2 multiples of a single number ␤ can be rewritten with + иии + nmn = N. Reference [10], Eq. (A.6) provides the repeated variables and all b’s equal to ␤. An example is recurrence relation

1 1 1 n R (x, y, z, p)=RϪ ( , , ,1;x, y, z, p) J 3/2 2 2 2 ͸ Ϫ r ␤ Ϫ NTN + ( 1) (r + N r)ErTNϪr = 0, (3.9) r=2 1 1 1 1 1 = RϪ3/2(2, 2, 2, 2, 2; x, y, z, p, p), (3.1)

where T0 = 1 and TNϪr =0ifr > N, whence T1 = 0. The and RD (x, y, z) is the case with p = z. Therefore we term with r = 1 is missing because Eqs. (3.3) and (3.4) consider imply E1 = 0, which greatly simplifies TN . Let |Z| = maxi |Zi |and␭ = max{|a|, 1}. The series RϪ (␤,...,␤; z ,...,z ) a 1 n [Eq. (3.7)] converges absolutely if ␤ >0and|Z|<1,and ϱ n the truncation error rK resulting from neglect of terms of 1 ͵ n␤ϪaϪ1͹ Ϫ␤ = ␤ Ϫ t (t + zi ) dt degree N Ն K can be shown to satisfy B(a, n a) 0 i=1

Ϫa K A RϪ ␤ ␤ z A z A (|a|)K |Z| = a ( ,..., ; 1/ ,..., n / ), (3.2) |r | Յ ␭ . (3.10) K K!(1 Ϫ |Z|) where B is the beta function and we have used the homogeneity of R to divide the variables by their arith- Each application of a duplication theorem decreases by metic average, a factor of four the differences between the variables, therefore the difference A Ϫ zi , and ultimately |Z|asA 1 ͸n approaches a limit. It is easy to determine whether an- A = zi . (3.3) n i=1 other duplication is needed before using the truncated series to achieve the desired accuracy. The relative difference between A and zi is If a = ␤ = 1/2 and n = 3, the series [Eq. (3.8)] with E = 0 can be rearranged as Ϫ 1 A zi Ϫ zi Zi = =1 , (3.4) ϱ ϱ A A r 1 r s Ϫ (Ϫ1) ( ) E E R (z , z , z )=A 1/2͸͸ 2 r+s 2 3 . (3.11) F 1 2 3 4r +6s +1r!s! whence r=0 s=0 This double series is convenient for obtaining numerical RϪa (␤,...,␤; z1,...,zn ) coefficients but requires |E2|+|E3| < 1 for absolute con- Ϫa vergence. Keeping together all terms of the same degree = A RϪa (␤,...,␤;1Ϫ Z1,...,1Ϫ Zn ). (3.5) in the Z’s, as in Eq. (3.8), we find Because the function is symmetric in the Z’s,itcan be expanded in elementary symmetric functions Ϫ1/2 1 1 1 2 RF (z1, z2, z3)=A (1 Ϫ E2 + E3 + E2 Em = Em (Z1,...,Zn ) defined by 10 14 24

n n 3 5 3 1 ͹ ͸ r Ϫ Ϫ 3 2 2 (1 + tZi )= t Er . (3.6) E2E3 E2 + E3 + E2 E3 + r8), (3.12) i=1 r=0 44 208 104 16

417 Volume 107, Number 5, September–October 2002 Journal of Research of the National Institute of Standards and Technology where 4. References

8 Ϫ 0.2|Z| ͯA ziͯ [1] B. C. Carlson, Toward symbolic integration of elliptic integrals, |r8|< ,|Z|=max <1, 1 Ϫ |Z| i A J. Symb. Comput. 28, 739-753 (1999). [2] I. S. Gradshteyn and I. M. Ryzhik, Table of Integrals, Series, and Products (Sixth Ed.), Academic Press, San Diego (2000). A =(z1 + z2 + z3)/3. (3.13) [3] M. Abramowitz and I. A. Stegun (eds.), Handbook of Mathe- matical Functions, U.S. Government Printing Office, Washing- One more duplication would (ultimately) have de- ton, D.C. (1964) Sec. 17.8 (Examples 16 and 18). Reprinted by 8 creased |r8| by a factor of 4 = 65 536. Dover, New York (1965). For convenient reference we restate the corresponding [4] R. Bulirsch, An extension of the Bartky-transformation to in- complete elliptic integrals of the third kind, Numer. Math. 13, result for RJ and RD [see Eq. (3.1) and the discussions 266-284 (1969) Sec. 1.2. preceding it]: [5] B. C. Carlson, Quadratic transformations of Appell functions, SIAM J. Math. Anal. 7, 291-304 (1976). 1 1 [6] B. C. Carlson, Special Functions of Applied Mathematics, Aca- RϪ3/2(2,..., 2; z1,...,z5) demic Press, New York (1977). Ϫ3/2 Ϫ 3 1 9 2 Ϫ 3 [7] D. G. Zill and B. C. Carlson, Symmetric elliptic integrals of the = A (1 14 E2 + 6 E3 + 88 E2 22 E4 third kind, Math. Comp. 24, 199-214 (1970). [8] B. C. Carlson, Numerical computation of real or complex ellip- 9 3 1 3 3 tic integrals, Numer. Algorithms 10, 13-26 (1995). Ϫ E E + E Ϫ E 3 + E 2 + E E 52 2 3 26 5 16 2 40 3 20 2 4 [9] B. C. Carlson and J. FitzSimons, Reduction theorems for elliptic integrands with the square root of two quadratic factors, J. Com- put. Appl. Math. 118, 71-85 (2000). 45 2 9 9 + E2 E3 Ϫ E3E4 Ϫ E2E5 + r8), (3.14) [10] B. C. Carlson, Computing elliptic integrals by duplication, Nu- 272 68 68 mer. Math. 33, 1-16 (1979). where About the author: B. C. Carlson was formerly a pro- fessor of physics and is currently a professor emeritus 8 Ϫ 3.4|Z| ͯA ziͯ of mathematics at Iowa State University and an associ- |r8|< 3/2 ,|Z|=max <1, (1 Ϫ |Z|) i A ate at the Ames Laboratory of the U.S. Department of Energy. A =(z1 +...+z5)/5. (3.15)

The duplication theorems for these two functions are more complicated than that for RF ; see Ref. [10] and Ref. [9], Appendix.

Acknowledgment

This manuscript was authored by a contractor of the U.S. Government (Ames Laboratory, Department of Energy), under contract No. W-7405-ENG-82. Accord- ingly, the U.S. Government retains a nonexclusive, roy- alty-free license to publish or reproduce the published form of this contribution, or allow others to do so for U.S. Government purposes. This work was supported also, in part, by the National Science Foundation under Agreement No. 9980036. Any opinions, findings, and conclusions or recommendations expressed in this pub- lication are those of the author and do not necessarily reflect the views of the National Science Foundation.

418