Spock’s π Gambit — TNT Interactive

Compute π

The Gregory-Leibniz series in motion — drag the slider and watch it converge.
Inspired by Spock’s trap for Redjac in “Wolf in the Fold” (Star Trek, 1967)

About this simulation — the Gregory-Leibniz series

In the Star Trek episode “Wolf in the Fold” (1967), Spock defeats an evil entity that has possessed the Enterprise computer by ordering it to “compute to the last digit the value of pi.” Since π is irrational — its decimal expansion is infinite and non-repeating — there is no last digit. The computer runs forever. Redjac is trapped.

This simulation uses the Gregory-Leibniz series, one of the simplest infinite series for π:

π = 4 × (1 − 1/3 + 1/5 − 1/7 + 1/9 − …)

Drag the slider to add more terms. Watch the approximation oscillate above and below π, getting closer each time — but never arriving. That is the asymptotic convergence Spock relied on.

Watch the clip  •  Series tutorial  •  S.P.A.R.K. Chat Log

Terms: 50
The Math Behind the π
Terms (n):
Series approx:
True π (JS Math.PI):
Absolute error:
Error bound (4/2n+1):