Skip to content

How to calculate π

How would you calculate \pi? I remember being sent as a boy of ten into the schoolyard to find circular objects to measure. Our attempts to wrap a tape around a dustbin lid clearly did not represent the optimal method.

Perhaps you know a few digits of \pi. Starting from scratch, how would you find more? We know \pi is irrational, so it cannot be expressed as the ratio of two numbers. Worse, \pi is transcendental, so it is not the solution of any polynomial equation with integer coefficients.

There is a passage of the Bible (1 Kings 7:23) which refers to “a molten sea” which is “ten cubits from the one brim to the other” and “a line of thirty cubits did compass it about”. This figure of \pi=3 did not represent the state of the art, with more accurate values being recorded much earlier in Egypt and Mesopotamia.

A famous approximation is attributed to Archimedes (287-212 BC), who worked using only geometric methods. Archimedes took a circle and inscribed within it a polygon. The perimeter of the polygon, which is contained within the circle, is smaller than the circumference of the circle itself. Then he superscribed a polygon outside the circle. The perimeter of this second, larger polygon is larger than the circumference of the circle itself. If you think about increasing the number of sides on a polygon you will notice that the more sides a polygon has, the closer it gets to the shape of a circle. By increasing the number of sides on his two polygons and considering their perimeters, Archimedes could define two series, one increasing and one decreasing, both of which have \pi in their limit.

Archimedes took this as far as polygons of 96 sides and came up with an upper limit for \pi of \frac{22}{7} \approx 3.142857 and a lower limit of \frac{223}{71} \approx 3.140845. Because these coincide in the first three digits, we can conclude that \pi begins 3.14 \ldots

Others, following the method of Archimedes or developing it independently, extended to polygons with greater numbers of sides. This method culminated with Ludolph Van Ceulen who, around 1600, produced an approximation for \pi to 35 decimal places. Those 35 digits were inscribed on Van Ceulen’s tombstone.

More modern approximations involve calculating the terms of an infinite series involving \pi, which can be rearranged to find an approximation for \pi. For example, the following was discovered by James Gregory:


Using such a formula, one can generate \pi to as many decimal places as necessary by taking more terms. However, this series converges very slowly. For example, 10,000 terms are needed to get just four decimal places. John Machin found a series that converges much more quickly to \frac{pi}{4}:

\frac{\pi}{4}=4 \arctan{\frac{1}{5}}-\arctan{\frac{1}{239}}

which uses a more general James Gregory result:

\arctan{x}=x-\frac{x^3}{3}+\frac{x^5}{5}- \ldots (-1\leq x \leq 1)

Machin used this formula to calculate one hundred digits of \pi in 1706, the year William Jones introduced the modern use of the Greek letter π.

Computers enter the story in 1947 when D. F. Ferguson of the Royal Naval College in England calculated \pi to 710 digits with a desk calculator. In 1950 George W. Reitwiesner published more than 2000 digits of \pi in the journal Mathematics of Computation. These digits were calculated on the ENIAC computer at the suggestion of John von Neumann, who was interested to obtain a statistical measure of the randomness of the distribution of the digits (whether digits occur equally often in \pi remains an open question).  Reitwiesner and his team used the same formula as Machin and ran ENIAC for around 70 hours, including the time taken to handle the punch cards.

More recently, series are used which operate on similar principles but converge even more quickly. The latest computer record used the 1989 Chudnovsky algorithm, which is based on the series:

\frac{1}{\pi} = 12 \sum^\infty_{k=0} \frac{(-1)^k (6k)! (13591409 + 545140134k)}{(3k)!(k!)^3 640320^{3k + 3/2}}.!

In 2011 Shigeru Kondo set this record on a custom-built home computer using y-cruncher, a program written by Alexander Yee, to calculate \pi to ten trillion digits.


  1. Michael Kenyon wrote:

    pi=sin(180/infinity)x infinity

    Tuesday, July 17, 2012 at 11:21 am | Permalink
  2. “More modern approximations involve calculating the terms of an infinite series involving , which can be rearranged to find an approximation for . For example, the following was discovered by James Gregory…”

    Was “rediscovered” by James Gregory!

    See here!

    Sunday, July 22, 2012 at 10:41 am | Permalink
  3. Jimbob S. wrote:

    Machin’s formula should be:

    pi/4 = 4*arctan(1/5) – arctan(1/239)

    Wednesday, September 5, 2012 at 5:42 pm | Permalink
  4. @Jimbob S.: Thanks, well spotted. I don’t know how that happened; probably a copying error when I typed it up. I’ve edited the entry to have the correct formula.

    Thursday, September 20, 2012 at 8:09 am | Permalink
  5. YaphetS wrote:

    Is this correct? It shows the same result

    Tuesday, September 25, 2012 at 12:02 pm | Permalink
  6. @YaphetS: Yes, this is also a way to represent pi. The game is to find a trig series that converges very quickly, so you can get many decimal places without having to calculate lots and lots of terms.

    Tuesday, September 25, 2012 at 2:20 pm | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *