I want to find all the possible $x,y \in \mathbb{Z}$ s.t. $1125 = x^2 + y^2$ using the following result:
The representations of $n$ as a sum of two squares are determined by the possible choices of the $p_i$ in the Gaussian prime decomposition (i.e. choosing signs $a_j \pm b_j i$).
$1125 = 3^2 (2+i)^2 (2-i)^2$ is the Gaussian prime decomposition of $1125$ and I can spot solutions as $(30,15)$ but how can I find all of them? How many are there?
You can find a very detailed explanation of the solution in "Abstract Algebra" by Dummit and Foote, pag. 291.
Theorem.
If $n=2^kp_1^{a_1}\cdots p_r^{a_r}q_1^{b_1}\cdots q_s^{b_s}$ where $p_i \equiv 1 \bmod(4)$ and $q_i \equiv 3 \bmod(4)$, then:
1) $n$ can be written as sum of squares, i.e. $n=A^2 + B^2$ with $A$ and $B$ integers, if and only if every $b_i$ is even.
2) If (1) holds the number of different ways to write $n$ as a sum of two squares are $4(a_1+1)\cdots(a_r+1)$.
Example.
$1125=3^25^3$, the precedent theorem tell us that there are $16$ ways to write it as a sum of squares. We'll show throught an example how to find them.
Every prime congruent $1$ modulo $4$ can be factorized in two conjugate irreducible gaussian integers, for example $5=(2+i)(2-i)$. Instead every prime congruent $3$ modulo $4$ is irreducible also in the guassian integers ring.
The integers we're looking for are the solutions of $A + iB = (2+i)^{e_1}(2-i)^{e_2}3$ with $e_1$ and $e_2$ not negative integers such that $e_1+e_2=3$. Infact:
$A^2 + B^2 = \\ =N(A+iB)= \\ =(A+iB)(\overline{A+iB})= \\ =((2+i)^{e_1}(2-i)^{e_2}3)\overline{((2+i)^{e_1}(2-i)^{e_2}3)}=\\ =((2+i)^{e_1}(2-i)^{e_2}3)((2-i)^{e_1}(2+i)^{e_2}3)= \\ =(2+i)^3(2-i)^33^2=\\ =5^33^2=\\ =1125\\$
Varing $e_1$ we can find all the solutions:
For $e_1=0$:
$A+iB=\\ =(2-i)^33=\\ =6-33i$
Inverting the signs and the order we get 8 solutions $1125= (\pm6)^2 +(\pm 33)^2 = (\pm 33)^2 +(\pm 6)^2$
For $e_1=1$:
$A+iB=\\ =(2+i)(2-i)^23=\\ =30-15i$
For others 8 solutions $1125= (\pm30)^2 +(\pm 15)^2 = (\pm 15)^2 +(\pm 30)^2$
For $e_1=2$ or $e_1=3$ we obtain the same results infact we've already reached the 16 solutions predicted.