# Number theory : Sum of two squares :

Let $p$ be a prime. Prove that if both $p$ and $pa$ can be written as a sum of two squares, then so is $a$.

My attempt :

By Fermat's two square theorem, the expression of a prime, $p\equiv1\bmod{4}$ as the sum of two squares is unique.

Let $p = x^2+y^2$

Suppose $gcd(x,y) \not= 1$, let $gcd(x,y)=d$

then $d\mid x$, $d\mid y$ so $d^2\mid x^2+y^2$ i.e., $d^2\mid p$, contradiction.

so $gcd(x,y) =1$ then there exists $t_1, t_2 \in\mathbb{Z}$ that $t_1x+t_2y=1$

so $a = at_1x+at_2y$

• You might get some insight from math.stackexchange.com/questions/285563/… . – Eric Towers Aug 20 '17 at 5:57
• You will want to show that if $p \mid X^2 + Y^2$, then at least one of $x+yi$ or $x-yi$ divides $X+Yi$ (in the Gaussian integer sense). – Erick Wong Aug 20 '17 at 6:25
• Thank you, @Eric Towers. I can prove that problem. I think the problem condition is different. – carat Aug 20 '17 at 6:31

Suppose $p = {x_1}^2 + {y_1}^2$ and $ap = {x_2}^2 + {y_2}^2$.

$$(x_1x_2+y_1y_2)(x_1x_2-y_1y_2) = {x_1}^2{x_2}^2 - {y_1}^2{y_2}^2 = {x_2}^2({x_1}^2 + {y_1}^2) - {y_1}^2({x_2}^2 + {y_2}^2) \equiv 0 \mod p$$

So at least on of $(x_1x_2+y_1y_2)$ and $(x_1x_2-y_1y_2)$ is a multiple of $p$.

Suppose without loss of generality that $p\mid (x_1x_2+y_1y_2)$. (If not, set $x_1' = -x_1$)

Consider $ap^2 = (x_1x_2+y_1y_2)^2 + (x_1y_2-x_2y_1)^2$.

Since $p\mid (x_1x_2+y_1y_2)$, we must also have $p\mid(x_1y_2-x_2y_1)$.

Thus $\frac{x_1x_2+y_1y_2}{p}$ and $\frac{x_1y_2-x_2y_1}{p}$ are both integers and $$a = \left( \frac{x_1x_2+y_1y_2}{p} \right)^2+\left( \frac{x_1y_2-x_2y_1}{p} \right)^2$$

• Nice idea ! Thank you very much, Yifan Zhu. – carat Aug 20 '17 at 10:28
• You are welcome. I think this proof is originally due to Euler. See en.wikipedia.org/wiki/… – Yifan Zhu Aug 20 '17 at 10:38

Your problem can actually be solved using Gaussian integers. As a consequence of the ramification of primes in $\mathbf Z [i]$, it is classically known that an integer $x$ is a sum of two squares iff for any prime $l \equiv 3$ mod $4$, the exponent $v_l (x)$ of $l$ in the rational prime decomposition of $x$ is even, see e.g. Samuel's ANT chap.V, §5.6. Here $v_l (pa) = v_l(p) + v_l(a)= v_l(a)$ (because $l\neq p$) is even by hypothesis, and you are done.

• Thank you for your help ! – carat Aug 22 '17 at 12:43