Pi Calculator: Simple and Fun Math Tool

π/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

Worked example: Leibniz formula with only 5 terms

The Leibniz series is π/4 = 1 − 1/3 + 1/5 − 1/7 + 1/9 − ..., so π = 4 × (that alternating sum). Set terms = 5 and the calculator sums exactly five fractions:

4 × (1 − 1/3 + 1/5 − 1/7 + 1/9)
= 4 × (1 − 0.333333 + 0.2 − 0.142857 + 0.111111)
= 4 × 0.834921
= 3.339683

Compare that to the true value 3.14159265: the error is 0.198090, meaning this 5-term approximation is only about 93.69% accurate. That's the practical lesson this calculator demonstrates — Leibniz converges very slowly. Even 1,000 terms only gets you roughly 3 correct decimal digits, because each additional term only shrinks the error by about 1/n.

Why the other formulas exist

Nilakantha's series converges faster because each term is divided by a product of three consecutive numbers instead of a single odd number, shrinking error roughly as 1/n³. Machin's formula, built from arctangent series with small fractions (1/5 and 1/239), converges dramatically faster still — it's part of the family of formulas historically used to compute pi to thousands of digits by hand before computers existed.

What "accuracy" and "error" mean in the output

Error is the raw absolute difference between the computed value and JavaScript's built-in Math.PI (accurate to about 15-16 significant digits). Accuracy is expressed as a percentage: 100 minus the error as a fraction of pi, so a smaller error always pushes accuracy closer to 100%.

Performance note

Term counts near the 1,000,000 cap can take a moment to compute and redraw the convergence graph, since each formula re-runs its full summation loop for every point plotted.