Perimeter of an Ellipse

02/01/2025

A commonly-shared math fact is that there is no closed-form expression for the perimeter (circumference) of an ellipse. In layman's terms, it can't be achieved using only basic operations: addition and subtraction, multiplication and division, exponentiation, trigonometric functions, etc. This post aims to serve as an introduction to the various methods of approximating the perimeter without requiring too much prerequisite knowledge. I also suggest my own simple method of approximation.

The creation of this post was inspired by Matt Parker's video on this topic.



Perimeter of a Circle

The perimeter (usually called the circumference in this case) of a circle is $2 \pi r$, where $r$ is the radius. This can be stated even more simply using the diameter $d$ as $\pi d$.



Approximations of the Perimeter of an Ellipse

Although there are methods to precisely define the perimeter of an ellipse, none of them are algebraic or closed-form. We will be going through a series of approximations in a somewhat natural order, starting with expressions that are simple to derive and understand but aren't particularly accurate and progressing towards expressions that are increasingly complex but offer more accuracy.

It is important to cover how these expressions are defined. Ellipses are in effect generalizations of circles; A circle can be defined as a special case of an ellipse, and all other ellipses can be imagined as circles that have been "stretched" in one direction. The amount of stretching relative to a circle is known as the eccentricity: The eccentricity is 0 for the case of a circle and increases to 1 as the ellipse stretches towards infinity. Understanding it requires introducing two aspects of ellipses: the semi-major axis ($a$) and the semi-minor axis ($b$), which can be defined as the longest distance and the shortest distance from the center of the ellipse to its edge respectively.


The typical formula for eccentricity (from 0 to 1) is $\sqrt {1 - ( \frac {b}{a} ) ^ 2}$. However, a more intuitive descriptor of stretch is available: The ratio between the axes, or $\frac {a}{b}$. This ratio will be 1 in the case of a circle, and stretch to infinity as the ellipse stretches. Most approximations of an ellipse's perimeter can be defined in terms of $a$ and $b$, and their deviation from the actual value (the error) varies as the eccentricity changes. This allows us to not just compare the general accuracy of each method, but also to graph the error values for a range of eccentricities.

Arithmetic Mean Method

$2 \pi \frac {a+b}{2}$

Simplicity: Extremely simple

This is a simple extension of the circle formula: It takes the arithmetic mean (AKA the average, or the midpoint) of the semi-major and semi-minor axes as a substitute for the radius. In the case of an ellipse with eccentricity 0 (a circle) a will be equal to b, so this formula acts the same as the circle formula and thus is exactly correct. However, the error increases as the eccentricity increases.

JS function:

function ellipseApproxArithmeticMean(a, b) {
  return 2 * Math.PI * (a + b) / 2;
}

Geometric Mean Method

$2 \pi \sqrt{ab}$

Simplicity: Extremely simple

This formula instead uses the geometric mean, a similar kind of average based on the product of multiple numbers instead of the sum. Matt Parker claims that Kepler used this method to approximate the perimeters of planetary orbits, although this method is significantly less accurate than the arithmetic mean method.

JS function:

function ellipseApproxGeometricMean(a, b) {
  return 2 * Math.PI * (a * b) ** 0.5;
}

Arithmetic-Geometric Mean Method

$2 \pi \sqrt{\frac{a^2+b^2}{2}}$

Simplicity: Very simple

This is an unusual combination somewhat similar to both the arithmetic mean and the geometric mean. It is slightly more accurate than the arithmetic mean.

JS function:

function ellipseApproxArithmeticGeometricMean(a, b) {
  return 2 * Math.PI * ((a ** 2 + b ** 2) / 2) ** 0.5;
}


Matt Parker's Simple Method

$\pi (\frac{6a}{5} + \frac{3b}{4})$

Simplicity: Extremely simple

A simple formula devised by Matt Parker for his video. 2.5% error at eccentricity 0 (effectively $1.95 \pi r$), intercepts 0 twice before diverging.

JS function:

function ellipseApproxMattParkerSimple(a, b) {
  return Math.PI * ((6 * a) / 5 + (3 * b) / 4);
}


Demonin's Method

$4a + (2 \pi - 4) \frac{b^2}{a}$

Simplicity: Very simple

My own method. Arises from the fact that $P = 2 \pi a$ at eccentricity 0 and $P = 4a$ at eccentricity 1, by interpolating between those two. Thus, this formula becomes more accurate as the eccentricity increases. Can be written in terms of the eccentricity $e$ as $a(2 \pi - (2 \pi - 4)e^2)$. A simpler (but overall slightly less accurate) formula is $4a + (2 \pi - 4) b$.

JS function:

function ellipseApproxDemonin(a, b) {
  return (4*a) + (2 * Math.PI - 4) * (b ** 2) / a;
}


Ramanujan's Method

$\pi (3(a+b) - \sqrt{(3a+b)(a+3b)})$

Simplicity: Somewhat simple

Ramanujan proposed two methods in 1914 for approximating the perimeter of an ellipse: This is the simpler formula. It is orders of magnitude more accurate than the previous methods.

JS function:

function ellipseApproxRamanujan1(a, b) {
  return Math.PI * (3 * (a + b) - ((3 * a + b) * (3 * b + a)) ** 0.5);
}


Matt Parker's Complex Method

$\pi (\frac{53a}{3} + \frac{717b}{35} - \sqrt{269 a^2 + 667 a b + 371 b^2})$

Simplicity: Somewhat complex

The second formula devised by Matt Parker for his video. Less accurate than Ramanujan's method for small eceentricities, but more accurate for $\frac {a}{b} \gt \sim 2.4$. Around 0.004% error at eccentricity 0, intercepts 0 four times before diverging.

JS function:

function ellipseApproxMattParkerComplex(a, b) {
  return Math.PI * ((a * 53) / 3 + (b * 717) / 35 - ((269 * a * a) + (667 * a * b) + (371 * b * b)) ** 0.5);
}


Ramanujan's Second Method

$\pi (a+b) (1 + \frac{3h}{10 + \sqrt{4-3h}})$

Where $h = \frac{(a-b)^2}{(a+b)^2}$.

Simplicity: Somewhat complex

This is the more complex of Ramanujan's two formulas. Significantly more accurate than the first, and as far as I am aware the most accurate method known. Can be written in terms of $a$ and $b$ as $\pi ((a+b) + \frac{3(a-b)^2}{10(a+b) + \sqrt{a^2 + 14ab + b^2}})$.

JS function:

function ellipseApproxRamanujan2(a, b) {
  let h = (a - b) ** 2 / (a + b) ** 2;
  return Math.PI * (a + b) * (1 + (3 * h) / (10 + (4 - 3 * h) ** 0.5));
}


Google's Method

$\pi (a + b) \left( 3 \frac{(a - b)^2}{(a + b)^2 \left( \sqrt{-3 \frac{(a - b)^2}{(a + b)^2} + 4} + 10 \right)} + 1 \right)$

Simplicity: Somewhat complex

This is the formula Google uses when you search "Perimeter of an ellipse". It is an unnecessarily complicated version of Ramanujan's second method.



Infinite series for calculating the Perimeter of an Ellipse

There are a variety of infinite series that converge towards the exact value, with some series being more useful than others in certain cases.

The perimeter of an ellipse can be defined precisely using the integral $4a \int_{0}^{\frac{\pi}{2}} \sqrt{1-e^2 sin^2 \theta} \,d \theta$, where $e$ is the eccentricity. This integral can be conveniently rewritten in terms of a hypergeometric function, upon which some infinite series can be built:

$\int_{0}^{\frac{\pi}{2}} \sqrt{1-e^2 sin^2 \theta} \,d \theta = \frac{\pi}{2} F(0.5, -0.5; 1; e^2)$

Maclaurin Series

$2 \pi a (1 - ( \frac{1}{2})^2 \frac{k^2}{1} - ( \frac{1 \cdot 3}{2 \cdot 4})^2 \frac{k^4}{3} - ( \frac{1 \cdot 3 \cdot 5}{2 \cdot 4 \cdot 6})^2 \frac{k^6}{5} - ...)$

Where $k = \sqrt{1 - \frac{b^2}{a^2}}$.

This is a simplified intuitive form of the hypergeometric function $2 a \pi F(-0.5, 0.5; 1; k^2)$. One of the first infinite series discovered for this case, although it converges relatively slowly.

JS function:

function ellipseSeriesMaclaurin(a, b, maxTerms = 100) {
  let k = (1 - b**2/a**2) ** 0.5;
  let seriesSum = 1; // The initial term is 1

  // Calculate the terms of the series
  for (let n = 1; n <= maxTerms; n++) {
    let numerator = 1;
    let denominator = 1;

    // Compute the product (1 * 3 * 5 * ... * (2n - 1)) for the numerator
    for (let i = 1; i <= n; i++) {
      numerator *= 2 * i - 1;
       }

    // Compute the product (2 * 4 * 6 * ... * 2n) for the denominator
    for (let i = 1; i <= n; i++) {
      denominator *= 2 * i;
    }

    // Add the nth term to the series sum
    seriesSum -= ((numerator / denominator) ** 2) * (k ** (n*2) / (2*n-1));
  }

  // Compute the final value
  return Math.PI * 2 * a * seriesSum;
}

Gauss-Kummer Series

$\pi (a+b) (1 + ( \frac{1}{2})^2 h^2 + ( \frac{1}{2 \cdot 4})^2 h^4 + ( \frac{1 \cdot 3}{2 \cdot 4 \cdot 6})^2 h^6 + ( \frac{1 \cdot 3 \cdot 5}{2 \cdot 4 \cdot 6 \cdot 8})^2 h^8 + ...)$

Where $h = \frac{a-b}{a+b}$. This is a simplified intuitive form of the hypergeometric function $\pi (a+b) F(-0.5, 0.5; 1; h^2)$ The most commonly-used function for determining the perimeter today, this series converges very fast especially for small eccentricities.

Alternate form:

$\pi (a+b) (1 + ( \frac{1}{2})^2 h + ( \frac{1}{2 \cdot 4})^2 h^2 + ( \frac{1 \cdot 3}{2 \cdot 4 \cdot 6})^2 h^3 + ( \frac{1 \cdot 3 \cdot 5}{2 \cdot 4 \cdot 6 \cdot 8})^2 h^4 + ...)$

Where $h = \frac{(a-b)^2}{(a+b)^2}$. This is the form that Matt Parker showed at the end of his video; It operates identically.

JS function:

function ellipseSeriesGaussKummer(a, b, maxTerms = 100) {
  let h = (a - b) / (a + b); // Can be done with (a - b) ** 2 / (a + b) ** 2 (as Matt Parker does), just replace the h ** (n*2) in the series with h ** n
  let seriesSum = 1; // The initial term is 1

  // Calculate the terms of the series
  for (let n = 1; n <= maxTerms; n++) {
    let numerator = 1;
    let denominator = 1;

    // Compute the product (1 * 3 * 5 * ... * (2n - 3)) for the numerator
    for (let i = 1; i <= n-1; i++) {
      numerator *= 2 * i - 1;
    }

    // Compute the product (2 * 4 * 6 * ... * 2n) for the denominator
    for (let i = 1; i <= n; i++) {
      denominator *= 2 * i;
    }

    // Add the nth term to the series sum
    seriesSum += ((numerator / denominator) ** 2) * (h ** (n*2));
  }

  // Compute the final value
  return Math.PI * (a + b) * seriesSum;
}

Cayley Series

$4a (1 + \frac{1}{2} (ln \frac{4}{k} - \frac{1}{1 \cdot 2}) k^2 + \frac{1^2 \cdot 3}{2^2 \cdot 4} (ln \frac{4}{k} - \frac{2}{1 \cdot 2} - \frac{1}{3 \cdot 4}) k^4 + \frac{1^2 \cdot 3^2 \cdot 5}{2^2 \cdot 4^2 \cdot 6} (ln \frac{4}{k} - \frac{2}{1 \cdot 2} - \frac{2}{3 \cdot 4} - \frac{1}{5 \cdot 6}) k^6 + ...)$

Where $k = \frac{b}{a}$. This series is not based on a hypergeometric function but was instead designed for large eccentricities by substituting $k = \frac{b}{a}$ into the main differential equation. This formula converges faster than the Gauss-Kummer Series for high eccentricities.

JS function:

function ellipseSeriesCayley(a, b, maxTerms = 50) {
  let k = b/a;
  let seriesSum = 1; // The initial term is 1

  // Calculate the terms of the series
  for (let n = 1; n <= maxTerms; n++) {
    let numerator = 1;
    let denominator = 1;
    let interiorSum = 0;

    //Calculate the products (1^2 * 3^2 * 5^2 * ... * (2n - 1)) and (2^2 * 4^2 * 6^2 * ... * 2n)
    for (let i = 1; i <= n-1; i++) {
      numerator *= (2 * i - 1) ** 2;
      denominator *= (2 * i) ** 2;
    }
    numerator *= (2 * n - 1);
    denominator *= 2 * n;

    //Calculate the product 0 - 2/(1*2) - 2/(3*4) - 2/(5*6) - ... - 1/((2n-1)*2n)
    for (let i = 1; i <= n-1; i++) {
      interiorSum -= 2/((2 * i - 1)*(2 * i));
    }
    interiorSum -= 1/((2 * n - 1)*(2 * n));

    // Add the nth term to the series sum
    seriesSum += (numerator / denominator) * (Math.log(4/k)+interiorSum) * (k**(n*2));
  }

  // Compute the final value
  return 4 * a * seriesSum;
}

The following graph shows the number of terms needed in each series to compute the perimeter correctly to within 0.0000001. It shows that the Gauss-Kummer series converges the fastest for low eccentricities (<~0.94), and the Cayley series converges the fastest for high eccentricities (>~0.94).



References:
M. Parker - "Why is there no equation for the perimeter of an ellipse‽" (https://www.youtube.com/watch?v=5nW3nJhBHL0)
S. Ramanujan - "Modular Equations and Approximations to $\pi$" (http://ramanujan.sirinudi.org/Volumes/published/ram06.pdf)
T. Chandrupatla, T. Osler - "The Perimeter of an Ellipse" (https://web.tecnico.ulisboa.pt/~mcasquilho/compute/com/,ellips/PerimeterOfEllipse.pdf)
P. Abbott - "On the Perimeter of an Ellipse" (https://content.wolfram.com/sites/19/2009/11/Abbott.pdf)
M. Villarino - "Ramanujan’s Perimeter of an Ellipse" (https://arxiv.org/pdf/math/0506384)

Back