Lagrange's four-square theorem states that every natural number can be written as the sum of four squares, allowing for zeros in the sum (e.g. $6=2^2+1^2+1^2+0^2$). Is there a similar result in which zeros are not allowed in the sum? For example, does there exist $n\in\mathbb{N}$ such that every natural number greater than $n$ can be written as the sum of five non-zero squares, or six non-zero squares, for example?
[Math] Integers which are the sum of non-zero squares
elementary-number-theorynumber theory
Related Solutions
The modular forms explanation is basically due to the fact that $3$ is odd and so the generating function for representations of sums of three squares is a modular form of half-integer weight.
In general if $r_k(n)$ is the number of representations of $n$ as a sum of $k$ squares then $$\sum_{n=0}^\infty r_k(n)q^n=\theta(z)^k$$ where $q=\exp(\pi i z)$ and $$\theta(z)=1+2\sum_{n=1}^\infty q^{n^2}.$$ Then $f_k(z)=\theta(z)^k$ is a modular form of weight $k/2$ for the group $\Gamma_0(4)$. This means that $$f_k((az+b)/(cz+d))=(cz+d)^{k/2}f_k(z)$$ whenever the matrix $\begin{pmatrix}a&b\\\\c&d\end{pmatrix}$ lies in $\Gamma_0(4)$, that is $a$, $b$, $c$ and $d$ are integers, $4\mid c$ and $ad-bc=1$.
This definition is easy to understand when $k$ is even, but for odd $k$ one needs to take the correct branch of $(cz+d)^{k/2}$, and this is awkward. The space of modular forms of weight $k/2$ is finite-dimensional for all $k$, and is one-dimensional for small enough $k$. For these small $k$ the space is spanned by an "Eisenstein series". Computing the Eisenstein series isn't too hard for even $k$, but is much nastier for odd $k$ where again square roots need to be dealt with. See Koblitz's book on modular forms and elliptic functions for the calculation for $k\ge5$ odd. The calculation for $k=3$ is even nastier as the Eisenstein series does not converge absolutely. In fact the cases where $k$ is divisible by $4$ are even easier, as even weight modular forms behave nicer.
For large $k$, Eisenstein series are no longer enough, one needs also "cusp forms". While fascinating, cusp forms have coefficients which aren't given by nice formulae unlike Eisenstein series.
Of course there is a formula for $r_3(n)$, due to Gauss in his Disquisitiones Arithmeticae. It involves class numbers of quadratic fields (or to Gauss numbers of classes of integral quadratic forms).
Similar to the Brahmagupta-Fibonacci two-square identity. Euler has a four square identity which involves the sum of 4 squares:
$$(a_1^2+a_2^2+a_3^2+a_4^2)(b_1^2+b_2^2+b_3^2+b_4^2) =\\ \quad(a_1b_1 - a_2b_2 - a_3b_3 - a_4b_4)^2 + (a_1b_2+a_2b_1+a_3b_4-a_4b_3)^2 +(a_1b_3 - a_2b_4 + a_3b_1 + a_4b_2)^2 + (a_1b_4 + a_2b_3 - a_3b_2 + a_4b_1)^2$$
Factor $1638$ as products of any small factors you know how to represent as sum of 4 squares. Repeat apply the formula will allow you to represent $1638$ itself as sum of 4 squares.
For example, let's say we have factored $1638$ as $2\cdot 3^2 \cdot 7 \cdot 13$, we have:
$$\begin{align} & 2\cdot 3^2 \cdot 7 \cdot 13\\ = & (1^2+1^2+0^2+0^2)(1^2+1^2+1^2+0^2)^2(2^2+1^2+1^2+1^2)(3^2+2^2+0^2+0^2)\\ = & (0^2 + 2^2 + 1^2 + 1^2)(1^2+1^2+1^2+0^2)(2^2+1^2+1^2+1^2)(3^2+2^2+0^2+0^2)\\ = & ((-3)^2 + 1^2 + 2^2 + 2^2)(2^2+1^2+1^2+1^2)(3^2+2^2+0^2+0^2)\\ = & ((-11)^2+(-1)^2+2^2 + 0^2)(3^2+2^2+0^2+0^2)\\ = & ((-31)^2 + (-25)^2 + 6^2 + 4^2)\\ \end{align}$$
This give you a non-trivial representation of $1638$ as $31^2 + 25^2 + 6^2 + 4^2$.
In general, there are many representations of a number as a sum of 4 squares. There is a theorem:
The total number of representations of a positive integer $n$ as the sum of four squares, representations that differ only in order and sign being counted as distinct, is eight times the sum of the divisors of $n$ that are not multiple of $4$.
The above representation is only $1$ out of $8 \sum_{d\mid 1638, 4 \nmid d} d = 34944$ ways of representing $1638$ as sum of 4 squares.
Best Answer
This question is answered in "Introduction to Number Theory" by Niven, Zuckerman& Montmogery (pp.318-319 of the fifth edition). I summarize their proof below.
Every integer $\geq 34$ is a sum of five positive squares (while $33$ is not). The number five is optimal, because the only representation of $2^{2r+1}$ as a sum of four squares is $0^2+0^2+(2^r)^2+(2^r)^2$ (easy exercice by induction on $r$).
One can check by hand by noting all the numbers between $34$ and $169$ are sums of five positive squares. Now, let $n\geq 169$ and let us show that $n$ is a sum of five positive squares.
We know that $n-169$ is a sum of four not necessarily positive squares, $n-169=x_1^2+x_2^2+x_3^2+x_4^2$ and we can assume $x_1 \leq x_2 \leq x_3 \leq x_4$.
If $x_1>0$, writing $n=13^2+x_1^2+x_2^2+x_3^2+x_4^2$ we are done. So assume $x_1=0$.
If $x_2>0$, writing $n=5^2+12^2+x_2^2+x_3^2+x_4^2$ we are done. So assume $x_2=0$.
If $x_3>0$, writing $n=3^2+4^2+12^2+x_3^2+x_4^2$ we are done. So assume $x_3=0$.
If $x_4>0$, writing $n=2^2+4^2+7^2+12^2+x_4^2$ we are done. So assume $x_4=0$.
So now all the $x_i$ are zero, and $n=169=5^2+6^2+6^2+6^2+6^2$. This concludes the proof.