## Unique Square Sum

#### Problem

You are given that ALL primes that are one more than a multiple of 4 can be written as the sum of two squares. For example, 13 = 2^{2}+3^{2}.

Assuming that a prime is expressible as the sum of two squares, prove that it can be done in only one way.

#### Solution

Suppose that the prime, `p` = `a`^{2}+`b`^{2} = `c`^{2}+`d`^{2}.

Clearly HCF(`a`,`b`)=1, otherwise `a`^{2}+`b`^{2} would be composite; similarly HCF(`c`,`d`)=1.

We will begin by establishing a result that will be used later.

If `ad` = `bc` then `a`|`bc`, but as HCF(`a`,`b`)=1, `a`|`c`. Let `c` = `ka`.

`ad` = `kab` `d` = `kb`.

So `p` = `c`^{2}+`d`^{2} = (`ka`)^{2}+(`kb`)^{2} = `k`^{2}(`a`^{2}+`b`^{2}).

And because of the initial supposition, it is necessary that `k` = 1. Hence `c` = `ka` = `a` and `d` = `kb` = `b`.

By the symmetry of our initial supposition, from `ad` = `bc` we can freely interchange `c` and `d` to get `ac` = `bd`. And in the same way we can show that `c` = `b` and `d` = `a`.

Hence our proof will be complete if we can show that either `ad` = `bc` or `ac` = `bd`.

From the initial supposition, `p` = `a`^{2}+`b`^{2} = `c`^{2}+`d`^{2}, we can write:

`a`^{2} = `p``b`^{2} and `d`^{2} = `p``c`^{2}.

`a`^{2}`d`^{2} = (`p``b`^{2})(`p``c`^{2}) = `p`^{2}`p`(`b`^{2}+`c`^{2})+`b`^{2}`c`^{2}

`a`^{2}`d`^{2} `b`^{2}`c`^{2} mod `p`

`ad` `bc` mod `p`

So either (i) `ad``bc` 0 mod `p`, or (ii) `ad`+`bc` 0 mod `p`.

As 0 `a`^{2}, `b`^{2}, `c`^{2}, `d`^{2} `p`

0 `a`, `b`, `c`, `d` `p`

0 `ad`, `bc` `p`

Hence -`p` `ad``bc` `p` and 0 `ad`+`bc` 2`p`.

If (i) is true then `ad``bc` 0 mod `p`, but as `ad``bc` lies between -`p` and `p`, it follows that `ad``bc` = 0 `ad` = `bc`. However, we have shown that if this is true, then `c` = `a` and `d` = `b`, and the square sum must be unique.

Let now consider (ii), `ad`+`bc` 0 mod `p`. We have shown that `ad`+`bc` lies between 0 and 2`p`, so if this is true then `ad`+`bc` = `p`. This case requires a useful, and tricky, identity to be obtained.

p^{2} | = | (a^{2}+b^{2})(c^{2}+d^{2}) |

= | a^{2}c^{2}+a^{2}d^{2}+b^{2}c^{2}+b^{2}d^{2} | |

= | (ad+2^{2}abcd+b^{2}c^{2})+(a^{2}c^{2}2abcd+b^{2}d^{2}) | |

= | (ad+bc)^{2}+(acbd)^{2} |

Hence if `ad`+`bc` = `p`, then `p`^{2} = `p`^{2}+(`ac``bd`)^{2}.

This leads to `ac``bd` = 0 `ac` = `bd`. However, we have shown that if this is true, then `c` = `b` and `d` = `a`, and once again we show that the square sum is unique.

Hence we prove that `p` can be written as the sum of two squares in only one way.