# Numerical evaluation of the first and second complete elliptic integrals

To get a numerical evaluation of the first (K) and second (E) complete elliptic integrals:

$$K(k)=\int_0^1\frac{dt}{(1-t^2)^{1/2}(1-k^2t^2)^{1/2}}, \ \ \ \ \ E(k)=\int_0^1\frac{(1-k^2t^2)^{1/2}}{(1-t^2)^{1/2}}dt$$

in a left neighbourhood of the point $k=1$. What numerical methods do you recommend to get a "good" approximation of K and E in a left neighbourhood of the point $k=1$?

## 2 Answers

A truncated power series about $k=1$ is one way. You can find several forms at functions.wolfram.com for $K(k)$ and $E(k)$. The number of terms used should allow you to estimate your error for a given neighborhood size.

Matlab's ellipke uses a simple arithmetic–geometric mean method (see Abramowitz & Stegun) to find values for any $k$.

The scipy package for Python has ellipkm1 "The complete elliptic integral of the first kind around m=1."

• Sadly this function is a very limited implementation, it works only for real arguments 0 <= m <= 1. So it is not really practical. – DerWeh Jul 26 '19 at 9:59