- Choose one method and keep the default inputs for your first run.
- Compare the estimate and error, then read the chart and sampled step table together.
- Load another example or copy the URL when you want to reuse the setup.
Classroom presets: use one quick demo, one series comparison, and one reproducible Monte Carlo run before changing inputs by hand.
Start with the chord of an inscribed hexagon and double the side count by recurrence. The estimate does not use a known value of pi; Math.PI is only the error reference.
Convergence chart
Read the chart with the sampled table below. The red dashed line marks the reference value of pi.
Sampled steps
| Step | Estimate | Absolute error | Relative error |
|---|
How the four approximations work
- Polygon
c₆ = 1; c₂ₙ = cₙ / √(2 + √(4 − cₙ²)); πₗₒwₑᵣ = n × cₙ / 2
Start from the chord of an inscribed hexagon and repeatedly double the side count. The estimate path does not use a known value of pi; Math.PI is used only as the error reference.- Gregory–Leibniz
π ≈ 4 × Σ (-1)ᵏ / (2k + 1)
Simple and intuitive, but extremely slow and alternating.- Nilakantha
π ≈ 3 + 4/(2·3·4) − 4/(4·5·6) + 4/(6·7·8) − …
An alternating series that improves much faster than Gregory at modest term counts.- Monte Carlo
π ≈ 4 × inside / total
Estimate the area ratio with pseudo-random points. A fixed seed reproduces the same experiment.
This page compares convergence behaviour, not equal computational cost. Sides, terms, and random points are different units of work; use Pi Algorithm Race for a speed-focused comparison.
Teacher notes
- Start with polygon when you want a geometric picture of why pi is tied to circles.
- Gregory is deliberately slow, so students can feel what “convergence” means instead of just hearing the word.
- Nilakantha is useful right after Gregory because the same idea suddenly looks much more efficient.
- Monte Carlo shows a different lesson: randomness can still move toward a stable average, but not in a perfectly smooth way.
Worksheet and boardwork prep
- Algebra worksheets
Turn “which method improved faster?” into a ready-to-print reflection prompt or exit ticket.
- Graph paper generator
Prepare hand-drawn comparison sheets when students should sketch their own convergence story.
- Quick charts
Paste a short result table and build one classroom slide or worksheet chart in a few clicks.
FAQ
Does the polygon approximation use pi to calculate pi?
No. It starts from the chord of an inscribed hexagon and uses a side-doubling recurrence. Math.PI is used only to measure the final error.
What do matching decimal places mean?
They count consecutive digits after the decimal point until the first mismatch. The leading integer 3 is not counted.
Why is Gregory–Leibniz so slow?
Its alternating terms decrease very slowly. The formula is simple, but high precision requires a very large number of terms.
Why does Nilakantha look faster than Gregory?
Its terms shrink faster, so the error usually falls much more quickly at similar term counts. A term is not an equal unit of runtime across methods.
Why does Monte Carlo fluctuate?
It estimates an area ratio from a finite pseudo-random sample. More points usually stabilise the result, but improvement is not monotonic.
What is the seed?
It is the starting state of the pseudo-random sequence. The same seed and point count reproduce the same result. Seed 0 is a valid distinct seed.
How precise is the reference value of pi?
The page uses JavaScript Math.PI, so it is limited to double precision. Matching is capped at 14 decimal places and is not arbitrary precision.
Is this a fair speed comparison?
No. Sides, terms, and points represent different amounts of work. Use Pi Algorithm Race for a speed-oriented comparison.