We define $\mathbb{Z}[i] := \{a + bi \mid a, b \in \mathbb{Z}\}, i = \sqrt{-1},$ which is an euclidean ring together with $N: \mathbb{Z}[i] \to \mathbb{N}_0, z \mapsto z\bar{z}=a^2+b^2$ for $z=a+bi$. Being an euclidean ring means also to be a factorial ring so that each element $z \in \mathbb{Z}[i]$ can be decomposed into a product of prime elements.
Given an exercise to decompose $4 + 12i$ into prime factors in $\mathbb{Z}[i]$ I spent a lot of time just bruteforcing the combinations. Then I got $$4+12i = 4(1 + 3i) = 2^2(-1 + i)(1-2i) = (1+i)^2(1-i)^2(-1+i)(1-2i),$$ which also was the intended solution. There is also a theorem that states that if $N(z)$ is a prime in $\mathbb{Z}$, then $z$ is irreducible in $\mathbb{Z}[i]$, hence it is a prime element in $\mathbb{Z}[i]$. That verifies that all factors on the right side of the solution are prime.
As bruteforce is never effective, scalable and good for ones' karma I asked myself if there is a more effective way to compute this decomposition.
Are you aware of any procedure that brings some insights into the decomposition and makes it more effective?
Dario Alpern's Gaussian integer factorisation calculator has, like many other programs there, an explanation of the mathematics behind it.
Suppose you have the prime factorisation of the norm $N(z)$; primes of the form $4n+3$ will always appear in pairs. Each integer prime factor or pair – with multiplicity – corresponds to a Gaussian prime factor of $z$ as follows:
As an example, for factoring $4+12i$ by hand we notice that it has content (GCD of coefficients) $2^2$, so $$4+12i=(-1)(1+i)^4(1+3i)$$ $1+3i$ has norm $2×5$. So there is another $1+i$ factor and the quotient is a prime: $$4+12i=(-1)(1+i)^5(2+i)$$ Note that the factorisation is only unique up to units.