3 & = 1^2+1^2+1^2+0^2 \\[3pt]
31 & = 5^2+2^2+1^2+1^2 \\[3pt]
310 & = 17^2+4^2+2^2+1^2.
\end{align}$$ This theorem was proven by Joseph Louis Lagrange in 1770."
Historically, Wikipedia goes on to say that:
From examples given in the ''Arithmetica'' it is clear that Diophantus was aware of the theorem. This book was translated in 1621 into Latin by Claude Gaspard Bachet de Méziriac, who stated the theorem in the notes of his translation. But the theorem was not proved until 1770 by Lagrange.
Adrien-Marie Legendre completed the theorem in 1797–8 with his Legendre's three-square theorem, by proving that a positive integer can be expressed as the sum of three squares if and only if it is not of the form \(4^k(8m+7)\) for integers \(k\) and \(m\). Later, in 1834, Carl Gustav Jakob Jacobi discovered a simple formula for the number of representations of an integer as the sum of four squares with his own Jacobi's four-square theorem.
The formula is also linked to Descartes' theorem of four "kissing circles", which involves the sum of the squares of the curvatures of four circles. This is also linked to Apollonian gaskets, which were more recently related to the Ramanujan–Petersson conjecture.
Getting back to \(25775\), it turns out to be a member of OEIS A243580: integers of the form \(8k + 7\) that can be written as a sum of four distinct squares of the form \(m, m + 1, m + 3, m + 5\), where \(m == 2 \text{ (mod } 4) \). The particular value of \(m\) here is \(78\) so that we have:$$25775=78^2 + 79^2 + 81^2 + 83^2$$There are many proofs of the theorem and two are described in the Wikipedia article. They seem complicated and I haven't delved into them. However, what's of particular interest in the article is the number of ways in which a number can be represented as a sum of four squares, based on the sum (rather than the number) of divisors. There is a rule for the number of ways that a number can be written as a sum of two squares but this is based on powers of its prime divisors. The rule for the four squares is that the number is:
- \(8\) times the sum of the divisors of the number if it is odd and
- \(24\) times the sum of the odd divisors of the number if it is even
These numbers count squares in different positions and also include negative numbers. Thus the odd number \(1\), that has a sum of divisors equal to \(1\), has eight possible representations:
- \(1^2+0^2+0^2+0^2\) with the 1 in four possible positions
- \((-1)^2+0^2+0^2+0^2\) with the -1 in four possible positions
The number \(25775\) with a sum of \(31992\) would have a staggering \(8 \times 31992 = 255936\) possible representations as a sum of four squares. None of these representations would involve zero because \(25775\) cannot be expressed as a sum of two or three squares. It's easier to work initially with smaller numbers to begin with so let's take \(15 = 3 \times 5\) with a sum of divisors of \(24\). I've chosen \(15\) because it's equal to \(8 \times 1+7\) and thus cannot be represented as a sum of three squares. Thus \(15\) should have \(8 \times 24 = 192\) representations. This is indeed the case. However, if we don't regard different positions as being different, then there are only twelve arrangements. If we exclude negative numbers, there is only one arrangement: \(1^2+1^2+2^2+3^2\).
Moving on to \(23 = 8 \times 2+7\), there is again only one positive arrangement and that is \(1^2+2^2+3^2+3^2 \). With \(31 = 8 \times 3+7\), there are two positive arrangements: \(1^2+1^2+2^2+5^2\) and \(2^2+3^2+3^2+3^2\). Being primes, the sums of divisors of \(23\) and \(31\) are \(24\) and \(32\) respectively and so by Jacobi's theorem there are \(8 \times 24 =192\) and \(8 \times 32 = 256\) possible arrangements. It would seem that the theorem is of little practical use but interesting to explore nonetheless.