[Math] Representation as a sum of two squares

elementary-number-theorynumber theory

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!

Best Answer

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$.

Related Question