← Math & statistics

Pi Algorithm Race

Compare four ways to compute pi under the same stated condition. Fixed time gives each algorithm its own equal budget; fixed decimal digits measures the first time each method reaches the same accuracy target.

This is an educational benchmark in your current browser and on your current device. Algorithms run one after another, and the time budget applies separately to each algorithm. With four algorithms and a 1,000 ms budget, the whole run normally takes about four seconds or more. Browser load and timer scheduling can change the timing, so the result is not a universal ranking.

For the learning-first version, start with Pi Approximation Explorer. This page is for side-by-side comparison. When you need a practical decimal string at the end, continue to Pi Digits Generator.

Other languages 日本語 | English | 简体中文 | 繁體中文 | 繁體中文(香港) | Español | Português (Brasil) | Français | Italiano
3 quick steps
  1. Choose a race mode, keep all four algorithms on, and run the default target once.
  2. Check the winner card, then compare the chart and table together instead of reading one number in isolation.
  3. Load another sample or copy the URL when you want to reuse the same classroom setup.

Classroom presets: start with one all-method race, then switch to a small fixed-digits comparison for discussion.

Race mode

Use the same time budget for every algorithm and compare the number of matching digits reached.

Lower values produce denser chart points. Higher values reduce noise in the log and CSV.

Algorithms

Keep all four selected for the clearest comparison. Remove one only when you want to focus on a specific gap.

Winner
Best digits reached
Fastest to target
Compared algorithms
Mode
Target time
Winner estimate

Race chart

The chart uses elapsed time on the x-axis and matching digits on the y-axis. It is meant for trend reading, not for claiming exact performance on every device.

Comparison table

Final results for the four pi algorithms
Algorithm Estimate Absolute error Matching decimals Iterations Wall ms Compute ms Status

Four methods and comparison limits

Calculations run in this browser. Shared URLs contain settings only and never auto-run. See the privacy policy for site measurement details. (privacy policy)

The chart and CSV contain sampled points at the selected interval plus one guaranteed final point for every algorithm.

Teacher notes

Worksheet and slide prep

FAQ

Is a 1,000 ms fixed-time budget the total duration of the whole race?

No. The budget is applied separately to every selected algorithm, and the algorithms run sequentially. Four algorithms with a 1,000 ms budget normally take about four seconds or more in total.

How are a winner, a tie, and no target reached determined?

Fixed time first selects the highest matching-decimal accuracy and then the smallest absolute error; methods whose accuracy and comparison error are equivalent are tied. Fixed decimal digits considers only algorithms that reached the target; if none did, there is no winner and the closest method is shown instead.

What are matching decimal digits?

The integer 3 is not counted. The value reports how many digits after the decimal point agree continuously with the reference pi under the documented rounding rule, up to the safe JavaScript Number limit.

Does an absolute error of zero mean the exact mathematical value of pi was found?

No. It means the estimate rounded to the same double-precision value as Math.PI. The mathematical error relative to the true irrational number is not zero.

Does a smaller iteration count always mean a more efficient algorithm?

No. One Gregory term, one Machin update, and one Chudnovsky term have different computational costs and add different amounts of information. Treat iterations as progress within each method.

Why is Gregory slow while Chudnovsky is fast?

Gregory improves only a little per term, whereas Chudnovsky is designed to add many correct digits per term. Browser implementation and device performance still affect elapsed time.

Will another device or browser produce the same winner?

Not necessarily. CPU speed, browser engine, tab load, power mode, timer resolution, and scheduling can change timing. Use the page to study convergence trends rather than claim a universal benchmark.

What is saved when I stop, share the URL, or export CSV?

Stop creates a consistent snapshot marked as incomplete. The URL shares normalized settings without auto-running. CSV contains sampled points plus one guaranteed final row and status for every algorithm.