The circumference of an ellipse

The problem of finding an arc length of an ellipse is the origin of the name of the elliptic integrals. The equation of an ellipse with semi-major axis, $a$, and semi-minor axis, $b$, may be written in parametric form as \begin{align*} x &= a \sin\phi\\ y &= b \cos\phi \end{align*} The element of length along the ellipse's perimeter, \begin{align*} \mathrm{d}s &= \sqrt{\mathrm{d}x^2 + \mathrm{d}y^2} = \sqrt{a^2\cos^2\phi + b^2\sin^2\phi}\;\mathrm{d}\phi\\ & = a \sqrt{1 - e^2\sin^2\phi}\;\mathrm{d}\phi, \end{align*} where $e = \sqrt{1-b^2/a^2}$ is the eccentricity. The arc length may therefore be written in terms of incomplete elliptic integrals of the second kind: $$ \int \;\mathrm{d}s = a\int_{\phi_1}^{\phi_2} \sqrt{1 - e^2\sin^2\phi}\;\mathrm{d}\phi = a[E(e; \phi_2) - E(e; \phi_1)]. $$

Earth's orbit is an ellipse with semi-major axis 149,598,261 km and eccentricity 0.01671123. We will find the distance travelled by the Earth in one orbit, and compare it with that obtained assuming a circular orbit of radius $1\;\mathrm{AU} \equiv 149597870.7\;\mathrm{km}$.

The perimeter of an ellipse may be written using the above expression with $\phi_1 = 0, \phi_2 = 2\pi$: $$ P = a[E(e, 2\pi) - E(e, 0)] = 4aE(e), $$ since the entire perimeter is four times the quarter-perimeters which may be written in terms of the complete elliptic integral of the second kind. Noting that SciPy's ellipe function actually takes $m=e^2$ as its argument, we have:

In [x]: import numpy as np
In [x]: from scipy.special import ellipe
In [x]: a, e  = 149598261, 0.01671123   # semi-major axis (km), eccentricity
In [x]: pe = 4 * a * ellipe(e*e)
In [x]: print(pe)
939887967.974                   # "exact" answer
In [x]: AU = 149597870.7        # mean orbit radius, km
In [x]: pc = 2 * np.pi * AU
In [x]: print(pc)
939951143.1675915               # assuming circular orbit
In [x]: (pc - pe) / pe * 100

That is, the percentage error in the perimeter in treating the orbit as circular is about 0.0067%.