My first post for this mathematics blog concerned the conditions required for a number to be expressible as the sum of two squares. The date was 26th September 2015. I thought I might start revisiting some of my earlier posts just to reacquaint myself with their content. Let's consider prime numbers first. Fermat's theorem on the sums of two squares states that any prime number that is congruent to 1 modulus 4 can be expressed as a sum of two squares.
In other words, if \(p\) is a prime, then \(p=x^2+y^2\) where \(x\) and \(y\) are integers, if and only if \(p \equiv 1 \pmod{4}\). Applied to my current day count of \(24799\) (a prime), we find that \(24799 \equiv 3 \pmod{4}\) and so it cannot be written as the sum of two squares. In fact, it cannot even be written as the sum of three squares because the number can be expressed in the form \(4^a(8b+7)\) with \(a=0\) and \(b=3099\). By Legendre's 3-square theorem, such a number cannot be expressed as a sum of three squares.
Primes that can be expressed as the sum of two squares are called Pythagorean Primes.
If the number is composite, none of its \(4k+3\) primes can have an odd exponent. For example, two days ago I was \(24797\) days old and this number factorises to \(137 \times 181\). Now \(137 \equiv 1 \pmod{4}\) and \(181 \equiv 1 \pmod{4}\), so there are no \(4k+3\) primes and thus the number is expressible as a sum of two squares (in two different ways as it turns out): \(24797=59^2+146^2=74^2+139^2\).
There is a reason that \(24797\) can be expressed as a sum of squares in two different ways. Remember that its factors \(137\) and \(181\) are both primes satisfying \(p \equiv 1 \pmod{4}\) and so each can be expressed as a sum of two squares. Specifically, \(137=4^2+11^2\) and \(181=9^2+10^2\). It can easily be shown that the product of two sums of squares is equal to a sum of squares in two different ways. Here is the demonstration: $$(a^2+b^2)(c^2+d^2)=(ac-bd)^2+(ad+bc)^2=(ac+bd)^2+(ad-bc)^2$$There is an interesting history attached to this identity:
It is actually first found in Diophantus' Arithmetica (III, \(19\)), of the third century A.D. It was rediscovered by Brahmagupta (\(598\)–\(668\)), an Indian mathematician and astronomer, who generalised it (to the Brahmagupta identity) and used it in his study of what is now called Pell's equation. His Brahmasphutasiddhanta was translated from Sanskrit into Arabic by Mohammad al-Fazari, and was subsequently translated into Latin in \(1126\). The identity later appeared in Fibonacci's Book of Squares in \(1225\). Source.
However, take yesterday's number \(24798=2 \times 3 \times 4133\). Clearly, \(3\) is a \( 4k+3\) prime raised to an odd power and so \(24798\) cannot be expressed as sum of two squares. As it happens, \(4133 \equiv 1 \pmod{4}\) but that doesn't matter because \(3\) has already ruined things.