Mathwords logoMathwords

Jacobi's Four-Square Theorem — Definition, Formula & Example

Jacobi's Four-Square Theorem is a formula that tells you exactly how many ways a positive integer can be written as a sum of four squares of integers. Different orders and signs count as different ways, and zeros are allowed.

For a positive integer nn, let r4(n)r_4(n) be the number of ordered quadruples (x1,x2,x3,x4)∈Z4(x_1, x_2, x_3, x_4) \in \mathbb{Z}^4 with x12+x22+x32+x42=nx_1^2 + x_2^2 + x_3^2 + x_4^2 = n. Then r4(n)=8∑k∣n, 4∤kkr_4(n) = 8\sum_{k \mid n,\ 4 \nmid k} k. Equivalently, r4(n)=8σ(n)r_4(n) = 8\sigma(n) when nn is odd, and r4(n)=24σ(m)r_4(n) = 24\sigma(m) when nn is even, where mm is the largest odd divisor of nn and σ\sigma is the sum-of-divisors function.

Key Formula

r4(n)=8∑k∣n4∤kkr_4(n) = 8\sum_{\substack{k \mid n \\ 4 \nmid k}} k
Where:
  • r4(n)r_4(n) = Number of ordered, signed representations of n as a sum of four integer squares
  • nn = The positive integer being represented
  • kk = A positive divisor of n that is not a multiple of 4

Worked Example

Problem: Use Jacobi's Four-Square Theorem to find r4(4)r_4(4), the number of ways to write 4 as a sum of four integer squares. Then check the answer by listing the representations directly.
Step 1: List the positive divisors of 4. Drop any divisor that is a multiple of 4, then add the ones that remain.
divisors of 4:1,2,41+2=3\text{divisors of } 4: 1, 2, \cancel{4} \qquad 1 + 2 = 3
Step 2: Multiply the sum by 8.
r4(4)=8⋅3=24r_4(4) = 8 \cdot 3 = 24
Step 3: Check by counting. The pattern 22+02+02+022^2 + 0^2 + 0^2 + 0^2 has 4 positions for the 2 and 2 signs, giving 8 quadruples. The pattern 12+12+12+121^2 + 1^2 + 1^2 + 1^2 has 2 sign choices in each of 4 slots, giving 16 quadruples. No other patterns work.
4⋅2+24=8+16=244 \cdot 2 + 2^4 = 8 + 16 = 24
Answer: r4(4)=24r_4(4) = 24. The direct count of 8 + 16 quadruples agrees with the formula.

Why It Matters

Every positive integer has at least the divisor 1, which is not a multiple of 4. So r4(n)≥8r_4(n) \geq 8, and Jacobi's formula therefore proves Lagrange's Four-Square Theorem: every positive integer is a sum of four squares. Jacobi proved it in the 1820s using theta functions. It is now a standard first application in courses on modular forms and analytic number theory.

Common Mistakes

Mistake: Adding every divisor of n, including multiples of 4. For n=4n = 4 this gives 8(1+2+4)=568(1 + 2 + 4) = 56 instead of 2424.
Correction: Exclude divisors divisible by 4 before summing. You can also use the shortcut for even n: take 24 times the divisor sum of the odd part of n. For n = 4, that is 24 times 1, which equals 24.

Related Terms