# Can a prime of form $4m+1$ be expressed as sum of 2 squares in more than one way?

It is easy to find dozens of proofs (some of which are elementary or easy to follow) that every prime of the form $$4m+1$$ can be expressed as the sum of two squares.

How can one prove that every prime of the form $$4m+1$$ can be expressed as the sum of two squares $$p = a^2 + b^2 | a,b \in \Bbb Z^+, a>b$$ in only one way?

This is easy to verify for primes up to quite a large value but I can't find a proof.

• Most elementary texts on number theory prove this. – Lord Shark the Unknown Nov 20 '18 at 20:28
• @mathnoob $3$ is not of the from $4m+1$ – saulspatz Nov 20 '18 at 20:38
• very nice discussion of this, also for $mx^2 + ny^2$ with $m,n$ positive and coprime, by Brillhart zakuski.utsa.edu/~jagy/Brillhart_Euler_factoring_2009.pdf – Will Jagy Nov 20 '18 at 20:43
• @Will Jagy - Thanks for that reference - very enlightening. – marty cohen Nov 20 '18 at 20:52
• @will Jagy yes that answers the question. I have +1 the comment but if you put the proof as an answer it will bury this question; otherwise, perhaps I will do so maybe tomorrow. – Mark Fischler Nov 20 '18 at 20:57

Denote by $$p$$ a prime number of the form $$4m+1$$. Thus $$p\equiv 1\pmod 4$$ Assume that $$p={a^2}+{b^2}={c^2}+{d^2}$$ for some $$a,b,c,d\in\mathbb {N}$$ such that, w.l.o.g. $$a>b$$ and $$c>d$$. Our aim is now to show by contradiction, that this follows to $$a=c$$ and $$b=d$$:
We now have $$(ad-bc)(ad+bc)={a^2}{d^2}-{b^2}{c^2}=\bigl(p-{b^2\bigr)}{d^2}-{b^2}\bigl(p-{d^2\bigr)}=p\bigl({d^2}-{b^2}\bigr)\equiv 0\pmod p$$ This implies (see Euclid's lemma) that either $$p|(ad-bc)$$ or $$p|(ad+bc)$$
Let's suppose $$p\mid(ad+bc)$$. Hence $${a^2},{b^2},{c^2},{d^2}. Thus $$a,b,c,d<\sqrt{p}$$, which implies that $$0 That leads to $$ad+bc=p$$. However $${p^2}=\Bigl({a^2}+{b^2}\Bigr)\Bigl({c^2}+{d^2}\Bigr)={(ad+bc)^2}+{(ac-bd)^2}={p^2}+{(ac-bd)^2}$$ $$\Rightarrow ac-bd=0$$ which, nevertheless, contradicts the assumption that $$a>b$$ and $$c>d$$. This shows, that $$p\nmid ({ad+bc})$$.
This implies $$p\mid ({ad-bc})$$. Analugously $$a,b,c,d<\sqrt{p}$$ which implies that $$-p Hence $$a\mid {bc}$$. Note however, that since $$p={a^2}+{b^2}$$, $$a$$ and $$b$$ have to be coprime, so $$a\mid{c}$$ Let $$c=xa$$. Since $$ad=bc$$, it follows that $$d=xb$$
We finally have $$p={a^2}+{b^2}={c^2}+{d^2}={x^2}\bigl({a^2}+{b^2}\bigr)\Rightarrow x=1$$ $$\Rightarrow c=a\quad d=b$$