How the Pi Experiments Calculator works
π (pi) is the ratio of a circle's circumference to its diameter — an irrational, transcendental constant that cannot be written as a finite decimal or a simple fraction. Mathematicians have found many infinite series and products whose partial sums converge to π as more terms are added. This calculator lets you experiment with three classic ones — the Leibniz series, the Nilakantha series, and the Wallis product — by choosing a method and a number of terms N, then showing how close the partial result gets to the true value of π.
Formula and method
The Leibniz series comes from the arctangent series evaluated at 1: π = 4 × (1 − 1/3 + 1/5 − 1/7 + 1/9 − ...), so the calculator sums 4 × (−1)k/(2k+1) for k = 0 to N−1. The Nilakantha series starts from 3 and adds shrinking correction terms: π = 3 + 4/(2·3·4) − 4/(4·5·6) + 4/(6·7·8) − ..., alternating sign with each term. The Wallis product is an infinite product rather than a sum: π/2 = ∏n=1N (2n/(2n−1)) × (2n/(2n+1)), so the calculator multiplies N such pairs and doubles the result. In every case, using more terms (a larger N) pulls the approximation closer to π.
Why convergence speed matters
Not all three methods approach π at the same rate. The Leibniz series and the Wallis product both converge slowly — their error shrinks roughly in proportion to 1/N, so reaching one more correct decimal digit takes about 10 times as many terms. The Nilakantha series converges much faster, with error shrinking roughly like 1/N³, so it reaches far more correct digits for the same N. Try N = 1,000 with each method and compare the "correct decimal digits" result to see the difference directly.
Checking your result
The calculator always reports the absolute error (how far the partial sum or product is from Math.PI) alongside the approximation, so you can see accuracy directly rather than guessing. As N grows, the error should shrink monotonically toward zero for all three methods — if it does not, double-check that N is a positive whole number. Because the Leibniz series and Wallis product are so slow, do not expect more than 3-4 correct digits even at several thousand terms; that is expected behavior, not an error.
Applications
These experiments are a classic way to see how infinite series behave in practice: convergence rate, alternating-sign cancellation, and the trade-off between computational effort and precision. The same ideas — summing a truncated series and bounding the remainder — underlie numerical methods used throughout calculus, physics simulations, and computer arithmetic libraries that need many digits of π.