Prime representation by the Eisenstein norm (source code)

= Prime representation by the Eisenstein norm
{title2=$p\mid n^2+3,\ p\geq3\Longrightarrow p=a^2-ab+b^2$}

Let $p\geq3$ be a <prime number> dividing $n^2+3$, and set $\omega=(-1+i\sqrt3)/2$. The case $p=3$ is $N(1-\omega)=3$. For $p>3$, use
$$
n^2+3=(n+1+2\omega)(n-1-2\omega).
$$
The <Eisenstein integer> $p$ divides this product, but divides neither factor: divisibility by the rational integer $p$ in the <basis> $1,\omega$ requires both integer coefficients to be divisible by $p$, whereas the second coefficients are $2$ and $-2$. Thus $p$ is not a <prime element> of $\mathbb Z[\omega]$.

The <Euclidean norm on the Eisenstein integers> makes this ring a <principal ideal domain>. Since <irreducible elements of a principal ideal domain are prime>, $p$ admits a factorization $p=uv$ into two nonunits. The positive integral <Eisenstein norm> is multiplicative, and its value is one exactly on <units>: when $N(u)=1$, its <complex conjugate> is an inverse. Thus $N(u),N(v)>1$ and $N(u)N(v)=p^2$, forcing both norms to be $p$. Writing $u=a+b\omega$ proves the displayed representation.