1. ## Sum of squares

Can someone give me a hint for how to show if $\displaystyle p \equiv 1 \mod{4}$ then $\displaystyle p = a^2+b^2$?

Thanks a lot!

2. Originally Posted by chiph588@
Can someone give me a hint for how to show if $\displaystyle p \equiv 1 \mod{4}$ then $\displaystyle p = a^2+b^2$?

Thanks a lot!
Consider, $\displaystyle \mathbb{Z}[i]$. This is a principal ideal domain. Now the equation $\displaystyle x^2 \equiv -1(\bmod p)$ is solvable if $\displaystyle p\equiv 1(\bmod 4)$. Therefore, $\displaystyle p|(x^2+1)$ for some $\displaystyle x\in \mathbb{Z}$. If $\displaystyle p$ was irreducible then $\displaystyle p$ would also be prime (since the integral domain is a PID and so "irreducible" is equivalent to "prime") and so $\displaystyle p|(x+i)(x-i)\implies p|(x+i) \text{ or }p|(x-i)$. But this is impossible. Therefore, $\displaystyle p$ is reducible and $\displaystyle p=\alpha \beta$ where $\displaystyle \alpha,\beta \in \mathbb{Z}[i]$ and $\displaystyle \alpha,\beta$ are non-units. This means $\displaystyle p^2 = Np = (N\alpha)(N\beta)$ (norm). However, $\displaystyle N\alpha, N\beta \not = 1$ since they are not units and so $\displaystyle N\alpha = N\beta = p$. Therefore, if $\displaystyle \alpha = a+bi$ then it means $\displaystyle N\alpha = p \implies a^2 + b^2 = p$.

Additional problem: Prove that if $\displaystyle p=a^2+b^2$ and $\displaystyle p=c^2+d^2$ where $\displaystyle a,c$ are odd and $\displaystyle b,d$ are even and $\displaystyle a,b,c,d>0$ then $\displaystyle a=c\text{ and }b=d$. In other words, we have a certain level of uniqueness in the decomposition of $\displaystyle p$ into sum of squares.

3. Ah yes, I was having trouble seeing why p is reducible.

4. Here is a very elementary way of proving this result. Remember if $\displaystyle p\equiv 1(\bmod 4)$ then there is $\displaystyle a$ so that $\displaystyle a^2 \equiv -1(\bmod p)$. There is an elementary way of showing this too, just let $\displaystyle a = \left( \tfrac{p-1}{2} \right)!$ and use Wilson's theorem. But whatever, we will accept this result.

We need a Lemma first: let $\displaystyle (b,p)=1$ then there exists $\displaystyle x,y$ with $\displaystyle 0 < |x|,|y| < \sqrt{p}$ so that $\displaystyle bx\equiv y(\bmod p)$.

To prove this let $\displaystyle n = [\sqrt{p}]+1$. And define $\displaystyle S = \{bx - y | 0\leq x,y \leq n-1\}$. The set $\displaystyle S$ has at most $\displaystyle n^2$ different values. Since $\displaystyle n^2 > p$ and there are only two $\displaystyle p$ residue classes of mod $\displaystyle p$ it means there are $\displaystyle bx_1 - y_1\text{ and }bx_2 - y_2$ so that $\displaystyle bx_1 - y_1 \equiv bx_2 - y_2(\bmod p)$ and $\displaystyle x_1\not = x_2$ or $\displaystyle y_1\not = y_2$ (by pigeonhole principle). If $\displaystyle x_1 = x_2$ then by considering this congruence it would mean $\displaystyle y_1 = y_2$, which is a contradiction. Similarly if $\displaystyle y_1 = y_2$ then it would force $\displaystyle x_1=x_2$, which is a contradiction. Therefore, $\displaystyle x_1\not =x_2 , ~ y_1\not = y_2$. Thus, we have $\displaystyle b(x_1 - x_2) \equiv (y_1 - y_2)(\bmod p)$. Set $\displaystyle x=x_1-x_2, ~ y=y_1-y_2$ and we see that $\displaystyle 0 < |x|,|y| \leq n-1 < \sqrt{p}$. Remember that $\displaystyle x^2,y^2 < p \implies x^2+y^2 < 2p$, thus $\displaystyle k$ must be equal to $\displaystyle 1$.

Now we can prove that $\displaystyle p$ is a sum of two squares. Let $\displaystyle a$ be a square root of $\displaystyle -1$ mod $\displaystyle p$ i.e. in less fancy language $\displaystyle a^2\equiv -1(\bmod p)$. Pick integers $\displaystyle x,y$ so that $\displaystyle ax\equiv y(\bmod p)$ and $\displaystyle 0 < |x|,|y| < \sqrt{p}$. Therefore, $\displaystyle -x^2 \equiv a^2x^2 = (ax)^2 \equiv y^2(\bmod p)$. Thus, $\displaystyle p|(x^2+y^2) \implies x^2+y^2 = pk$ for some $\displaystyle k\in \mathbb{Z}^+$. We will complete the proof if we can show $\displaystyle k=1$.