◄ WORLD V · SONNY 5DART 057 · a helldive at the net

GAUSS-LEGENDRE pi, its digits doubling

Take the average of two numbers and their geometric mean, again and again; they rush together astonishingly fast. Feed the right starting pair and that arithmetic-geometric mean spits out π — with the count of correct digits doubling every step. It is the algorithm behind record π computations, and its engine is a square root at huge precision — which the campaign just built for I-13.

THE TECHNIQUE a ← (a+b)/2, b ← √(ab), correct π

Start a=1, b=1/√2, t=¼, p=1. Each step: a becomes their average, b becomes their geometric mean √(ab), and t, p track a correction. Then π ≈ (a+b)² / 4t. The convergence is quadratic — the number of correct digits doubles each iteration (1, 3, 8, 19, 41, …). Watch it, and watch an ordinary f64 run out of room. live demo

HISTORY & CREDIT named for the dead, found by the living, and one forgotten

Called “Gauss-Legendre” — yet neither Gauss nor Legendre ever wrote it as a π algorithm, and a 1924 predecessor is almost never named. cited

1785 / 1799 · Lagrange had the AGM iteration; Gauss rediscovered it and (diary, May 1799) saw it “will certainly open up a new field of analysis” — elliptic functions. Legendre supplied the relation between elliptic integrals.
1924 · Louis V. King states essentially this π-from-AGM formula — a ~50-year priority almost always omitted from the name.
1975–76 · Richard Brent (ANU, J. ACM) and Eugene Salamin (Math. Comp.) independently assemble it into a quadratic π algorithm — a clean, well-documented co-discovery.
records · Kanada’s group used it for billions of digits; only ~30 iterations reach a billion, so the cost is each step’s full-precision multiply and square root.

Gauss had every piece and never built the algorithm; the name honours the identities, not the π machine. Gauss/Legendre-Lagrange, King, Brent-Salamin

RECOMMEND FOR I-13 names a wall — and the campaign half-crosses it in the same breath

The demo above is f64, so it stalls near 15 digits at iteration 3. To go further needs bignum — and a square root at bignum precision. So this dart, first, surfaces the want:

$ i13 run bignum_isqrt.i13 # integer sqrt over bignum, written IN I-13 (no compiler change) isqrt(10^36) = 1000000000000000000 isqrt(2*10^36) = 1414213562373095048 # = floor(sqrt(2)*10^18), exact
Recommend: a want named and half-filled at once. The AGM’s once-per-step √(ab) is the load-bearing primitive f64 lacks at scale; the campaign just added std/bignum_isqrt.i13 (Newton’s integer method over the existing bignum — no interpreter change) — suggestion-box PS-012, landed. The remaining piece is fixed-point reals (scaled integers) to carry π’s fractional part — box PS-013, open. With both, Gauss-Legendre runs to arbitrary digits in pure I-13.
The loop: a dart names a wall, the stdlib clears half of it, the box records both — the corpus revising itself in one move.