The idea: one number, many endless sums

π can be written as an infinite sum (or product) in many different ways. You can never add all the terms, so you stop after n of them. That result is the partial sum Sn. The series converges to π when Sn gets as close to π as you like by taking n large enough. All seven series on this page converge to π, but some take a billion terms to get 10 digits right while others need two.

Horizontal bars on a log scale from 1 to 10 to the 9th: Ramanujan needs 2 terms, BBP 6, Machin 7, Nilakantha 752, and Wallis, Euler and Leibniz about one billion each to get 10 correct digits of pi
Terms needed for 10 correct digits: from 2 (Ramanujan) to about a billion (Leibniz).

The page computes every partial sum exactly, with 70 decimals, so it can count correct digits honestly: how many leading digits of Sn (the 3 and then the decimals) match π. The two digit rows on the canvas show this. Green digits match, the first wrong digit is red. Counting stops at 60 decimals ("60+").

The seven series

SeriesFormulaDigits at n = 10Digits at n = 1000
Leibniz (1670s)π/4 = 1 − 1/3 + 1/5 − 1/7 + …13
Euler, the Basel problem (1734)π²/6 = 1 + 1/2² + 1/3² + …13
Wallis product (1656)π/2 = (2·2)/(1·3) · (4·4)/(3·5) · …13
Nilakantha (1500s)π = 3 + 4/(2·3·4) − 4/(4·5·6) + …410
Machin (1706)π/4 = 4 arctan(1/5) − arctan(1/239)1560+
Bailey–Borwein–Plouffe (1995)π = Σ 16−k (4/(8k+1) − 2/(8k+4) − 1/(8k+5) − 1/(8k+6))1560+
Ramanujan (1914)1/π = (2√2/9801) Σ (4k)! (1103 + 26390k) / ((k!)⁴ 3964k)60+60+

Pick a series in the first menu and press Add a Term. The top chart plots S₁ … S₁₂ against a dashed π line, and a thin red line shows the newest gap. The race chart below marks where the series is now: correct digits against n. Race to 1000 draws all seven lines (Demo: race all seven to 1000 terms).

Zig-zag or creep: the sign of the terms

In Leibniz the signs alternate: +4, −4/3, +4/5, −4/7, …. Each step overshoots, so the sums hop above and below π: 4, 2.67, 3.47, 2.90, 3.34, …. Because the terms keep shrinking, π always lies between two neighbouring sums, and the gap is smaller than the next term (Demo: Leibniz zig-zags slowly). Nilakantha zig-zags the same way but starts at 3 and its terms shrink much faster (Demo: Nilakantha).

In Euler's sum every term is positive, so the sums only climb: 2.45, 2.74, 2.86, 2.92, …, always below π (Demo: Euler (Basel) creeps up from below). The Wallis product multiplies factors a little bigger than 1, such as 4/3, 16/15 and 36/35, and also creeps up from below (Demo: Wallis product).

Slow: an error like 1/n

After n terms, Leibniz is off by about 1/n, Euler by about 0.95/n and Wallis by about π/(4n). To gain one more digit you must make the error 10 times smaller, so you need 10 times as many terms. After 1000 terms all three have only 3 correct digits (Leibniz gives 3.1405…), and 10 digits would need about a billion terms. On the race chart, where n is on a log scale, these three lines climb only about one digit per tick mark.

Nilakantha's terms are about 1/(2n)³, so its error falls like 1/n³: each ×10 in n buys three digits. It reaches 10 correct digits at n = 752.

Fast: a fixed number of digits per term

The other three are geometric at heart: each term is a fixed factor smaller than the one before, so every term adds about the same number of correct digits.

  • Machin: arctan(1/5) = 1/5 − 1/(3·5³) + 1/(5·5⁵) − …, so each term is about 25 times smaller: log₁₀ 25 ≈ 1.4 digits per term (Demo: Machin, 1.4 digits per term).
  • BBP: the factor 1/16k makes each term 16 times smaller: about 1.2 digits per term (Demo: BBP, base 16).
  • Ramanujan: each term is about 396⁴/256 ≈ 96 million times smaller: about 8 digits per term. One term gives 3.1415927, two give 16 correct digits, and 8 terms pass 60 decimals (Demo: Ramanujan, 8 digits per term).

Why does Machin's formula hold? An angle θ with tan θ = 1/5 is about 11.31°. Four of them make about 45.24°, just past 45°. The tiny overshoot is exactly arctan(1/239).

Four wedges of angle theta equal to arctan of one fifth, stacked from the horizontal axis, reach just past a dashed 45 degree line; the thin red sliver past 45 degrees is arctan of 1/239
4·arctan(1/5) overshoots 45° by exactly arctan(1/239), so π/4 = 4 arctan(1/5) − arctan(1/239).

Both arctan series use a small x, so they shrink fast. Formulas of this kind computed π by hand to 100 digits in 1706, and to 707 digits (527 of them correct) by William Shanks in the 1870s.

BBP: a digit without the ones before it

The 1/16k in the BBP formula means it is really a series in base 16. Using it, you can compute the millionth hexadecimal digit of π without computing the first 999,999. This is called digit extraction. The page uses BBP only as an ordinary series, in decimal.

What is used in practice

Record computations of π, trillions of digits, use the Chudnovsky formula. It has the same shape as Ramanujan's and gives about 14 digits per term, with tricks such as binary splitting to multiply huge numbers quickly. Leibniz, Euler and Wallis are useful for proofs and for teaching, not for computing.

See also Taylor Series (where π/4 = 1 − 1/3 + 1/5 − … comes from: the series of arctan x at x = 1), Geometric Series (why a fixed ratio gives fixed digits per term), Series Convergence Tests and Monte Carlo Estimation of π (an even slower road: error like 1/√n) and Archimedes' π (polygons squeeze π from inside and outside, about 0.6 digits per doubling of the sides).

What the page leaves out

Proofs of the formulas (Euler's sin x product for the Basel problem, Ramanujan's modular equations), error bounds beyond the rough rates, acceleration tricks such as averaging neighbouring Leibniz sums, the Chudnovsky formula itself, binary splitting and fast multiplication, iterative methods such as Gauss–Legendre (which doubles the digits every step), and how the hexadecimal digit extraction with BBP works.

On the mind map

This page on the Calculus mind map · 43 pages in 8 branches · open it to see the whole map and test yourself in recall mode.