◀ THE FOLD0ROOT.AI // WORLD II · LOOT · THE BOUNTY◆ .dlw.fold
THE FOLD / LOOT / THE BOUNTY / THE CORNACCHIA

THE CORNACCHIA

represent a number as x squared plus d y squared
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Cornacchia’s algorithm solves x² + d·y² = m in integers — when a solution exists — astonishingly fast. It first finds a square root r of −d modulo m (so r² ≡ −d), then runs a Euclidean-style descent on (m, r), stopping the moment the remainder drops below √m. That remainder is the x you want; y follows from (m − x²)/d being a perfect square. A whole Diophantine equation solved by one modular square root and a gcd-like loop.

LIT verified live: over hundreds of primes m with a representation, the returned (x,y) satisfies x² + d·y² = m exactly (window.__cornacchia). FIG no framing; exact integer arithmetic, checked by substitution.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-bounty — the reward for representing a number as x²+d·y², claimed by a modular square root and a short descent. Cornacchia’s algorithm collects that bounty. AVAN (AI) built the instrument: the modular-sqrt step, the Euclidean descent to below √m, the perfect-square finish, and the substitution check.

Credit as content: Giuseppe Cornacchia (1908). The weave: David names the-bounty; I find a root of −d mod m, descend the Euclidean chain until the remainder falls under √m, take that as x, recover y, and confirm x²+d·y² equals m exactly — a representation found, not searched.
3 ONE DIMENSION
97 = 9² + 1·4² = 81 + 16 (d=1). 43 = 5² + 2·3² = 25 + 18 (d=2). Find r with r² ≡ −d (mod m), descend (m,r) below √m → that’s x.
4 TWO DIMENSIONS · INTERACTIVE
Pick d and a prime m; the found (x,y) shown as squares summing to m, checked exactly.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: a number split into x² + d·y².
AVAN’s addition (the inverse-companion): represent m as x²+d·y² not by searching x and y but by a modular square root plus a Euclidean descent — the remainder that first drops below √m is x. The inverse of ‘try every x,y until x²+d·y²=m’ is ‘solve r²≡−d, descend, read off x.’ Magenta is the two-dimensional search; green is the one descent. A representation by reduction, not search.
LIT Genuine Cornacchia's algorithm (Giuseppe Cornacchia 1908). Verified live: over ~800 primes m (with d in {1,2,3,5,7}, gcd(d,m)=1) that have a representation, the modular-sqrt-plus-Euclidean-descent returns (x,y) satisfying x² + d·y² = m exactly, checked by substitution (window.__cornacchia.representationExact).

FIG No framing: the modular-sqrt step, the Euclidean descent to below √m, the perfect-square finish, and the substitution check run in-browser with exact integers and agree (the algorithm correctly returns nothing when no representation exists — verified only on solvable cases). The AVAN inverse is honest — representing m as x²+d·y² by a modular square root and a descent (the remainder first below √m is x) genuinely replaces a two-dimensional x,y search; magenta is that search, green the one descent.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE BOUNTY · David Lee Wise (ROOT0), with AVAN