# Ramanujan Approximation for Circumference of an Ellipse

Join the DZone community and get the full member experience.

Join For Freethere’s no elementary formula for the circumference of an ellipse, but there is an elementary approximation that is extremely accurate.

an ellipse has equation (
*
x
*
/
*
a
*
)² + (
*
y
*
/
*
b
*
)² = 1. if
*
a
*
=
*
b
*
, the ellipse reduces to a circle and the circumference is simply 2π
*
a
*
. but the general formula for circumference requires the hypergeometric function
_{
2
}
*
f
*
_{
1
}
:

where λ = (
*
a
*
–
*
b
*
)/(
*
a
*
+
*
b
*
).

however, if the ellipse is anywhere near circular, the following approximation due to ramanujan is extremely good:

to quantify what we mean by extremely good, the error is o(λ
^{
10
}
). when an ellipse is roughly circular, λ is fairly small, and the error is on the order of λ to the 10th power.

to illustrate the accuracy of the approximation, i tried the formula out on some planets. the error increases with ellipticity, so i took the most most elliptical orbit of a planet or object formerly known as a planet. that distinction belongs to pluto, in which case λ = 0.016. if pluto’s orbit were exactly elliptical, you could use ramanujan’s approximation to find the circumference of its orbit with an error less than one micrometer.

next i tried it on something with a much more elliptical orbit: halley’s comet. its orbit is nearly four times longer than it is wide. for halley’s comet, λ = 0.59 and ramanujan’s approximation agrees with the exact result to seven significant figures. the exact result is 11,464,319,022 km and the approximation is 11,464,316,437 km.

here’s a video showing how elliptical the comet’s orbit is.

if you’d like to experiment with the approximation, here’s some python code:

from scipy import pi, sqrt from scipy.special import hyp2f1 def exact(a, b): t = ((a-b)/(a+b))**2 return pi*(a+b)*hyp2f1(-0.5, -0.5, 1, t) def approx(a, b): t = ((a-b)/(a+b))**2 return pi*(a+b)*(1 + 3*t/(10 + sqrt(4 - 3*t))) # semimajor and semiminor axes for halley's comet orbit a = 2.667950e9 # km b = 6.782819e8 # km print exact(a, b) print approx(a, b)

Published at DZone with permission of John Cook, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Comments