← Math & statistics

Pi Approximation Explorer

Compare four ways to approach pi using estimates, errors, matching decimal places, a convergence chart, and a sampled table. The methods cover geometry, alternating series, and reproducible pseudo-random simulation.

Runs locally in your browser. Use the shareable URL to reopen the same classroom example later.

Ready to compare speed under the same target? Open Pi Algorithm Race. Need a practical decimal output after that? Use Pi Digits Generator.

Other languages 日本語 | English | 简体中文 | 繁體中文 | 繁體中文(香港) | Español | Português (Brasil) | Français | Italiano
3 quick steps
  1. Choose one method and keep the default inputs for your first run.
  2. Compare the estimate and error, then read the chart and sampled step table together.
  3. 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.

Polygon

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.

Choose 6 to 12,288 sides. Each option doubles the previous side count.

Estimate
Reference pi
Absolute error
Relative error
Matching digits
Input summary

Convergence chart

Read the chart with the sampled table below. The red dashed line marks the reference value of pi.

Sampled steps

Sampled convergence steps for the selected method
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

Worksheet and boardwork prep

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.