A PHP Function to Numerically Evaluate the Complete Elliptic Integral
of the Second Kind Using an Infinite Power Series Summation
Based on Legendre Polynomials.

A High-Precision PHP Function Designed to Compute
The Circumference or Perimeter of an Ellipse
https://en.wikipedia.org/wiki/Elliptic_integral

PHP Program Function by Jay Tanner - 2025







The PHP Code

The demonstration program below demonstrates using the function to compute the equatorial and polar meridian circumferences of the Earth according to the WGS-84 Earth ellipsoid model used by the GPS system.  The parameters for any other ellipsoid model could also be used instead.

The function is an implementation of (Eq. 6), above.

Double-Click to select ALL code



Below is the PHP code for only the ellipse circumference function, without all the comments.

Double-Click to select ALL code








It might be noted that in this final reduced fractions series, the fractional denominators all equate to
even powers of 2, so the summation series could also be expressed in the somewhat abbreviated
form shown below: