Sum of Five Squares
Calculate r5(n) - the number of ways to represent n as a sum of five squares.
Enter n (0 to 1000) to calculate r5(n)
r5(n) counts the number of ways to write n as x1^2 + x2^2 + x3^2 + x4^2 + x5^2 where the xi are integers (positive, negative, or zero) and order matters.
The Four-to-Five Bridge: r5(n) = sum_j r4(n - j^2), where j ranges over all integers with j^2 <= n. This lets us compute r5 using the simpler r4 function.
Jacobi's Four-Square Theorem: r4(n) = 8 x (sum of divisors of n that are not divisible by 4). This gives us an exact formula for four squares.
Grosswald's Asymptotic Formula: For large n, r5(n) grows proportionally to n^(3/2).
Universality: Every integer n > 33 can be expressed as a sum of five nonzero squares.
Can every positive integer be written as a sum of five squares?
Yes, every positive integer can be expressed as a sum of five squares (allowing zeros). Moreover, every integer greater than 33 can be written as a sum of five nonzero squares. This is stronger than the four-square theorem, which requires some zeros for numbers like 1, 2, 3, 5, 6, etc.
How is r5(n) computed?
The calculator uses a bridge formula: r5(n) = sum of r4(n-j^2) for all integers j with j^2 <= n. Here r4(m) uses Jacobi's formula: r4(m) = 8 times the sum of divisors of m not divisible by 4. This avoids slow enumeration and gives exact counts efficiently.
Why does r5(n) count ordered representations with signs?
r5(n) counts all ways including different orderings (1^2+0^2+0^2+0^2+0^2 vs 0^2+1^2+0^2+0^2+0^2) and different signs (1^2 vs (-1)^2). This is the standard definition in number theory, connecting to theta functions and modular forms. For distinct unordered representations, you'd divide by permutation and sign factors.
How fast does r5(n) grow?
Grosswald's asymptotic formula shows r5(n) grows proportionally to n^(3/2). More precisely, r5(n) ~ (pi^(5/2) / Gamma(5/2)) * n^(3/2) = (4/3)*pi^2 * n^(3/2). For n=1000, there are over 3 million representations, demonstrating this rapid growth.