# Approximations of π

Graph showing the historical evolution of the record precision of numerical approximations to pi, measured in decimal places (depicted on a logarithmic scale; time before 1400 is not shown to scale).

Approximations 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 (Archimedes). In Chinese mathematics, this was improved to approximations correct to what corresponds to about seven decimal digits by the 5th century.

Further progress was made only from the 15th century (Jamshīd al-Kāshī), and early modern mathematicians reached an accuracy of 35 digits by the 18th century (Ludolph van Ceulen), and 126 digits by the 19th century (Jurij Vega), 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 mid 20th century, approximation of π has been the task of electronic digital computers; the current record (as of May 2015) is at 13.3 trillion digits, calculated in October 2014.[1]

## 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[2] have claimed that the ancient Egyptians used an approximation of π as 227 from as early as the Old Kingdom.[3] This claim has met with skepticism.[4][5]

Babylonian mathematics usually approximated π to 3, sufficient for the architectural projects of the time (notably also reflected in the description of Solomon's Temple in the Hebrew Bible).[6] The Babylonians were aware that this was an approximation, and one Old Babylonian mathematical tablet excavated near Susa in 1936 (dated to between the 19th and 17th centuries BCE) gives a better approximation of π as 25/8=3.125, about 0.5 percent below the exact value.[7]

At about the same time, the Egyptian Rhind Mathematical Papyrus )dated to the Second Intermediate Period, c. 1600 BCE, although stated to be a copy of an older, Middle Kingdom text) implies an approximation of π as 25681 ≈ 3.16 (accurate to 0.6 percent) by calculating the area of a circle by approximating the circle by an octagon.[4][8]

Astronomical calculations in the Shatapatha Brahmana (c. 4th century BCE) use a fractional approximation of 339/108≈3.139 (accuracy 9·10−4).[9]

In the 3rd century BCE, Archimedes proved the sharp inequalities 22371 < π < 227, by means of regular 96-gons (accuracies of 2·10−4 and 4·10−4, respectively).

In the 2nd century CE, Ptolemy, used the value 377120, the first known approximation accurate to three decimal places (accuracy 2·10−5).[10]

The Chinese mathematician Liu Hui in 263 CE computed π to between 3.141024 and 3.142708 by inscribing an 96-gon and 192-gon; the average of these two values is 3.141864 (accuracy 9·10−5). 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 π ≈ 3927/1250 = 3.1416 (accuracy 2·10−6), although some scholars instead believe that this is due to the later (5th-century) Chinese mathematician Zu Chongzhi.[11] 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 π: π ≈ 22/7 and π ≈ 355/113. 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 (6th century), mathematician Aryabhata in his astronomical treatise Āryabhaṭīya calculated the value of π to five significant figures (π ≈ 62832/20000 = 3.1416).[12] using it to calculate an approximation of the earth's circumference.[13] Aryabhata stated that his result "approximately" (āsanna "approaching") gave the circumference of a circle. His 15th-century commentator Nilakantha Somayaji (Kerala school of astronomy and mathematics) has argued that the word means not only that this is an approximation, but that the value is incommensurable (irrational).[14]

## 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,[15][16] 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

$\pi = \sqrt{12}\sum^\infty_{k=0} \frac{(-3)^{-k}}{2k+1} = \sqrt{12}\sum^\infty_{k=0} \frac{(-\frac{1}{3})^k}{2k+1} = \sqrt{12}\left(1-{1\over 3\cdot3}+{1\over5\cdot 3^2}-{1\over7\cdot 3^3}+\cdots\right)$
Comparison of the convergence of two Madhava series (the one with √12 in dark blue) and several historical infinite series for π. Sn is the approximation after taking n terms. Each subsequent subplot magnifies the shaded area horizontally by 10 times. (click for detail)

and used the first 21 terms to compute an approximation of π correct to 11 decimal places as 3.14159265359.

The other method he used was to add a remainder term to the original series of π. He used the remainder term

$\frac{n^2 + 1}{4n^3 + 5n}$

in the infinite series expansion of π4 to improve the approximation of π to 13 decimal places of accuracy when n = 75.

Jamshīd al-Kāshī (Kāshānī), a Persian astronomer and mathematician, correctly computed 2π to 9 sexagesimal digits in 1424.[17] This figure is equivalent to 17 decimal digits as

$2\pi \approx 6.28318530717958648, \,$

which equates to

$\pi \approx 3.14159265358979324. \,$

He achieved this level of accuracy by calculating the perimeter of a regular polygon with 3 × 228 sides.[18]

## 16th to 19th centuries

In the second half of the 16th century the French mathematician François Viète discovered an infinite product which converged on Pi known as Viète's formula.

The German/Dutch mathematician Ludolph van Ceulen (circa 1600) 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 (1621), Willebrord Snellius (a.k.a. Snell) 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. Snell was able to obtain 7 digits of Pi from a 96-sided polygon.[19]

The Slovene mathematician Jurij Vega in 1789 calculated the first 140 decimal places for π of which the first 126 were correct [20] 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 (152 decimal places) can be put into context by the fact that the circumference of the largest known thing, the observable universe, can be calculated from its diameter (93 billion light-years) to a precision of less than one Planck length (at 1.6162×1035 [[[[meters, the shortest unit of length that has real meaning) 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, although only the first 527 were 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 century

In 1910, the Indian mathematician Srinivasa Ramanujan found several rapidly converging infinite series of π, including

$\frac{1}{\pi} = \frac{2\sqrt{2}}{9801} \sum^\infty_{k=0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}}$

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 100000 decimal places[21]:78 was computed by Maryland mathematician Daniel Shanks (no relation to the above-mentioned William 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.[21]:80–99 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.[21]:78

In 1989, the Chudnovsky brothers correctly computed π to over 1 billion decimal places on the supercomputer IBM 3090 using the following variation of Ramanujan's infinite series of π:

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

In 1999, Yasumasa Kanada and his team at the University of Tokyo correctly computed π to over 200 billion decimal places on the supercomputer HITACHI SR8000/MPP (128 nodes) using another variation of Ramanujan's infinite series of π. In October 2005 they claimed to have calculated it to 1.24 trillion places.[22]

## 21st century – current claimed world record

In August 2009, a Japanese Supercomputer called the T2K Open Supercomputer was claimed to have more than doubled the previous record by calculating π to 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 (binary), then the result was converted to base 10 (decimal). The calculation, conversion, and verification steps took a total of 131 days.[23]

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.[24] The calculation was done between 4 May and 3 August, with the primary and secondary verifications taking 64 and 66 hours respectively.[25] In October 2011, they broke their own record by computing ten trillion (1013) and fifty digits using the same method but with better hardware. [26][27]

In December 2013 they broke their own record again when they computed 12.1 trillion digits of π.[28]

## 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 227 (accuracy 2·10−4) and 355113 (accuracy 8·10−8).

Of some notability are legal or historical texts purportedly "defining π" to have some rational value, notably the "Indiana Pi Bill" of 1897, which stated "the ratio of the diameter and circumference is as five-fourths to four" (which would imply "π = 3.2") and a passage in the Hebrew Bible which seems to imply that "π equals three".

### Imputed biblical value

It is sometimes claimed that the Hebrew Bible implies that "π equals three", based on a passage in 1 Kings 7:23 and 2 Chronicles 4:2 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.[29] Among the many explanations and comments are these:

• Rabbi Nehemiah explained this in his Mishnat ha-Middot (the earliest known Hebrew text on geometry, ca. 150 CE) by saying that the diameter was measured from the outside rim while the circumference was measured along the inner rim. This interpretation implies a brim about 0.225 cubit (or, assuming an 18-inch "cubit", some 4 inches), or one and a third "handbreadths," thick (cf. 1 Kings 7:24 and 2 Chronicles 4:3).
• Maimonides states (ca. 1168 CE) that π can only be known approximately, so the value 3 was given as accurate enough for religious purposes. This is taken by some[30] as the earliest assertion that π is irrational.
• Another rabbinical explanation[by whom?][year needed] invokes gematria: In 1 Kings 7:23 the word translated 'measuring line' appears in the Hebrew text spelled QWH קַוה, but elsewhere the word is most usually spelled QW קַו. The ratio of the numerical values of these Hebrew spellings is 111106. If the putative value of 3 is multiplied by this ratio, one obtains 333106 = 3.141509433... – within 1/10,000th of the true value of π.

There is still some debate on this passage in biblical scholarship.[not in citation given][31][32] Many reconstructions of the basin show a wider brim (or flared lip) extending outward from the bowl itself by several inches to match the description given in 1 Kings 7:26[33] 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" 2 Chronicles 4:5, 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.

### The Indiana bill

The "Indiana Pi Bill" of 1897, which was nearly passed by the Indiana General Assembly in the U.S., 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 π = 16/5 = 3.2, 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.

## Development of efficient formulae

### Polygon approximation to a circle

A very simple method, known to the ancient Greeks, uses the fact that as the number of sides of a regular polygon increases, the perimeter approaches the length of the circumscribed circle. The perimeter of a regular polygon with 'n' sides inscribed in a circle of diameter one unit is n x sin(180/n)

As 'n' increases, the perimeter approaches the value of pi.[34]

### Machin-like formulae

For fast calculations, one may use formulae such as Machin's:

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

together with the Taylor series expansion of the function arctan(x). This formula is most easily verified using polar coordinates of complex numbers, producing:

$(5+i)^4\cdot(239-i)=-114244-114244i.$

Another example is:

$\frac{\pi}{4} = \arctan\frac{1}{2} + \arctan\frac{1}{3}$

which is verified as above as producing a 45° vector:

$(2+i)\cdot(3+i) = 5+5i = 5 \sqrt{2}\ \mathrm{cis}\ 45^\circ.$

Formulae of this kind are known as Machin-like formulae.

### Other classical formulae

Other formulae that have been used to compute estimates of π include:

\begin{align} \pi &\approxeq 768 \sqrt{2 - \sqrt{2 + \sqrt{2 + \sqrt{2 + \sqrt{2 + \sqrt{2 + \sqrt{2 + \sqrt{2 + \sqrt{2+1}}}}}}}}}\\ &\approxeq 3.141590463236763. \end{align}
$\pi = \sqrt{12}\sum^\infty_{k=0} \frac{(-3)^{-k}}{2k+1} = \sqrt{12}\sum^\infty_{k=0} \frac{(-\frac{1}{3})^k}{2k+1} = \sqrt{12}\left({1\over 1\cdot3^0}-{1\over 3\cdot3^1}+{1\over5\cdot 3^2}-{1\over7\cdot 3^3}+\cdots\right)$
${\pi} = 20 \arctan\frac{1}{7} + 8 \arctan\frac{3}{79}$
$\frac{\pi}{2}= \sum_{k=0}^\infty\frac{k!}{(2k+1)!!}= \sum_{k=0}^{\infty} \cfrac {2^k k!^2}{(2k + 1)!} = 1+\frac{1}{3}\left(1+\frac{2}{5}\left(1+\frac{3}{7}\left(1+\cdots\right)\right)\right)$

where (2k+1)!! denotes the product of the odd integers up to 2k+1.

$\frac{1}{\pi} = \frac{2\sqrt{2}}{9801} \sum^\infty_{k=0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}}$
$\frac{1}{\pi} = 12 \sum^\infty_{k=0} \frac{(-1)^k (6k)! (13591409 + 545140134k)}{(3k)!(k!)^3 640320^{3k + 3/2}}$

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 fast:

For $y_0=\sqrt2-1,\ a_0=6-4\sqrt2$ and

$y_{k+1}=(1-f(y_k))/(1+f(y_k)) ~,~ a_{k+1} = a_k(1+y_{k+1})^4 - 2^{2k+3} y_{k+1}(1+y_{k+1}+y_{k+1}^2)$

where $f(y)=(1-y^4)^{1/4}$, the sequence $1/a_k$ converges quartically to π, giving about 100 digits in three steps and over a trillion digits after 20 steps.

The first one million digits of π and 1π are available from Project Gutenberg (see external links below). A former calculation record (December 2002) 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 (206 billion digits). The following Machin-like formulæ were used for this:

$\frac{\pi}{4} = 12 \arctan\frac{1}{49} + 32 \arctan\frac{1}{57} - 5 \arctan\frac{1}{239} + 12 \arctan\frac{1}{110443}$
K. Takano (1982).
$\frac{\pi}{4} = 44 \arctan\frac{1}{57} + 7 \arctan\frac{1}{239} - 12 \arctan\frac{1}{682} + 24 \arctan\frac{1}{12943}$ (F. C. W. Störmer (1896)).

These approximations have so many digits that they are no longer of any practical use, except for testing new supercomputers.[35] Properties like the potential normality of π 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 (decimal) significant figures with the number 3:8:29:4460, which is

$3 + \frac{8}{60} + \frac{29}{60^2} + \frac{44}{60^3} = 3.14159\ 259^+$

(The next sexagesimal digit is 0, causing truncation here to yield a relatively good approximation.)

In addition, the following expressions can be used to estimate π:

• accurate to three digits:
$\sqrt{2} + \sqrt{3} = 3.146^+$
Karl Popper conjectured that Plato knew this expression, that he believed it to be exactly π, and that this is responsible for some of Plato's confidence in the omnicompetence of mathematical geometry—and Plato's repeated discussion of special right triangles that are either isosceles or halves of equilateral triangles.
$\sqrt{15} - \sqrt {3} + 1 = 3.140^+$
• accurate to four digits:
$\sqrt[3]{31} = 3.1413^+$[36]
• accurate to four digits (or five significant figures):
$\sqrt{7+\sqrt{6+\sqrt{5}}} = 3.1416^+$[37]
• an approximation by Ramanujan, accurate to 4 digits (or five significant figures):
$\frac{9}{5}+\sqrt{\frac{9}{5}} = 3.1416^+$
• accurate to five digits:
$\frac{7^7}{4^9} = 3.14156^+$
• accurate to seven digits:
$\frac{355}{113} = 3.14159\ 29^+$
• accurate to nine digits:
$\sqrt[4]{3^4+2^4+\frac{1}{2+(\frac{2}{3})^2}} =\sqrt[4]{\frac{2143}{22}} = 3.14159\ 2652^+$
This is from Ramanujan, who claimed the Goddess of Namagiri appeared to him in a dream and told him the true value of π.[38]
• accurate to ten digits:
$\frac{63}{25} \times \frac{17 + 15\sqrt{5}}{7 + 15\sqrt{5}} = 3.14159\ 26538^+$
• accurate to ten digits (or eleven significant figures):
$\sqrt[193]{\frac{10^{100}}{11222.11122}} = 3.14159\ 26536^+$
This curious approximation follows the observation that the 193rd power of 1/π yields the sequence 1122211125... Replacing 5 by 2 completes the symmetry without reducing the correct digits of π, while inserting a central decimal point remarkably fixes the accompanying magnitude at 10100.[39]
• accurate to 18 digits:
$\frac{80\sqrt{15}(5^4+53\sqrt{89})^\frac{3}{2}}{3308(5^4+53\sqrt{89})-3\sqrt{89}}$[40]
This is based on the fundamental discriminant d = 3(89) = 267 which has class number h(-d) = 2 explaining the algebraic numbers of degree 2. Note that the core radical $\scriptstyle 5^4+53\sqrt{89}$ is 53 more than the fundamental unit $\scriptstyle U_{89} = 500+53\sqrt{89}$ which gives the smallest solution { x, y} = {500, 53} to the Pell equation x2-89y2 = -1.
• accurate to 30 decimal places:
$\frac{\ln(640320^3+744)}{\sqrt{163}} = 3.14159\ 26535\ 89793\ 23846\ 26433\ 83279^+$
Derived from the closeness of Ramanujan constant to the integer 640320³+744. This does not admit obvious generalizations in the integers, because there are only finitely many Heegner numbers and negative discriminants d with class number h(−d) = 1, and d = 163 is the largest one in absolute value.
• accurate to 52 decimal places:
$\frac{\ln(5280^3(236674+30303\sqrt{61})^3+744)}{\sqrt{427}}$
Like the one above, a consequence of the j-invariant. Among negative discriminants with class number 2, this d the largest in absolute value.
• accurate to 161 decimal places:
$\frac{\ln\big((2u)^6+24\big)}{\sqrt{3502}}$
where u is a product of four simple quartic units,
$u = (a+\sqrt{a^2-1})^2(b+\sqrt{b^2-1})^2(c+\sqrt{c^2-1})(d+\sqrt{d^2-1})$
and,
\begin{align} a &= \tfrac{1}{2}(23+4\sqrt{34})\\ b &= \tfrac{1}{2}(19\sqrt{2}+7\sqrt{17})\\ c &= (429+304\sqrt{2})\\ d &= \tfrac{1}{2}(627+442\sqrt{2}) \end{align}
Based on one found by Daniel Shanks. Similar to the previous two, but this time is a quotient of a modular form, namely the Dedekind eta function, and where the argument involves $\tau = \sqrt{-3502}$. The discriminant d = 3502 has h(−d) = 16.
• 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:[41][42]
$\frac{3}{1}, \frac{22}{7}, \frac{333}{106}, \frac{355}{113}, \frac{103993}{33102}, \frac{104348}{33215}, \frac{208341}{66317}, \frac{312689}{99532}, \frac{833719}{265381}, \frac{1146408}{364913}, \frac{4272943}{1360120}, \frac{5419351}{1725033}$
Of all of these, $\frac{355}{113}$ is the only fraction in this sequence that gives more exact digits of π (i.e. 7) than the number of digits needed to approximate it (i.e. 6). The accuracy can be improved by using other fractions with larger numerators and denominators, but, for most such fractions, more digits are required in the approximation than correct significant figures achieved in the result.[43]

### Summing a circle's area

Numerical approximation of π: as points are randomly scattered inside the unit square, some fall within the unit circle. The fraction of points inside the circle approaches π/4 as points are added.

Pi can be obtained from a circle if its radius and area are known using the relationship:

$A = \pi r^2.\$

If a circle with radius r is drawn with its center at the point (0, 0), any point whose distance from the origin is less than r will fall inside the circle. The Pythagorean theorem gives the distance from any point (xy) to the center:

$d=\sqrt{x^2+y^2}.\!$

Mathematical "graph paper" is formed by imagining a 1×1 square centered around each cell (xy), where x and y are integers between −r and r. Squares whose center resides inside or exactly on the border of the circle can then be counted by testing whether, for each cell (xy),

$\sqrt{x^2+y^2} \le r.\!$

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 r.

Mathematically, this formula can be written:

$\pi = \lim_{r \to \infty} \frac{1}{r^2} \sum_{x=-r}^{r} \; \sum_{y=-r}^{r} \begin{cases} 1 & \text{if } \sqrt{x^2+y^2} \le r \\ 0 & \text{if } \sqrt{x^2+y^2} > r. \end{cases}$

In other words, begin by choosing a value for r. Consider all cells (xy) in which both x and y are integers between −r and r. Starting at 0, add 1 for each cell whose distance to the origin (0,0) is less than or equal to r. When finished, divide the sum, representing the area of a circle of radius r, by r2 to find the approximation of π. For example, if r is 5, then the cells considered are:

 (−5,5) (−4,5) (−3,5) (−2,5) (−1,5) (0,5) (1,5) (2,5) (3,5) (4,5) (5,5) (−5,4) (−4,4) (−3,4) (−2,4) (−1,4) (0,4) (1,4) (2,4) (3,4) (4,4) (5,4) (−5,3) (−4,3) (−3,3) (−2,3) (−1,3) (0,3) (1,3) (2,3) (3,3) (4,3) (5,3) (−5,2) (−4,2) (−3,2) (−2,2) (−1,2) (0,2) (1,2) (2,2) (3,2) (4,2) (5,2) (−5,1) (−4,1) (−3,1) (−2,1) (−1,1) (0,1) (1,1) (2,1) (3,1) (4,1) (5,1) (−5,0) (−4,0) (−3,0) (−2,0) (−1,0) (0,0) (1,0) (2,0) (3,0) (4,0) (5,0) (−5,−1) (−4,−1) (−3,−1) (−2,−1) (−1,−1) (0,−1) (1,−1) (2,−1) (3,−1) (4,−1) (5,−1) (−5,−2) (−4,−2) (−3,−2) (−2,−2) (−1,−2) (0,−2) (1,−2) (2,−2) (3,−2) (4,−2) (5,−2) (−5,−3) (−4,−3) (−3,−3) (−2,−3) (−1,−3) (0,−3) (1,−3) (2,−3) (3,−3) (4,−3) (5,−3) (−5,−4) (−4,−4) (−3,−4) (−2,−4) (−1,−4) (0,−4) (1,−4) (2,−4) (3,−4) (4,−4) (5,−4) (−5,−5) (−4,−5) (−3,−5) (−2,−5) (−1,−5) (0,−5) (1,−5) (2,−5) (3,−5) (4,−5) (5,−5)
This circle as it would be drawn on a Cartesian coordinate graph. The cells (±3, ±4) and (±4, ±3) are labeled.

The 12 cells (0, ±5), (±5, 0), (±3, ±4), (±4, ±3) 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 81 / 52 = 3.24. Results for some values of r are shown in the table below:

r area approximation of π
2 13 3.25
3 29 3.22222
4 49 3.0625
5 81 3.24
10 317 3.17
20 1257 3.1425
100 31417 3.1417
1000 3141549 3.141549

For related results see The circle problem: number of points (x,y) in square lattice with x^2 + y^2 <= n.

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

### Approximation with a regular polygon

Pi is defined as the ratio of the circumference of a circle to its diameter. Circles can be approximated as regular polygons with an increasing number of sides, approaching infinity. Archimedes used this method with a 96-sided polygon to show that π is between 223/71 and 22/7.

### Continued fractions

Besides its simple continued fraction representation [3; 7, 15, 1, 292, 1, 1, ...], which displays no discernible pattern, π has many generalized continued fraction representations generated by a simple rule, including these two.

$\pi= {3 + \cfrac{1^2}{6 + \cfrac{3^2}{6 + \cfrac{5^2}{6 + \ddots\,}}}}\!$
$\pi = \cfrac{4}{1 + \cfrac{1^2}{3 + \cfrac{2^2}{5 + \cfrac{3^2}{7 + \ddots}}}}\!$

(Other representations are available at The Wolfram Functions Site.)

### Trigonometry

#### Gregory–Leibniz series

$\pi = 4\sum_{n=0}^{\infty} \cfrac {(-1)^n}{2n+1} = 4\left( \frac{1}{1} - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} +- \cdots\right) \! = \cfrac{4}{1 + \cfrac{1^2}{2 + \cfrac{3^2}{2 + \cfrac{5^2}{2 + \ddots}}}}\!$

is the power series for arctan(x) specialized to x = 1. It converges too slowly to be of practical interest. However, the power series converges much faster for smaller values of $x$, which leads to formulas where $\pi$ arises as the sum of small angles with rational tangents, such as these two by John Machin:

$\pi = 4\arctan\frac{1}{2} + 4\arctan\frac{1}{3}\!$
$\pi = 16\arctan\frac{1}{5} - 4\arctan\frac{1}{239}.\!$

Formulas for π of this type are known as Machin-like formulae.

#### Arctangent

Further information: Double factorial

Knowing that $4\arctan(1) = \pi\!$ the formula can be simplified to get:

$\pi = 2\left( 1 + \cfrac{1}{3} + \cfrac{1\cdot2}{3\cdot5} + \cfrac{1\cdot2\cdot3}{3\cdot5\cdot7} + \cfrac{1\cdot2\cdot3\cdot4}{3\cdot5\cdot7\cdot9} + \cfrac{1\cdot2\cdot3\cdot4\cdot5}{3\cdot5\cdot7\cdot9\cdot11} + \cdots\right) \!$
$= 2\sum_{n=0}^{\infty} \cfrac {n!}{(2n + 1)!!} = \sum_{n=0}^{\infty} \cfrac {2^{n+1} n!^2} {(2n + 1)!} = \sum_{n=0}^{\infty} \cfrac {2^{n+1}} {\binom {2n} n (2n + 1)} \!$
$= 2 + \frac{2}{3} + \frac{4}{15} + \frac{4}{35} + \frac{16}{315} + \frac{16}{693} + \frac{32}{3003} + \frac{32}{6435} + \frac{256}{109395} + \frac{256}{230945} + \cdots\!$

with a convergence such that each additional 10 terms yields at least three more digits.

#### Arcsine

Observing an equilateral triangle and noting that

$\sin\left (\frac{\pi}{6}\right )=\frac{1}{2}\!$

yields

$\pi = 6 \sin^{-1} \left( \frac{1}{2} \right) = 6 \left( \frac{1}{2} + \frac{1}{2\cdot 3\cdot 2^3} + \frac{1\cdot 3}{2\cdot 4\cdot 5\cdot 2^5} + \frac{1\cdot 3\cdot 5}{2\cdot 4\cdot 6\cdot 7\cdot 2^7} + \cdots\! \right)$
$= \frac {3} {16^0 \cdot 1} + \frac {6} {16^1 \cdot 3} + \frac {18} {16^2 \cdot 5} + \frac {60} {16^3 \cdot 7} + \cdots\! = \sum_{n=0}^\infty \frac {3 \cdot \binom {2n} n} {16^n (2n+1)}$
$= 3 + \frac{1}{8} + \frac{9}{640} + \frac{15}{7168} + \frac{35}{98304} + \frac{189}{2883584} + \cfrac{693}{54525952} + \frac{429}{167772160} + \cdots\!$

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 $\pi$ to $N$ digits in time proportional to $N\,\log(N)\,\log(\log(N))$, much faster than the trigonometric formulae.

## Digit extraction methods

The Bailey–Borwein–Plouffe formula (BBP) for calculating π was discovered in 1995 by Simon Plouffe. Using base 16 math, the formula can compute any particular digit of π—returning the hexadecimal value of the digit—without having to compute the intervening digits (digit extraction). [44]

$\pi=\sum_{n=0}^\infty \left(\frac{4}{8n+1}-\frac{2}{8n+4}-\frac{1}{8n+5}-\frac{1}{8n+6}\right)\left(\frac{1}{16}\right)^n\!$

In 1996, Simon Plouffe derived an algorithm to extract the nth decimal digit of π (using base 10 math to extract a base 10 digit), and which can do so with an improved speed of O(n3log(n)3) 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.[45]

$\pi+3=\sum_{n=1}^\infty \frac{n2^nn!^2}{(2n)!}$

The calculation speed of Plouffe's formula was improved to O(n2) by Fabrice Bellard, who derived an alternative formula (albeit only in base 2 math) for computing π.[46]

$\pi=\frac{1}{2^6}\sum_{n=0}^\infty \frac{(-1)^n}{2^{10n}} \left (-\frac{2^5}{4n+1}-\frac{1}{4n+3}+\frac{2^8}{10n+1}-\frac{2^6}{10n+3}-\frac{2^2}{10n+5}-\frac{2^2}{10n+7}+\frac{1}{10n+9}\right )\!$

## Efficient methods

In 1961 the first expansion of π to 100,000 decimal places was computed by Maryland mathematician Dr. Daniel Shanks and his team at the United States Naval Research Laboratory (N.R.L.).

Daniel 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,000 digits of π were published by the Naval Research Laboratory.

None of the formulæ given above can serve as an efficient way of approximating π. For fast calculations, one may use a formula such as Machin's:

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

together with the Taylor series expansion of the function arctan(x). This formula is most easily verified using polar coordinates of complex numbers, starting with,

$(5+i)^4\cdot(239-i)=2^2 \cdot 13^4(1+i).\!$

Formulae of this kind are known as Machin-like formulae. (Note also that { x,y} = {239, 132} is a solution to the Pell equation x2-2y2 = -1.)

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.

The first one million digits of π and 1/π are available from Project Gutenberg (see external links below). The record as of December 2002 by Yasumasa Kanada of Tokyo University stood at 1,241,100,000,000 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 (206 billion digits). The following Machin-like formulæ were used for this:

$\frac{\pi}{4} = 12 \arctan\frac{1}{49} + 32 \arctan\frac{1}{57} - 5 \arctan\frac{1}{239} + 12 \arctan\frac{1}{110443}\!$
K. Takano (1982).
$\frac{\pi}{4} = 44 \arctan\frac{1}{57} + 7 \arctan\frac{1}{239} - 12 \arctan\frac{1}{682} + 24 \arctan\frac{1}{12943}\!$
F. C. W. Störmer (1896).

These approximations have so many digits that they are no longer of any practical use, except for testing new supercomputers. (Normality of π will always depend on the infinite string of digits on the end, not on any finite computation.)

In 1997, David H. Bailey, Peter Borwein and Simon Plouffe published a paper (Bailey, 1997) on a new formula for π as an infinite series:

$\pi = \sum_{k = 0}^\infty \frac{1}{16^k} \left( \frac{4}{8k + 1} - \frac{2}{8k + 4} - \frac{1}{8k + 5} - \frac{1}{8k + 6}\right).\!$

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 π (which turns out to be 0).

Fabrice Bellard further improved on BBP with his formula[1]:

$\pi = \frac{1}{2^6} \sum_{n=0}^{\infty} \frac{{(-1)}^n}{2^{10n}} \left( - \frac{2^5}{4n+1} - \frac{1}{4n+3} + \frac{2^8}{10n+1} - \frac{2^6}{10n+3} - \frac{2^2}{10n+5} - \frac{2^2}{10n+7} + \frac{1}{10n+9} \right)\!$

Other formulae that have been used to compute estimates of π include:

$\frac{\pi}{2}=\sum_{k=0}^\infty\frac{k!}{(2k+1)!!}=\sum_{k=0}^{\infty}\frac{2^k k!^2}{(2k+1)!} =1+\frac{1}{3}\left(1+\frac{2}{5}\left(1+\frac{3}{7}\left(1+\cdots\right)\right)\right)\!$
Newton.
$\frac{1}{\pi} = \frac{2\sqrt{2}}{9801} \sum^\infty_{k=0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}}\!$
Srinivasa Ramanujan.

This converges extraordinarily rapidly. Ramanujan's work is the basis for the fastest algorithms used, as of the turn of the millennium, to calculate π.

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

## Projects

### Pi Hex

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 (5*1012), the forty trillionth, and the quadrillionth (1015) 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 CLN and MPFR.

### 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.

• y-cruncher by Alexander Yee[47] is the program which Shigeru Kondo used to compute the current world record number of digits. y-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.[48] PiFast can also compute other irrational numbers like e and √2. It can also work at lesser efficiency with very little memory (down to a few tens of megabytes to compute well over a billion (109) digits). This tool is a popular benchmark in the overclocking community. PiFast 4.4 is available from Stu's Pi page. 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 e, √2, and √3. The software may be obtained from the Pi-Hacks Yahoo! forum, or from Stu's Pi page.
• Super PI by Kanada Laboratory[49] 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.1 is available from Super PI 1.1 page.
• apfloat provides a Pi Calculator Applet for computing π in a browser. It can compute a million digits of π in a few seconds on a normal PC. Different radixes and algorithms can be used. In theory it can compute more than 1015 digits of π.

## References

1. ^ http://www.numberworld.org/y-cruncher/
2. ^ Petrie, W.M.F. Wisdom of the Egyptians (1940)
3. ^ Based on the Great Pyramid of Giza, supposedly built so that the circle whose radius is equal to the height of the pyramid has a circumference equal to the perimeter of the base (it is 1760 cubits around and 280 cubits in height). Verner, Miroslav. The Pyramids: The Mystery, Culture, and Science of Egypt's Great Monuments. Grove Press. 2001 (1997). ISBN 0-8021-3935-3
4. ^ a b Rossi, Corinna Architecture and Mathematics in Ancient Egypt, Cambridge University Press. 2007. ISBN 978-0-521-69053-9.
5. ^ Legon, J. A. R. On Pyramid Dimensions and Proportions (1991) Discussions in Egyptology (20) 25-34 [2]
6. ^ See #Imputed biblical value. There has been concern over the apparent biblical statement of π ≈ 3 from the early times of rabbinical Judaism, addressed by Rabbi Nehemiah in the 2nd century. Petr Beckmann, A History of Pi, St. Martin's (1971).[page needed]
7. ^ David Gilman Romano, Athletics and Mathematics in Archaic Corinth: The Origins of the Greek Stadion, American Philosophical Society, 1993, p. 78. "A group of mathematical clay tablets from the Old Babylonian Period, excavated at Susa in 1936, and published by E.M. Bruins in 1950, provide the information that the Babylonian approximation of π was 3 1/8 or 3.125." E. M. Bruins, Quelques textes mathématiques de la Mission de Suse, 1950. E. M. Bruins and M. Rutten, Textes mathématiques de Suse, Mémoires de la Mission archéologique en Iran vol. XXXIV (1961). See also Beckmann, Petr (1971), A History of Pi, New York: St. Martin's Press, pp. 12, 21–22 "in 1936, a tablet was excavated some 200 miles from Babylon. [...] The mentioned tablet, whose translation was partially published only in 1950, [...] states that the ratio of the perimeter of a regular hexagon to the circumference of the circumscribed circle equals a number which in modern notation is given by 57/60+36/(60)2 [i.e. π = 3/0.96 = 25/8]". Jason Dyer , On the Ancient Babylonian Value for Pi, 3 December 2008.
8. ^ Katz, Victor J. (ed.), Imhausen, Annette et al. The Mathematics of Egypt, Mesopotamia, China, India, and Islam: A Sourcebook, Princeton University Press. 2007. ISBN 978-0-691-11485-9
9. ^ Chaitanya, Krishna. A profile of Indian culture. Indian Book Company (1975). P. 133.
10. ^ http://uzweb.uz.ac.zw/science/maths/zimaths/pi.htm
11. ^ Lam, Lay Yong; Ang, Tian Se (1986), "Circle measurements in ancient China", Historia Mathematica 13 (4): 325–340, doi:10.1016/0315-0860(86)90055-8, MR 875525. Reprinted in Berggren, J. L.; Borwein, Jonathan M.; Borwein, Peter, eds. (2004), Pi: A Source Book, Springer, pp. 20–35, ISBN 9780387205717. See in particular pp. 333–334 (pp. 28–29 of the reprint).
12. ^ Āryabhaṭīya (gaṇitapāda 10):
"Add four to one hundred, multiply by eight and then add sixty-two thousand. The result is approximately the circumference of a circle of diameter twenty thousand. By this rule the relation of the circumference to diameter is given."
In other words, (4 + 100) × 8 + 62000 is the circumference of a circle with diameter 20000. This provides a value of π ≈ 62832/20000 = 3.1416, Jacobs, Harold R. (2003). Geometry: Seeing, Doing, Understanding (Third Edition). New York: W.H. Freeman and Company. p. 70.
13. ^ "Aryabhata the Elder". University of St Andrews, School of Mathematics and Statistics. Retrieved 20 July 2011.
14. ^ S. Balachandra Rao (1998). Indian Mathematics and Astronomy: Some Landmarks. Bangalore: Jnana Deep Publications. ISBN 81-7371-205-0.
15. ^ George E. Andrews, Richard Askey, Ranjan Roy (1999). Special Functions. Cambridge University Press. p. 58. ISBN 0-521-78988-5.
16. ^ Gupta, R. C. (1992). "On the remainder term in the Madhava–Leibniz's series". Ganita Bharati 14 (1-4): 68–71.
17. ^ Al-Kashi, author: Adolf P. Youschkevitch, chief editor: Boris A. Rosenfeld, p. 256
18. ^ Azarian, Mohammad K. (2010), "al-Risāla al-muhītīyya: A Summary", Missouri Journal of Mathematical Sciences 22 (2): 64–85
20. ^ Sandifer, Dr. Edward. Why 140 Digits of Pi Matter, page 17. NOTE: The last paragraph on that page says "the 127th digit... should be an 8." It is actually a 6.
21. ^ a b c Shanks, D.; Wrench, Jr., J. W. (1962). "Calculation of π to 100,000 decimals". Mathematics of Computation (American Mathematical Society) 16 (77): 76–99. doi:10.2307/2003813. JSTOR 2003813..
22. ^ Announcement at the Kanada lab web site.
23. ^ Bellard.org
24. ^ McCormick Grad Sets New Pi Record
25. ^ 5 Trillion Digits of Pi - New World Record
26. ^ http://www.newscientist.com/blogs/shortsharpscience/2011/10/pi-10-trillion.html
27. ^ Alexander J. Yee; Shigeru Kondo (22 October 2011). "Round 2... 10 Trillion Digits of Pi".
28. ^ Alexander J. Yee; Shigeru Kondo (28 December 2013). "12.1 Trillion Digits of Pi".
29. ^ Tsaban, B; Boaz Tsaban, David Garber (February 1998). "On the rabbinical approximation of π" (PDF). Historia Mathematica 25 (1): 75–84. doi:10.1006/hmat.1997.2185. ISSN 0315-0860. Retrieved 14 July 2009.
30. ^ Wilbur Richard Knorr, The Ancient Tradition of Geometric Problems, New York: Dover Publications, 1993.
31. ^ Aleff, H. Peter. "Ancient Creation Stories told by the Numbers: Solomon's Pi". recoveredscience.com. Archived from the original on 14 October 2007. Retrieved 30 October 2007.
32. ^ O'Connor, J J; E F Robertson (August 2001). "A history of Pi". Archived from the original on 30 October 2007. Retrieved 30 October 2007.
33. ^ Math Forum – Ask Dr. Math
34. ^ [3]
35. ^ What Can You Do With a Supercomputer?
36. ^ Gardner, Martin (1995). "New Mathematical Diversions". Mathematical Association of America. p. 92.
37. ^ A nested radical approximation for π
38. ^ "Lost notebook page 16" ,Ramanujan
39. ^ Hoffman, D.W. College Mathematics Journal, 40 (2009) 399
40. ^ CetinHakimoglu–Brown
41. ^ "Sloane's A002485 : Numerators of convergents to Pi", The On-Line Encyclopedia of Integer Sequences. OEIS Foundation.
42. ^ "Sloane's A002486 : Denominators of convergents to Pi", The On-Line Encyclopedia of Integer Sequences. OEIS Foundation.
43. ^ Fractional Approximations of Pi accurate up to 37 digits
44. ^ MathWorld: BBP Formula Wolfram.com
45. ^ Simon Plouffe, On the computation of the n'th decimal digit of various transcendental numbers, November 1996; Revised December 2009
46. ^ Bellard's Website: Bellard.org
47. ^ y-cruncher
48. ^