# How to prove that all primes of the form $4k+1$ can be represented by the sum of two squares in only one way regardless of the order?

I am reading a book about Number Theory as a new learner.

The book has proved that all primes of the form $4k+1$ can be represented by the sum of two squares.

This question is given as exercise and I truly have no idea for the solution.

The only thing that I found may be helpful is that one of the squares is even and one is odd.

Thanks for any help ^_^

Edit: About duplication, I suppose that question is about the process in a specified proof.

Will Jagy has given a complete proof.

Thanks so much for the answer!

• – Peter Jul 18 '18 at 13:38
• It would help to know what sort of proof the book gave of the existence. For example, if it's based on the fact that the Gaussian integers $\mathbb{Z}[i]$ are a PID, then the uniqueness just follows from the fact that if $a^2 + b^2 = p$ is prime then $a+bi$ is irreducible in $\mathbb{Z}[i]$. So if $c^2 + d^2 = p$ also then $c+di$ must be a unit times either $a+bi$ or $a-bi$... – Daniel Schepler Jul 18 '18 at 23:11

Let us have positive integers with $$n = a^2 + b^2 = c^2 + d^2$$ with $a,c$ odd, then $b,d$ even, also $b < d$ and $a > c.$ So these are two genuinely distinct ways of writing $n.$
$$(a-c)(a+c) = (d-b)(d+b).$$ Define $$r = \gcd(a-c, d-b)$$ Note that $r$ is even. Next we define $$a-c = rs \; , \; \; \; d-b = r t \; ,$$ so that $$\gcd(s,t) = 1.$$ Note that at least one of $s,t$ is odd. This gives us $$(a+c)s = (d+b)t.$$ The gcd property tells us that $t | (a+c).$ We define $u$ with $$a+c = t u.$$ We immediately conclude $d+b = s u.$ As $a+c, d+b$ are even, but at least one of $s,t$ is odd, we find $u$ is even.
In one line, $$\color{magenta}{ a-c = rs \; , \; \; a+c = tu \; , \; \; d-b = rt \; , \; \; d+b = su \; }.$$ If we now solve for $a$ and $b$ and square and combine, we get $$a = \frac{1}{2}(rs+tu) \; , \; \; \; b = \frac{1}{2}(su-rt) \; ,$$ $$a^2 + b^2 = \frac{1}{4}\left( r^2 s^2 + r^2 t^2 + u^2 s^2 + u^2 t^2\right) = \frac{1}{4}\left( r^2 + u^2 \right) \left( s^2 + t^2 \right)\; ,$$
$$\color{magenta}{ n = a^2 + b^2 = c^2 + d^2 = \left( \left(\frac{r}{2}\right)^2 +\left(\frac{u}{2}\right)^2 \right) \left(s^2 + t^2 \right) } .$$ That is to say, because $n$ had two distinct representations as the sum of two squares, it is composite.
The contrapositive is that a number $4k+1$ with just one expression as the sum of two nonzero squares is prime. It is probably worth pointing out that this is the contrapositive in the setting of having at least one representation. We are not making any conclusions about numbers that have no representation as the sum of two squares.
• Did you mean converse in the last sentence? Note that for example, 9 has essentially only $3^2 + 0^2$ as a representation as a sum of two squares, yet 9 is not prime. – Daniel Schepler Jul 19 '18 at 0:33
• @DanielSchepler I will need to think about it. What I wrote is just about two representations with nonzero $a,b,c,d,$ so is silent about some issues. – Will Jagy Jul 19 '18 at 0:36