A PHP Function to Compute the Circumference or Perimeter of an Ellipse or Circle
by Evaluating the Complete Elliptic Integral of the Second Kind Using an Infinite
Power Series Summation Based on Legendre Polynomials.

PHP Function by Jay Tanner - 2022

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: