Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If a prime can be expressed as sum of two squares, then prove that the representation is unique.

My attempt:
If $a^2+b^2=p$, then it is obvious that $a,b$ of different parity.
Now, I assume the contraposition that the representation is not unique, $p=a^2+b^2=c^2+d^2$. Again, $c,d$ are of different parity.

Now, let $b,d$ be even and $a,c$ be odd.

So, $a^2+b^2=c^2+d^2 \implies a^2-c^2=d^2-b^2 \implies (a+c)(a-c)=(d-b)(d+b)$.

I cannot proceed any further. Please help.

share|cite|improve this question
Nitpick corner case: $2 = 1^2 + 1^2$, so not necessarily of different parity. This would most likely be taken care of in a different case. :) – apnorton Mar 20 '14 at 12:02
@anorton That is definitely something I didn't think about...thanks for identification – Hawk Mar 20 '14 at 12:02

The slickest way is via a little Algebraic Number Theory. If $p=a^2+b^2=c^2+d^2$ then $$p=(a+bi)(a-bi)=(c+di)(c-di)$$ Now ${\bf Z}[i]$ is a unique factorization domain, so these two factorizations of $p$ show that $a+bi$ can't be a prime in ${\bf Z}[i]$. We must have a non-trivial factorization $a+bi=(s+ti)(u+vi)$, whence $a-bi=(s-ti)(u-vi)$, and then $$p=(s^2+t^2)(u^2+v^2)$$ contradicting primality of $p$.

There are ways to answer your question without these advanced concepts, but I can never remember how it's done. I'm sure someone else will.

share|cite|improve this answer
Thanks for the approach...I will try to do something with this. – Hawk Mar 20 '14 at 12:00

Here's an answer without Algebraic Number Theory. I found it in Shanks, Solved and Unsolved Problems in Number Theory.

Assume $$p=a^2+b^2=c^2+d^2\tag1$$ with all variables positive integers. Then $$p^2=(a^2+b^2)(c^2+d^2)=a^2c^2+a^2d^2+b^2c^2+b^2d^2$$ and you can verify by just multiplying everything out that $$p^2=(ac+bd)^2+(ad-bc)^2\tag2$$ and $$p^2=(ac-bd)^2+(ad+bc)^2\tag3$$ By (1), we have $$(p-a^2)d^2=(p-c^2)b^2$$ which implies $$p(d^2-b^2)=(ad-bc)(ad+bc)\tag4$$ From (4), $p$ divides $ad-bc$, or $p$ divides $ad+bc$. If $p$ divides $ad-bc$, then from (2) we get $ad-bc=0$, so $d^2-b^2=0$, so $b=d$. If $p$ divides $ad+bc$, then from (3) we get $ac=bd$. Now $a$ and $b$ are relatively prime, so $a$ divides $d$, and $b$ divides $c$. Then by (1) we have $a=d$, and we have proved that the two representations of $p$ are the same.

This is probably something like what @Konstantinos was getting at in his answer.

share|cite|improve this answer
Just noting that $(a^2+b^2)(c^2+d^2)=(ac+bd)^2+(ad-bc)^2=(ac-bd)^2+(ad+bc)^2$ states that if a number is the product of two sums of squares,then the number can also be written as the sum of two squares.This is the sum of squares identity of Diophantus. – rah4927 Mar 21 '14 at 9:11

If $p=a^2+b^2=c^2+d^2$ then $$p=\frac{(ac+bd)(ac-bd)}{(a+d)(a-d)}$$

share|cite|improve this answer
How is that supposed to help? – Hawk Mar 20 '14 at 17:48
It is a contradiction this shows that $p$ must be composite.Maybe i will edit it later when i will have time! – Konstantinos Gaitanas Mar 20 '14 at 18:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.