## Solve an equation over the Gaussian integers

Find all the Gaussian integers $\pi$ and $\rho$ such that $5-i = \pi(1+2i) + \rho$ and $N(\rho) < N(1+2i)$.

First, let $\pi = a_1 + a_2i$ and $\rho = b_1 + b_2i$. Expanding and comparing real and imaginary parts, we have the following linear system of equations.

$\left[ \begin{array}{cc} 1 & \text{-}2 \\ 2 & 1 \end{array} \right] \left[ \begin{array}{c} a_1 \\ a_2 \end{array} \right] = \left[ \begin{array}{c} 5-b_1 \\ -1-b_2 \end{array} \right]$.

Evidently, $\left[ \begin{array}{cc} 1 & \text{-}2 \\ 2 & 1 \end{array} \right] \left[ \begin{array}{cc} 1 & 2 \\ \text{-}2 & 1 \end{array} \right] = 5I$. This yields the following equality.

$\left[ \begin{array}{c} 5a_1 \\ 5a_2 \end{array} \right] = \left[ \begin{array}{c} 3-b_1-2b_2 \\ -11 + 2b_1 - b_2 \end{array} \right]$.

Reducing mod 5 yields the following two equations: $3 \equiv b_1 + 2b_2$ mod 5 and $1 \equiv 2b_1 - b_2$ mod 5. A simple but tedious case analysis reveals that this system has two solutions: $(0,-1)$ and $(1,1)$.

Now recall the constraint that $N(\rho) < N(1+2i)$; that is, $b_1^2 + b_2^2 < 5$. Thus $(|b_1|, |b_2|)$ must be one of $(0,0)$, $(0,\pm 1)$, $(0, \pm 2)$, $(\pm 1, 0)$, $(\pm 1, \pm 1)$, and $(\pm 2, 0)$. Thus we have $\rho \in \{ 1+i, -i \}$.

Thus the solutions $(\pi,\rho)$ of our original equation are $(1-2i,-i)$ and $(-2i,1+i)$.