Skip to content
CalcWorld

Browse all tools

Pi Calculator

This pi calculator approximates π with four classic series, each summed to the number of terms you choose. After 5 terms the Leibniz series gives 3.339683, while Machin's formula is already right to 7 decimal places.

Sources: Wikipedia: Leibniz formula Updated

π/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ...

Number of terms:

Calculated π: -

Actual π: 3.1415926536

Accuracy: -

Error: -

Convergence Graph

Graph shows how the calculated value approaches π as terms increase

The four series for pi

SeriesFormulaAfter 10 terms
Leibnizπ/4 = 1 − 1/3 + 1/5 − 1/7 + …3.0418396189
Nilakanthaπ = 3 + 4/(2×3×4) − 4/(4×5×6) + …3.1414067185
Wallisπ/2 = (2/1)(2/3)(4/3)(4/5)(6/5)(6/7) …3.0677038066
Machinπ/4 = 4 arctan(1/5) − arctan(1/239)3.1415926536

Each series is an endless sum (or, for Wallis, product) that the calculator cuts off after the number of terms you enter. Adding terms one at a time is what the sigma notation calculator does for any expression.

How to approximate pi with the Leibniz series: 5 terms

  1. Write the first five terms: 1 − 1/3 + 1/5 − 1/7 + 1/9.
  2. Turn them into decimals: 1 − 0.333333 + 0.2 − 0.142857 + 0.111111.
  3. Add them up: 0.834921.
  4. Multiply by 4, because the series gives π/4: 4 × 0.834921 = 3.339683.
Pi calculator comparison after 5 terms: Leibniz 3.33968254 (0 correct decimals), Nilakantha 3.14271284 (2), Wallis 3.00217595 (0) and Machin 3.14159268 (7).
With the same 5 terms, Machin's formula is about seven decimal places ahead of the Leibniz series.

The true value is 3.14159265, so the error is 0.198090 and the accuracy shown is 93.69%. The Leibniz series is the easiest to remember and one of the slowest to converge.

Why the series close in at different speeds

The Leibniz terms shrink like 1/n, so after 1,000 terms the sum is 3.1405926538, still wrong in the third decimal. The Nilakantha terms are divided by three numbers multiplied together, so they shrink like 1/n³ and 10 terms already give 3.14141.

Machin's formula sums the arctangent series for 1/5 and 1/239. Each term is about 25 times smaller than the one before, close to a geometric sequence with ratio 1/25, which is why 10 terms match π to every decimal shown.

What error and accuracy mean in the results

Error is the difference between the series and JavaScript's built-in value of π. Accuracy is 100% minus the error as a share of π, so it gets closer to 100% as the error shrinks.

Term counts near the 1,000,000 limit can take a moment, because the graph re-runs the sum for every point it plots. The value of π itself is used in every circle formula, such as the circle area calculator.

Questions about calculating pi

Which series gets closest to pi fastest?

Of the four here, Machin's formula. Its terms shrink by a factor of about 25 each time, so 5 terms give 3.14159268 and 10 terms match π to the 10 decimals shown.

Why is the Leibniz series so slow?

Its terms only shrink like 1/n, and they alternate in sign, so each new term overshoots in the other direction. After 1,000 terms it gives 3.1405926538, still wrong in the third decimal place.

How many digits of pi do I need?

For school problems, 3.14 or the π key on a calculator is enough. The calculator compares each series with JavaScript's built-in value of π, which is accurate to about 15 to 16 significant digits.

Sources