 Given The General Static Ellipsoid Parameters:
a = Equatorial radius of ellipsoid = Length of semimajor axis
b = Polar radius of ellipsoid = Length of semiminor axis
where, a > b
 Any units of length may be used for (a, b), such as feet, meters, kilometers, miles, etc., just as long as the same units are used for both.
 If (a = b), then the form is a perfect sphere, otherwise it is an ellipsoid or oblate spheroid to some degree, generally wider between two opposite equatorial points due to a slight equatorial bulge, than between the opposite polar points.
 From the given parameters, the polar flattening and eccentricity are computed by:
$f=\frac{a\text{}\text{}b}{a}$ = Polar flattening factor of ellipsoid due to equatorial bulge.
$\epsilon =\sqrt{1{\left(\frac{b}{a}\right)}^{2}}$ = Eccentricity = A measure of the ellipsoid deviation from a perfect sphere.
NOTE:
The Greek letter epsilon ( ε ) is being used here for the eccentricity so as to avoid confusion with the mathematical constant e = 2.7182818 ..., also called Euler's number and commonly associated with exponential and logarithmic operations.
 Horizontal Circumference Around the Equator
An ellipsoid has two basic circumferences  an equatorial circumference and a polar or meridian circumference. They equate to the same numerical value only in the special case of the ellipsoid equating to a perfect sphere, where ($\mathrm{a=b}$).
For Earth, the equatorial horizontal circumference is the length of the equator, the solid red line in the diagram, and computing it simply amounts to computing the classical circumference of a circle of radius ($R=a$).
The circle is actually an ellipse. One of an infinite set or family of ellipses, where $(0\le \u03f5\le 1)$. It just so happens that in the case of an ellipse where (a = b), we call it a circle instead, attributing to it a single radius where (radius = a), resulting in the simplest possible solution to the circumference C of an ellipse.
Length of the Circumference as Measured Around the Equator
$C=2\pi a$
 Vertical Circumference Around a Polar Meridian
A general equation for computing the length of a meridian or circumference as measured through the poles of an oblate sphereoid or ellipsoid can be expressed in the form of an infinite power series defined in terms of the given (a, b) parameters.
$$C=2\pi a(1\sum _{n=1}^{\mathrm{\infty}}{\left(\frac{(2n1)!!}{(2n)!!}\right)}^{2}\xb7\frac{{\left(\sqrt{1\frac{{b}^{2}}{{a}^{2}}}\right)}^{2n}}{2n1})$$
The vertical polar or meridian circumference, the solid gray elliptical surface outline in the diagram, also symbolized by the gray dotted line, is more complicated because due to the polar flattening, the circumference is elliptical, not circular, and is computed by evaluating the infinite series summation to the desired level of precision.
In any particular instance, the eccentricity can be treated as a constant value so, in the above equation, if we make the substitution
$$\epsilon =\sqrt{1{\left(\frac{b}{a}\right)}^{2}}$$
then the equation can be rewritten in the slightly simpler form given below.
Length of a Meridian or the Vertical Circumference as Measured Through the Poles
$$C=2\pi a(1\sum _{n=1}^{\mathrm{\infty}}{\left(\frac{(2n1)!!}{(2n)!!}\right)}^{2}\xb7\frac{{\epsilon}^{2n}}{2n1})$$
This equation is derived from the complete elliptic integral of the second kind, which is essentially a fancy name for the general solution we can apply to find the circumference (C) of an ellipse with given perpendicular Cartesian parameters (a, b). If the ellipse parameters are equal, then it equates to the special case of a perfect circle, where the inner summation equates to zero and
$C=2\pi a$ , when (ε = 0)
When (a $\ne $ b) and (0 $<$ ε $<$ 1), then we have an ellipse and this general solution applies, which the program solves by evaluating the simplified infinite power series summation given above in terms of the eccentricity (ε) to compute the circumference along a polar meridian.
 Physical Applications
This program can be applied to computing the lengths of meridians for ellipsoid models of the Earth or other planets like Jupiter or Saturn, or computing the lengths of nottooeccentric orbits, the original purpose of the program, the eccentricity is generally a relatively small value, so the infinite series evaluates quickly.
An extreme ratio, in this case, means like 4:1 or more, between (a, b) could possibly cause a script timeout.
For all practical purposes, 16 decimals should be sufficiently accurate, however the PHP function source code, listed below, could be modified to be extended out to even more decimals.
NOTES:
The general rule is: The higher the eccentricity, or the greater the difference between (a, b), the longer the time it will take to evaluate the power series.
This program does NOT perform intensive error checking, so absurd or extreme input values could result in timeouts or a program crash, such as a divisionbyzero or other fatal error. Valid input should return valid output within the given constraints. Otherwise, garbage in, garbage out, crash and burn.
 PLANETARY ELLIPSOID PARAMETERS (a, b)
Known (a, b) Parameters of Planets in Kilometers and Miles
Source: NASA
The equatorial and meridional circumferences were computed
from the given (a , b) parameters using the above program.
__________________________________________________________
Earth 
6378.1 , 6356.8 km  Equat C = 40074.8 km = 24901.3 mi
a b  Diff = 1326.0 km = 824.0 mi
3963.2 , 3949.9 mi  Merid C = 40007.9 km = 24859.8 mi
_________________________________________________________
The Moon 
1738.1 , 1736.0 km  Equat C = 6785.8 km = 4216.5 mi
a b  Diff = 6.6 km = 4.1 mi
1080.0 , 1078.7 mi  Merid C = 6781.8 km = 4214.0 mi
_________________________________________________________
Mars 
3396.2 , 3376.2 km  Equat C = 21339.0 km = 13259.4 mi
a b  Diff = 62.8 km = 39.0 mi
2110.3 , 2097.9 mi  Merid C = 21276.2 km = 13220.4 mi
_________________________________________________________
Jupiter 
71492 , 66854 km  Equat C = 449197 km = 279118 mi
a b  Diff = 14449 km = 8978 mi
44423 , 41541 mi  Merid C = 434749 km = 270140 mi
_________________________________________________________
Saturn 
60268 , 54364 km  Equat C = 378675 km = 235298 mi
a b  Diff = 18309 km = 11377 mi
37449 , 33780 mi  Merid C = 360366 km = 223921 mi
_________________________________________________________
Uranus 
25559 , 24973 km  Equat C = 160592 km = 99787 mi
a b  Diff = 1836 km = 1141 mi
15882 , 15518 mi  Merid C = 158756 km = 98647 mi
_________________________________________________________
Neptune 
24764 , 24341 km  Equat C = 155597 km = 96683 mi
a b  Diff = 1326 km = 824 mi
15388 , 15125 mi  Merid C = 154271 km = 95859 mi

