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
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
| Series | Formula | After 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
- Write the first five terms: 1 − 1/3 + 1/5 − 1/7 + 1/9.
- Turn them into decimals: 1 − 0.333333 + 0.2 − 0.142857 + 0.111111.
- Add them up: 0.834921.
- Multiply by 4, because the series gives π/4: 4 × 0.834921 = 3.339683.
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
- Wikipedia: Leibniz formula for π — the alternating series π/4 = 1 − 1/3 + 1/5 − … and its slow convergence (checked October 16, 2026)
- Wikipedia: Machin-like formula — π/4 = 4 arctan(1/5) − arctan(1/239) and the arctangent series (checked October 16, 2026)