# Representation as a sum of two squares

Recently, I have been wandering that what natural numbers can can be written as a sum of squares of two coprime positive integers in two different ways, order being irrelevant, or with the help of notations,

Find all natural numbers $a,b,c,d,n$ such that $$n=a^{2}+b^{2}=c^{2}+d^{2}$$ where gcd$(a.b)$$=gcd(c,d)$$=1$ and $a\lt c \lt d \lt b$.

My little progress: The prime decomposition of $n$ must look like $2^{a_1}p_2^{a_2}...p_r^{a_r}$ where $a_1 \in \{0,1\}$ and the $p_i$ 's are primes of the form $4k+1$.
Proof: Suppose there existed a prime $p \equiv 3 \pmod 4$ in the prime decomposition of $n$, then we would have $a^2+b^2 \equiv 0 \pmod p$. But then we would have $a\equiv b \equiv 0 \pmod p$, contradicting gcd$(a,b)$$=1 (For , if a \not \equiv 0 \pmod p, then (a,p)=1 and hence \exists c such that ac \equiv 1 \pmod p wherefrom we see that (ac)^2+(bc)^2 \equiv 0 \pmod p and the contradiction 1+(bc)^2 \equiv 0 \pmod p). Also, if 4|n, then gcd(a,b)$$=1$ forces us to conclude that both $a$ and $b$ are odd but then $0 \equiv a^2+b^2 \equiv 2 \pmod 4$. Contradiction!

-
Changing the question after an answer's posted isn't so nice. You can always add a question though. – Zev Chonoles Feb 21 '14 at 15:09
I am sorry @ZevChonoles, actually I wanted this question to be answered and expected it to be in the negative. It is my bad that I should have experimented, nonetheless I've upvoted you. – Indrayudh Roy Feb 21 '14 at 15:14
The condition that you give is required for any number to be representable as a sum of squares of coprime positive integers in just one way itself! – Singhal Feb 21 '14 at 15:18
Yeah, I've seen that. – Indrayudh Roy Feb 21 '14 at 15:20

We give an answer to a generalization of the problem, but without proof. The easiest proof uses facts about the factorization of Gaussian integers.

Note that if $n$ is divisible by $4$ or by a prime of the form $4k+3$, then $n$ has no representation as a sum of relatively prime squares. So we can assume that $n$ is of the form $n=p_1^{a_1}p_2^{a_2}\cdots p_s^{a_s}$ or $n=2p_1^{a_1}p_2^{a_2}\cdots p_s^{a_s}$. where the $p_i$ are distinct primes all of the form $4k+1$.

Let $n\gt 2$. Then the number of essentially distinct representations of $n$ as a sum of two relatively prime squares is $2^{s-1}$. In particular, $n$ has exactly $2$ essentially distinct representations as a sum of two relatively prime squares if and only if $s=2$.

-
Is there any elementary proof of this fact...because I know nothing about the Gaussian integers. – Indrayudh Roy Feb 22 '14 at 16:01
Yes, there is nothing very hard about it, but it takes some writing to put the pieces together. In teaching elementary number theory, I have sometimes given both proofs. – André Nicolas Feb 22 '14 at 16:35
You are free to give me any hints, so I can try by myself, only hints please. – Indrayudh Roy Feb 22 '14 at 16:39
It is far too long. A useful device for producing a representation of $xy$ from representations of $x$ and $y$ is the easily verified identity $(a^2+b^2)(c^2+d^2)=(ac+bd)^2 +(ad-bc)^2$. – André Nicolas Feb 22 '14 at 16:44
But that does not guarantee coprimality...for if $a,b,c,d$ are all odd then both $ac+bd$ and $ad-bc$ are even. – Indrayudh Roy Feb 22 '14 at 16:48

We have $$65=1^2+8^2=4^2+7^2.$$ I chose this number because it is a product of two different prime numbers ($5$ and $13$) that are each congruent to $1$ mod $4$ (hence each expressible as a sum of two different squares); indeed, $65$ is the smallest such number.

You can also see that $$85=5\cdot 17=2^2+9^2=6^2+7^2$$ $$221=13\cdot 17=5^2+14^2=10^2+11^2$$ I haven't quite thought about which other numbers might be able to be expressed this way, but I am pretty sure that some simple manipulations with Fermat's two-squares theorem (Wikipedia) will show that any product of two different primes each congruent to $1$ mod $4$ is expressible this way. (I have to go to class now, so I can't do those manipulations myself right now.)

-
sent you nice short article on this from the MAA Monthly – Will Jagy Feb 21 '14 at 16:12
@Will: Thanks for the interesting read :) – Zev Chonoles Feb 22 '14 at 23:10