by R. Grothmann Euler contains functions to compute the elliptic integrals of first and second kind (elle, ellf). These functions use a representation and a method of Carlson (ellrf and ellre). We want to check the accuracy of the implementations. The speed is not optimal, since we use the Euler language, and no built-in procedures.
>function f(t,k) := 1/sqrt(1-k*sin(t)^2)
The elliptic integral of first kind is the integral of this funciton from 0 to phi. We first try the adpative Runge method with a small epsilon.
>longestformat; integrate("f",0,0.8;0.5,eps=1e-18)
0.842919855810007
The ellf function of Euler implements this using Carlson's method.
>ellf(0.8,0.5)
0.8429198558100065
Using high order interval algorithms, we get a guaranteed inclusion for the integral.
>mxmiint("1/sqrt(1-sin(x)^2/2)",0,0.8)
~0.84291985580998496,0.84291985581002793~
However, the best and fastest method is the integration method of Gauss, using only 10 evaluations of the function.
>gauss("1/sqrt(1-sin(x)^2/2)",0,0.8)
0.8429198558100067
Maxima contains a numerical method for elliptic functions of the first kind, which uses the same definition.
>&elliptic_f(0.8,0.5)
0.84291985581001
The complete elliptic integral of the first kind is defined in the following way.
>function ellF(k) := ellf(pi/2,k^2)
There are some well known special values, which we can check.
>ellF(0), pi/2
1.570796326794897 1.570796326794897
>ellF(1/sqrt(2)), gamma(1/4)^2/(4*sqrt(pi))
1.854074677301372 1.854074677301372
>ellF((sqrt(6)-sqrt(2))/4), 2^(-7/3)*3^(1/4)*gamma(1/3)^3/pi
1.59814200211254 1.598142002112539
>ellF((sqrt(6)+sqrt(2))/4), 2^(-7/3)*3^(3/4)*gamma(1/3)^3/pi
2.768063145368767 2.768063145368766
The complete elliptic integral of the second kind is defined in the following way.
>function ellE(k) := elle(pi/2,k^2)
Again, we can test special values.
>ellE(0), pi/2
1.570796326794897 1.570796326794897
>ellE(1/sqrt(2)), pi^(3/2)/gamma(1/4)^2+gamma(1/4)^2/(8*sqrt(pi))
1.350643881047676 1.350643881047676