There’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 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)

Neat. I think you discussed easy approximations to the Gaussian form once upon a time, too.

How do I read the 2F1 invocation? Is there something wrong with the LaTeX or is it a problem with my browser, or do I just not understand the notation?

Daniel: Hypergeometric functions have an intimidating notation, but there are reasons for it.

2F1 was originally “the” hypergeometric function, but this was generalized so the “2” and “1” became necessary to distinguish it from the newcomers.

The numbers on top, both -1/2 in our case, are related to quantities that appear in the numerator of a fraction, and the numbers on bottom, just 1 in our case, are related to numbers in a denominator. So the notation is mnemonic.

Often the notation is flattened out for convenience: F(a, b; c; z). The numbers before the first semicolon are upper parameters. The numbers between the two semicolons are lower parameters. And the final number is the argument where the function is evaluated. The z here corresponds to lambda^2 above.

I just finished a joint biography of Tycho Brahe and Johannes Kepler* that (among many other interesting things) pointed out that you couldn’t really blame anyone for not realizing that planetary orbits are not circular.

Specifically, the eccentricity of the orbits of the 6 classical planets is sufficiently low that you would need positional observations with errors less than about five arcminutes to see that ellipses give better fits than circles. The best pre-Tycho observations had average errors of about 10 arcminutes, and there were other less-accurate data also in use. Tycho got that down to around 3 arcminutes, which was just enough for Kepler to do his thing.

I had no idea that the planets’ orbits were so nearly circular — or, perhaps, that the observational differences between circular orbits and elliptical orbits are so small.

*

Tycho and Kepler, by Kitty Fergusonhttp://cs.brown.edu/~sk/Personal/Books/Ferguson-Tycho-Kepler/

If you vary a from 0 to 1, set b=2-a, and plot the circumferences as a function of lambda^2, you will see it looks very close to a line. So I’m not so impressed as I was at first with the approximation.

I’ve seen Hypergeometric functions come up several times recently in work that I’ve done. It seems that they are some kind of big daddy special function that generalizes a large number of other special functions. I wonder if you’d be willing to do a post on where they come from, how they’re useful to applied math, and maybe why the ellipse circumference formula contains them? Most of the references I’ve seen start with some definition in terms of solutions of an ODE, but it would be nice to get a little more context, ie. why is that ODE something we should care about, what problems does this whole field arise out of etc.

I had to calculate the circumference of an ellipse recently, I used a less good approximation, but for my application it was fine since the measurements had a fair amount of measurement error in them, and the eventual result was part of a statistical model with a lot of measurement error as well, the approximation error was dominated by random errors. If i’d known about the formula you mentioned I might have built some taylor series or something, since i had a fairly restricted range of lambda values.

Daniel: Here’s a chart of special function relationships. That doesn’t directly address your comment, but it’s related.

See this post on mechanical vibrations. The same equations describe many other oscillating systems. And if you consider non-constant coefficients, you run into hypergeometric functions.

ODEs were the motivation for hypergeometric functions in the 19th century. Today people may be more likely to run into them because of their use in combinatorics. See, for example, the book Concrete Mathematics.

Sure, I can see why 2nd order ODEs are interesting, they define most of Newtonian mechanics. On the other hand, it wasn’t obvious to me that the issue of interest for Hypergeometric functions was the non-constancy of the coefficients. Now that you’ve mentioned that it makes a little more sense. I still don’t see why specifically the Hypergeometric series would be the series of interest, but I imagine that is not exactly obvious.

I still feel like there’s some kind of “big picture” with regards to special functions that is missing for me. Perhaps I need to go look at my copy of Abramowitz and Stegun for a while.

I’m particularly interested in the arclength of the ellipse issue, since that actually came up in my applied work recently. I imagine if I write down the arclength formula in terms of an integral, and then differentiate it a bit I probably wind up with something that looks like a non-constant coefficient ODE? Or is it that there’s a more subtle and bigger connection between all of these things?

Daniel: When you differentiate power series, you get falling powers. For example, 2nd derivative of x^n is n(n-1)x^(n-2). And falling powers are central to the definition of hypergeometric functions. I think that’s the heart of the connection between ODEs and hypergeometric functions.

The way the wikipedia article describes them is in terms of *rising* powers, which now that you mention it I assume is some kind of shortcut for the ratio of two falling powers. Often the way things are defined in terms of a final result obscures the reasoning that got you to that result. the falling powers concept is powerful motivation, but the definition in terms of rising powers makes that obscure.

Daniel: These notes give a link between rising and falling powers on page 1.

and when I say “rising powers” i meant rising products, ie. the pochhammer symbol (q)_n = q*(q+1)*(q+2)*…(q+n-1) which is (q+n-1)!/(q-1)! but I would probably find that notation more informative than the more compact pochhammer notation.

Hey did you just write that up in response to my request, or was that something you already had lying around? Thanks!

I’ve been numerically integrating the complete elliptic function of the 2nd kind to get circumferences of ellipses.

C = 4a ∫(0,π/2) √(1−e²sin²x) dx

This approximation looks good enough to use most of the time though.

Hi,

I have greatly enjoyed reading about your description of the accuracy in Ramanujan’s formula for the ellipse circumference.

Just as you have computed the values for the Halley’s comet, have you compiled the numbers for the circumference of different planets in the solar system using Ramanujan’s approximation and the exact formula ? I would be curios to see the comparative values for Mercury, Earth, Jupiter and Pluto.

I have had the problem of determining the perimeter of an Ellipse and did a derivation myself. By using the arc length formula and numerically integrating the following simple python code yields high accuracy for a large spectrum of elliptical perimeters. With A and B differs greatly eg. A=9 and B=3, Where the function h defines the arc length.

from scipy import integrate

def elipticperimeter(A,B):

# define h(x)

h = lambda x: (1+(((B**2)*(x**2))/((A**2)*(A**2-x**2))))**0.5

L = integrate.quad(h,0,A)

return 4*L[0]

For larger values almost circular like the example code you posted the values do converge.

Kind Regards

Philip