Algorithm used for world record pi calculations

The following algorithm is based on work of Ramanujan and has been used in several world-record calculations of pi.

Initialize a0 = 6 – 4 √2 and y0 = √2 – 1. Then compute

y_{n+1} = frac{1 - (1-y_n^4)^{1/4}}{1 + (1-y_n^4)^{1/4}}


a_{n+1} = (1 + y_{n+1})^4 a_n - 2^{2n+3} y_{n+1}(1 + y_{n+1} + y_{n+1}^2)

The terms an form a sequence of approximations to 1/π. The error in each approximation is given by

0 < a_n - frac{1}{pi} < 16cdot 4^n exp(-2cdot 4^n pi)

This says that the number of correct digits roughly quadruples after each step. To see this, note that the number of correct decimal places after the nth step is the negative of the logarithm base 10 of the error:

frac{2cdot 4^n pi - n ln 4 - ln 16}{ln 10}

[The error term goes to zero so quickly that you cannot (in ordinary precision) compute the error bound and then take logarithms; the exp(-2 π 4n) term will underflow to zero for n larger than 3. (See why here.) You have to take the log of the error term directly before evaluating numerically.]

The number of correct digits quadruples at each step because the leading term in the numerator above is 4n.

To give a few specifics, a1 is accurate to 9 digits, a2 is accurate to 41 digits, and a3 is accurate to 171 digits. After 10 steps, a10 is accurate to over 2.8 million digits.

The algorithm given here was state of the art as of 1989. It was used to set world records in 1986. I don’t know whether it has been used more recently. See more here.

According to this page, π has been calculated to 6.4 billion digits. You can beat this record if you can carry out 16 steps of the method described here. a16 would be accurate to over 11 billion digits.

Update (18 April 2012): The algorithm used most recently for world record calculations for pi has been the Chudnovsky algorithm. As of October 2011, the record was over 10 trillion digits.

Related posts:

A Ramanujan series for computing pi
There isn’t a googol of anything
How to compute log factorial

Tagged with:
Posted in Math
6 comments on “Algorithm used for world record pi calculations
  1. Speedmaster says:

    My head just imploded. :-)

  2. Chris Vest says:

    If I’m not mistaken, the number must be verified by at least two algorithms (in addition to being longer than any other) before it can be accepted as a world record.

  3. Scott says:

    Fantastic post for pi day (3/14)!

  4. Reader says:


  5. It is way more than 6.4 (American) billion digits. We are now on 10 trillions.

  6. Shamus says:

    I’m curious about the choice of initial conditions.

    a0 corresponds to an initial estimate of pi of 2.914… which is correct in 0 decimal places. I realize that the choice of y0 is linked to the choice of a0, but the details of how you might choose a better starting point. I guess, since a single iteration gets you to 9 correct digits, it doesn’t matter too much in practice.

5 Pings/Trackbacks for "Algorithm used for world record pi calculations"
  1. [...] Algorithm used for World Record Pi Calculations [...]

  2. [...] e.g., a compiler might spot programs that calculate pi and always generate code that uses the most rapidly converging method known. This is a very different approach to the traditional methods based on using (mostly) execution [...]

  3. [...] Algorithm for world record pi calculations Ramanujan series for pi [...]

  4. [...] is not the most efficient series for computing π. My next post will give a more efficient method, also based on work of Ramanujan. But the series above is [...]

  5. [...] some purposes, the digits of pi are random. The digits are obviously not random — there are algorithms for calculating them — and yet they behave randomly, and random is as random [...]