Approximations of π


for the mathematical constant pi in the history of mathematics reached an accuracy within 0.04% of the true value before the beginning of the Common Era. In Chinese mathematics, this was improved to approximations correct to what corresponds to about seven decimal digits by the 5th century.
Further progress was not made until the 15th century. Early modern mathematicians reached an accuracy of 35 digits by the beginning of the 17th century, and 126 digits by the 19th century, surpassing the accuracy required for any conceivable application outside of pure mathematics.
The record of manual approximation of is held by William Shanks, who calculated 527 digits correctly in the years preceding 1873. Since the middle of the 20th century, the approximation of has been the task of electronic digital computers. In March 2019 Emma Haruka Iwao, a Google employee from Japan, calculated to a new world record length of 31trillion digits with the help of the company's cloud computing service.

Early history

The best known approximations to dating to before the Common Era were accurate to two decimal places; this was improved upon in Chinese mathematics in particular by the mid-first millennium, to an accuracy of seven decimal places. After this, no further progress was made until the late medieval period.
Some Egyptologists
have claimed that the ancient Egyptians used an approximation of as = 3.142857 from as early as the Old Kingdom.
This claim has met with skepticism.
Babylonian mathematics usually approximated to 3, sufficient for the architectural projects of the time. The Babylonians were aware that this was an approximation, and one Old Babylonian mathematical tablet excavated near Susa in 1936 gives a better approximation of as = 3.125, about 0.528 percent below the exact value.
At about the same time, the Egyptian Rhind Mathematical Papyrus implies an approximation of as ≈ 3.16 by calculating the area of a circle by approximating the circle by an octagon.
Astronomical calculations in the Shatapatha Brahmana use a fractional approximation of.
In the 3rd century BCE, Archimedes proved the sharp inequalities < < , by means of regular 96-gons.
In the 2nd century CE, Ptolemy used the value, the first known approximation accurate to three decimal places.
The Chinese mathematician Liu Hui in 263 CE computed to between and by inscribing a 96-gon and 192-gon; the average of these two values is .
He also suggested that 3.14 was a good enough approximation for practical purposes. He has also frequently been credited with a later and more accurate result, π ≈ = 3.1416, although some scholars instead believe that this is due to the later Chinese mathematician Zu Chongzhi.
Zu Chongzhi is known to have computed between 3.1415926 and 3.1415927, which was correct to seven decimal places. He gave two other approximations of : π ≈ and π ≈. The latter fraction is the best possible rational approximation of using fewer than five decimal digits in the numerator and denominator. Zu Chongzhi's result surpasses the accuracy reached in Hellenistic mathematics, and would remain without improvement for close to a millennium.
In Gupta-era India, mathematician Aryabhata in his astronomical treatise Āryabhaṭīya calculated the value of to five significant figures π ≈ = 3.1416. using it to calculate an approximation of the Earth's circumference. Aryabhata stated that his result "approximately" gave the circumference of a circle. His 15th-century commentator Nilakantha Somayaji has argued that the word means not only that this is an approximation, but that the value is incommensurable.

Middle Ages

By the 5th century CE, was known to about seven digits in Chinese mathematics, and to about five in Indian mathematics. Further progress was not made for nearly a millennium, until the 14th century, when Indian mathematician and astronomer Madhava of Sangamagrama, founder of the Kerala school of astronomy and mathematics, discovered the infinite series for, now known as the Madhava–Leibniz series, and gave two methods for computing the value of. One of these methods is to obtain a rapidly converging series by transforming the original infinite series of. By doing so, he obtained the infinite series
and used the first 21 terms to compute an approximation of correct to 11 decimal places as.
The other method he used was to add a remainder term to the original series of. He used the remainder term
in the infinite series expansion of to improve the approximation of to 13 decimal places of accuracy when = 75.
Jamshīd al-Kāshī, a Persian astronomer and mathematician, correctly computed 2 to 9 sexagesimal digits in 1424. This figure is equivalent to 17 decimal digits as
which equates to
He achieved this level of accuracy by calculating the perimeter of a regular polygon with 3 × 228 sides.

16th to 19th centuries

In the second half of the 16th century, the French mathematician François Viète discovered an infinite product that converged on known as Viète's formula.
The German-Dutch mathematician Ludolph van Ceulen computed the first 35 decimal places of with a 262-gon. He was so proud of this accomplishment that he had them inscribed on his tombstone.
In Cyclometricus, Willebrord Snellius demonstrated that the perimeter of the inscribed polygon converges on the circumference twice as fast as does the perimeter of the corresponding circumscribed polygon. This was proved by Christiaan Huygens in 1654. Snellius was able to obtain seven digits of from a 96-sided polygon.
In 1789, the Slovene mathematician Jurij Vega calculated the first 140 decimal places for, of which the first 126 were correct and held the world record for 52 years until 1841, when William Rutherford calculated 208 decimal places, of which the first 152 were correct. Vega improved John Machin's formula from 1706 and his method is still mentioned today.
The magnitude of such precision can be put into context by the fact that the circumference of the largest known object, the observable universe, can be calculated from its diameter to a precision of less than one Planck length using expressed to just 62 decimal places.
The English amateur mathematician William Shanks, a man of independent means, spent over 20 years calculating to 707 decimal places. This was accomplished in 1873, with the first 527 places correct. He would calculate new digits all morning and would then spend all afternoon checking his morning's work. This was the longest expansion of until the advent of the electronic digital computer three-quarters of a century later.

20th and 21st centuries

In 1910, the Indian mathematician Srinivasa Ramanujan found several rapidly converging infinite series of, including
which computes a further eight decimal places of with each term in the series. His series are now the basis for the fastest algorithms currently used to calculate. See also Ramanujan–Sato series.
From the mid-20th century onwards, all calculations of have been done with the help of calculators or computers.
In 1944, D. F. Ferguson, with the aid of a mechanical desk calculator, found that William Shanks had made a mistake in the 528th decimal place, and that all succeeding digits were incorrect.
In the early years of the computer, an expansion of to decimal places was computed by Maryland mathematician Daniel Shanks and his team at the United States Naval Research Laboratory in Washington, D.C. In 1961, Shanks and his team used two different power series for calculating the digits of. For one, it was known that any error would produce a value slightly high, and for the other, it was known that any error would produce a value slightly low. And hence, as long as the two series produced the same digits, there was a very high confidence that they were correct. The first 100,265 digits of were published in 1962. The authors outlined what would be needed to calculate to 1 million decimal places and concluded that the task was beyond that day's technology, but would be possible in five to seven years.
In 1989, the Chudnovsky brothers computed to over 1 billion decimal places on the supercomputer IBM 3090 using the following variation of Ramanujan's infinite series of :
Records since then have all been accomplished using the Chudnovsky algorithm.
In 1999, Yasumasa Kanada and his team at the University of Tokyo computed to over 200 billion decimal places on the supercomputer HITACHI SR8000/MPP using another variation of Ramanujan's infinite series of.
In November 2002, Yasumasa Kanada and a team of 9 others used the Hitachi SR8000, a 64-node supercomputer with 1 terabyte of main memory, to calculate to roughly 1.24 trillion digits in around 600 hours. In October 2005, they claimed to have calculated it to 1.24 trillion places.
In 2009, Fabrice Bellard computed just under 2.7 trillion digits, and from 2010 onward, all records have been set using Alexander Yee's y-cruncher software.
In August 2009, a Japanese supercomputer called the T2K Open Supercomputer more than doubled the previous record by calculating to roughly 2.6 trillion digits in approximately 73 hours and 36 minutes.
In December 2009, Fabrice Bellard used a home computer to compute 2.7 trillion decimal digits of. Calculations were performed in base 2, then the result was converted to base 10. The calculation, conversion, and verification steps took a total of 131 days.
In August 2010, Shigeru Kondo used Alexander Yee's y-cruncher to calculate 5 trillion digits of. This was the world record for any type of calculation, but significantly it was performed on a home computer built by Kondo. The calculation was done between 4 May and 3 August, with the primary and secondary verifications taking 64 and 66 hours respectively.
In October 2011, Shigeru Kondo broke his own record by computing ten trillion and fifty digits using the same method but with better hardware.
In December 2013, Kondo broke his own record for a second time when he computed 12.1 trillion digits of.
In October 2014, Sandon Van Ness, going by the pseudonym "houkouonchi" used y-cruncher to calculate 13.3 trillion digits of.
In November 2016, Peter Trueb and his sponsors computed on y-cruncher and fully verified 22.4 trillion digits of. The computation took 105 days to complete.
, the record stands at 22,459,157,718,361 digits. The limitation on further expansion is primarily storage space for the computation.
In March 2019, Emma Haruka Iwao, an employee at Google, computed 31.4 trillion digits of pi using y-cruncher and Google Cloud machines. This took 121 days to complete.
In January 2020, Timothy Mullican announced the computation of 50 trillion digits over 303 days.

Practical approximations

Depending on the purpose of a calculation, can be approximated by using fractions for ease of calculation. The most notable such approximations are and .

Non-mathematical "definitions" of

Of some notability are legal or historical texts purportedly "defining " to have some rational value, such as the "Indiana Pi Bill" of 1897, which stated "the ratio of the diameter and circumference is as five-fourths to four" and a passage in the Hebrew Bible that implies that.

Indiana bill

The so-called "Indiana Pi Bill" of 1897 has often been characterized as an attempt to "legislate the value of Pi". Rather, the bill dealt with a purported solution to the problem of geometrically "squaring the circle".
The bill was nearly passed by the Indiana General Assembly in the U.S., and has been claimed to imply a number of different values for, although the closest it comes to explicitly asserting one is the wording "the ratio of the diameter and circumference is as five-fourths to four", which would make, a discrepancy of nearly 2 percent. A mathematics professor who happened to be present the day the bill was brought up for consideration in the Senate, after it had passed in the House, helped to stop the passage of the bill on its second reading, after which the assembly thoroughly ridiculed it before tabling it indefinitely.

Imputed biblical value

It is sometimes claimed that the Hebrew Bible implies that " equals three", based on a passage in and giving measurements for the round basin located in front of the Temple in Jerusalem as having a diameter of 10 cubits and a circumference of 30 cubits.
The issue is discussed in the Talmud and in Rabbinic literature. Among the many explanations and comments are these:
There is still some debate on this passage in biblical scholarship. Many reconstructions of the basin show a wider brim extending outward from the bowl itself by several inches to match the description given in In the succeeding verses, the rim is described as "a handbreadth thick; and the brim thereof was wrought like the brim of a cup, like the flower of a lily: it received and held three thousand baths", which suggests a shape that can be encompassed with a string shorter than the total length of the brim, e.g., a Lilium flower or a Teacup.

Development of efficient formulae

Polygon approximation to a circle

Archimedes, in his Measurement of a Circle, created the first algorithm for the calculation of based on the idea that the perimeter of any polygon inscribed in a circle is less than the circumference of the circle, which, in turn, is less than the perimeter of any circumscribed polygon. He started with inscribed and circumscribed regular hexagons, whose perimeters are readily determined. He then shows how to calculate the perimeters of regular polygons of twice as many sides that are inscribed and circumscribed about the same circle. This is a recursive procedure which would be described today as follows: Let and denote the perimeters of regular polygons of sides that are inscribed and circumscribed about the same circle, respectively. Then,
Archimedes uses this to successively compute and. Using these last values he obtains
It is not known why Archimedes stopped at a 96-sided polygon; it only takes patience to extend the computations. Heron reports in his Metrica that Archimedes continued the computation in a now lost book, but then attributes an incorrect value to him.
Archimedes uses no trigonometry in this computation and the difficulty in applying the method lies in obtaining good approximations for the square roots that are involved. Trigonometry, in the form of a table of chord lengths in a circle, was probably used by Claudius Ptolemy of Alexandria to obtain the value of given in the Almagest.
Advances in the approximation of were made by increasing the number of sides of the polygons used in the computation. A trigonometric improvement by Willebrord Snell obtains better bounds from a pair of bounds gotten from the polygon method. Thus, more accurate results were obtained from polygons with fewer sides. Viète's formula, published by François Viète in 1593, was derived by Viète using a closely related polygonal method, but with areas rather than perimeters of polygons whose numbers of sides are powers of two.
The last major attempt to compute by this method was carried out by Grienberger in 1630 who calculated 39 decimal places of using Snell's refinement.

Machin-like formula

For fast calculations, one may use formulae such as Machin's:
together with the Taylor series expansion of the function arctan. This formula is most easily verified using polar coordinates of complex numbers, producing:
Formulae of this kind are known as Machin-like formulae. Machin's particular formula was used well into the computer era for calculating record numbers of digits of, but more recently other similar formulae have been used as well.
For instance, Shanks and his team used the following Machin-like formula in 1961 to compute the first 100,000 digits of :
and they used another Machin-like formula,
as a check.
The record as of December 2002 by Yasumasa Kanada of Tokyo University stood at 1,241,100,000,000 digits. The following Machin-like formulae were used for this:
K. Takano.
F. C. M. Størmer.

Other classical formulae

Other formulae that have been used to compute estimates of include:
Liu Hui :
Madhava:
Euler:
Newton / Euler Convergence Transformation:
where !! denotes the product of the odd integers up to 2k + 1.
Ramanujan:
David Chudnovsky and Gregory Chudnovsky:
Ramanujan's work is the basis for the Chudnovsky algorithm, the fastest algorithms used, as of the turn of the millennium, to calculate.

Modern algorithms

Extremely long decimal expansions of are typically computed with iterative formulae like the Gauss–Legendre algorithm and Borwein's algorithm. The latter, found in 1985 by Jonathan and Peter Borwein, converges extremely quickly:
For and
where, the sequence converges quartically to, giving about 100 digits in three steps and over a trillion digits after 20 steps. However, it is known that using an algorithm such as the Chudnovsky algorithm is faster than these iterative formulae.
The first one million digits of and are available from Project Gutenberg. A former calculation record by Yasumasa Kanada of Tokyo University stood at 1.24 trillion digits, which were computed in September 2002 on a 64-node Hitachi supercomputer with 1 terabyte of main memory, which carries out 2 trillion operations per second, nearly twice as many as the computer used for the previous record. The following Machin-like formulæ were used for this:
These approximations have so many digits that they are no longer of any practical use, except for testing new supercomputers. Properties like the potential normality of pi| will always depend on the infinite string of digits on the end, not on any finite computation.

Miscellaneous approximations

Historically, base 60 was used for calculations. In this base, can be approximated to eight significant figures with the number 3:8:29:44, which is
In addition, the following expressions can be used to estimate :
  • accurate to three digits:
  • accurate to three digits:
  • accurate to four digits:
  • accurate to four digits :
  • an approximation by Ramanujan, accurate to 4 digits :
  • accurate to five digits:
  • accurate to six digits :
  • accurate to seven digits:
  • accurate to nine digits:
  • accurate to ten digits:
  • accurate to ten digits :
  • accurate to 18 digits:
  • accurate to 30 decimal places:
  • accurate to 52 decimal places:
  • accurate to 161 decimal places:
  • The continued fraction representation of can be used to generate successive best rational approximations. These approximations are the best possible rational approximations of relative to the size of their denominators. Here is a list of the first thirteen of these:

    Summing a circle's area

Pi can be obtained from a circle if its radius and area are known using the relationship:
If a circle with radius ' is drawn with its center at the point, any point whose distance from the origin is less than ' will fall inside the circle. The Pythagorean theorem gives the distance from any point to the center:
Mathematical "graph paper" is formed by imagining a 1×1 square centered around each cell, where and are integers between − and. Squares whose center resides inside or exactly on the border of the circle can then be counted by testing whether, for each cell,
The total number of cells satisfying that condition thus approximates the area of the circle, which then can be used to calculate an approximation of. Closer approximations can be produced by using larger values of.
Mathematically, this formula can be written:
In other words, begin by choosing a value for. Consider all cells in which both and are integers between − and. Starting at 0, add 1 for each cell whose distance to the origin is less than or equal to . When finished, divide the sum, representing the area of a circle of radius, by 2 to find the approximation of.
For example, if is 5, then the cells considered are:
graph. The cells and are labeled.
The 12 cells,,, are exactly on the circle, and 69 cells are completely inside, so the approximate area is 81, and is calculated to be approximately 3.24 because = 3.24. Results for some values of are shown in the table below:

rareaapproximation of
2133.25
3293.22222
4493.0625
5813.24
103173.17
2012573.1425
100314173.1417
100031415493.141549


For related results see .
Similarly, the more complex approximations of given below involve repeated calculations of some sort, yielding closer and closer approximations with increasing numbers of calculations.

Continued fractions

Besides its simple continued fraction representation , which displays no discernible pattern, has many generalized continued fraction representations generated by a simple rule, including these two.

Trigonometry

Gregory–Leibniz series

The Gregory–Leibniz series
is the power series for arctan specialized to = 1. It converges too slowly to be of practical interest. However, the power series converges much faster for smaller values of, which leads to formulae where arises as the sum of small angles with rational tangents, known as Machin-like formulae.

Arctangent

Knowing that 4 arctan 1 =, the formula can be simplified to get:
with a convergence such that each additional 10 terms yields at least three more digits.
Another formula for involving arctangent function is given by
where such that. Approximations can be made by using, for example, the rapidly convergent Euler formula
Alternatively, the following simple expansion series of the arctangent function can be used
where
to approximate with even more rapid convergence. Convergence in this arctangent formula for improves as integer increases.
The constant can also be expressed by infinite sum of arctangent functions as
and
where is the n-th Fibonacci number. However, these two formulae for are much slower in convergence because of set of arctangent functions that are involved in computation.

Arcsine

Observing an equilateral triangle and noting that
yields
with a convergence such that each additional five terms yields at least three more digits.

The Salamin–Brent algorithm

The Gauss–Legendre algorithm or Salamin–Brent algorithm was discovered independently by Richard Brent and Eugene Salamin in 1975. This can compute to digits in time proportional to, much faster than the trigonometric formulae.

Digit extraction methods

The Bailey–Borwein–Plouffe formula for calculating was discovered in 1995 by Simon Plouffe. Using Hexadecimal| math, the formula can compute any particular digit of —returning the hexadecimal value of the digit—without having to compute the intervening digits.
In 1996, Simon Plouffe derived an algorithm to extract the th decimal digit of , and which can do so with an improved speed of time. The algorithm requires virtually no memory for the storage of an array or matrix so the one-millionth digit of can be computed using a pocket calculator. However, it would be quite tedious and impractical to do so.
The calculation speed of Plouffe's formula was improved to by Fabrice Bellard, who derived an alternative formula for computing.

Efficient methods

Many other expressions for were developed and published by Indian mathematician Srinivasa Ramanujan. He worked with mathematician Godfrey Harold Hardy in England for a number of years.
Extremely long decimal expansions of are typically computed with the Gauss–Legendre algorithm and Borwein's algorithm; the Salamin–Brent algorithm, which was invented in 1976, has also been used.
In 1997, David H. Bailey, Peter Borwein and Simon Plouffe published a paper on a new formula for as an infinite series:
This formula permits one to fairly readily compute the kth binary or hexadecimal digit of, without having to compute the preceding k − 1 digits. Bailey's website contains the derivation as well as implementations in various programming languages. The PiHex project computed 64 bits around the quadrillionth bit of .
Fabrice Bellard further improved on BBP with his formula:
Other formulae that have been used to compute estimates of include:
This converges extraordinarily rapidly. Ramanujan's work is the basis for the fastest algorithms used, as of the turn of the millennium, to calculate.
In 1988, David Chudnovsky and Gregory Chudnovsky found an even faster-converging series :
The speed of various algorithms for computing pi to n correct digits is shown below in descending order of asymptotic complexity. M is the complexity of the multiplication algorithm employed.
AlgorithmYearTime complexity or Speed
Chudnovsky algorithm1988
Gauss–Legendre algorithm1975
Binary splitting of the arctan series in Machin's formula
Leibniz formula for π1300sSublinear convergence. Five billion terms for 10 correct decimal places

Projects

Pi Hex

was a project to compute three specific binary digits of using a distributed network of several hundred computers. In 2000, after two years, the project finished computing the five trillionth, the forty trillionth, and the quadrillionth bits. All three of them turned out to be 0.

Software for calculating

Over the years, several programs have been written for calculating to many digits on personal computers.

General purpose

Most computer algebra systems can calculate and other common mathematical constants to any desired precision.
Functions for calculating are also included in many general libraries for arbitrary-precision arithmetic, for instance Class Library for Numbers, MPFR and SymPy.

Special purpose

Programs designed for calculating may have better performance than general-purpose mathematical software. They typically implement checkpointing and efficient disk swapping to facilitate extremely long-running and memory-expensive computations.
  • TachusPi by Fabrice Bellard is the program used by himself to compute world record number of digits of pi in 2009.
  • -cruncher by Alexander Yee is the program which every world record holder since Shigeru Kondo in 2010 have used to compute [|world record numbers of digits]. -cruncher can also be used to calculate other constants and holds world records for several of them.
  • PiFast by Xavier Gourdon was the fastest program for Microsoft Windows in 2003. According to its author, it can compute one million digits in 3.5 seconds on a 2.4 GHz Pentium 4. PiFast can also compute other irrational numbers like e | and square root of 2|. It can also work at lesser efficiency with very little memory. This tool is a popular benchmark in the overclocking community. PiFast 4.4 is available from . PiFast 4.3 is available from Gourdon's page.
  • QuickPi by Steve Pagliarulo for Windows is faster than PiFast for runs of under 400 million digits. Version 4.5 is available on Stu's Pi Page below. Like PiFast, QuickPi can also compute other irrational numbers like,, and square root of 3|. The software may be obtained from the Pi-Hacks Yahoo! forum, or from .
  • Super PI by Kanada Laboratory in the University of Tokyo is the program for Microsoft Windows for runs from 16,000 to 33,550,000 digits. It can compute one million digits in 40 minutes, two million digits in 90 minutes and four million digits in 220 minutes on a Pentium 90 MHz. Super PI version 1.9 is available from .