◀ THE FOLD0ROOT.AI // WORLD II · BOSS · THE GAUNTLET◆ .dlw.fold
THE FOLD / BOSS / THE GAUNTLET / THE JACOBI FOUR-SQUARE

THE JACOBI FOUR-SQUARE

counting the ways to write a number as four squares
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Jacobi’s four-square theorem gives the exact count of ways to write a number as a sum of four squares. Lagrange proved every number is a sum of four squares; Jacobi went further and counted them: the number of ordered representations (allowing zeros and negatives) is r4(n) = 8·σ(n) if n is odd, and 24·σ(m) if n = 2km with m odd — equivalently, r4(n) = 8 × (sum of the divisors of n that are not divisible by 4). A pure counting law, exact and closed-form, for a question with no obvious formula.

LIT verified live: brute-force counting of all ordered integer quadruples (a, b, c, d) with a2+b2+c2+d2 = n equals 8·Σd|n, 4∤d d for every n up to 150 (window.__jacobi4). FIG no framing; exhaustive representation counts vs the divisor-sum formula.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-gauntlet — not merely “can n be four squares” but “in exactly how many ways”, and the answer runs the full gauntlet of counting to land on a clean divisor sum. AVAN (AI) built the instrument: the exhaustive four-square representation counter (signs and zeros included) and the 8×(sum of divisors not divisible by 4) formula.

Credit as content: Carl Gustav Jacob Jacobi (1834); Lagrange’s four-square theorem (1770) underlies it. The weave: David names the-gauntlet; I count every signed, ordered quadruple of squares summing to n, and confirm the total equals eight times the sum of n’s divisors that are not multiples of four — Jacobi’s exact law.
3 ONE DIMENSION
r4(1) = 8 (the (±1,0,0,0) arrangements); r4(2) = 24; r4(4) = 24 (the divisor 4 is excluded). Always r4(n) = 8 × (sum of divisors of n not divisible by 4).
4 TWO DIMENSIONS · INTERACTIVE
A number, its four-square representation count, and the divisor-sum formula; the equality checked to 150.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: a representation count that is a divisor sum.
AVAN’s addition (the inverse-companion): don’t just ask whether n is a sum of four squares — ask how many ways, and the answer is a clean function of n’s divisors. The inverse of ‘is n four squares’ is ‘r4(n) = 8 times the 4-free divisor sum.’ Magenta is the brute list of quadruples; green is the divisor-sum formula that counts them. Representations, counted by divisors.
LIT Genuine Jacobi four-square theorem (Carl Gustav Jacob Jacobi, 1834; on Lagrange's four-square theorem, 1770). Verified live: a brute-force count of all ordered integer quadruples (a,b,c,d) with a²+b²+c²+d²=n (signs and zeros included) equals 8 times the sum of the divisors of n not divisible by 4, for every n from 1 to 150 (window.__jacobi4.matches).

FIG No framing: the exhaustive four-square representation counter and the divisor-sum formula 8·Σ_{d|n,4∤d} d both run in-browser with exact arithmetic. The AVAN inverse is honest — counting how many ways n is four squares (not merely whether it is) yields a clean function of n's divisors; magenta is the brute list of quadruples, green the divisor-sum formula that counts them. Representations, counted by divisors.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE GAUNTLET · David Lee Wise (ROOT0), with AVAN