## The ring of algebraic integers in QQ(i) is ZZ[i]

Prove that the ring of algebraic integers in $\mathbb{Q}(i)$ is $\mathbb{Z}[i]$.

Recall that an element in an algebraic extension of $\mathbb{Q}$ is called an algebraic integer if its minimal polynomial over $\mathbb{Q}$ has only integer coefficients.

First we will show that the minimal polynomial of every element of $\mathbb{Z}[i]$ has only integer coefficients. To that end, let $z = a+bi \in \mathbb{Z}[i]$. If $b = 0$, then certainly $z = a \in \mathbb{Z}$ is an algebraic integer, since its minimal polynomial is simply $x - a$. Suppose $b \neq 0$; in this case $z \notin \mathbb{Q}$, and so its minimal polynomial has degree at least 2. Note that $z$ is a root of $p(x) = x^2 - 2ax + (a^2 + b^2)$, and $p(x) \in \mathbb{Z}[x]$; so $z$ has degree exactly 2, and in fact $p(x)$ is its minimal polynomial. So $z$ is an algebraic integer.

Conversely, suppose $z = s+ti \in \mathbb{Q}(i)$ is an algebraic integer. If $t = 0$, then $s \in \mathbb{Q}$ is an algebraic integer, and so $s \in \mathbb{Z}$. Certainly then $z \in \mathbb{Z}[i]$. Suppose now that $t \neq 0$. If $s = 0$, then $z = ti$ is a root of $x^2 + t^2$, which is irreducible over $\mathbb{Q}$ and hence the minimal polynomial of $z$. So $t^2 \in \mathbb{Z}$. If $t$ is not an integer, then neither is $t^2$; hence $t \in \mathbb{Z}$, and so $z \in \mathbb{Z}[i]$. So we assume $t \neq 0$.

Now $z \notin \mathbb{Q}$, so the minimal polynomial of $z$ over $\mathbb{Q}$ has degree at least 2. Since $z$ is (evidently) a root of $p(x) = x^2 - 2sx + s^2+t^2$, this must be the minimal polynomial of $z$. Since $z$ is an algebraic integer, we have $2s, s^2+t^2 \in \mathbb{Z}$.

Let us say $s = a/b$ and $t = c/d$, where $a,b,c,d \in \mathbb{Z}$ and $\mathsf{gcd}(a,b) = \mathsf{c,d} = 1$. Then (rewriting) we have $\frac{2a}{b} \in \mathbb{Z}$, so that $b|2a$. Let $p$ be a prime factor of $b$; then $p|2a$. Since $a$ and $b$ are relatively prime, $p|2$, and in fact $p = 2$. So $b = 2^k$ for some $k \geq 0$. However, if $k \geq 2$, then we have $2|a$, a contradiction since $a$ and $b$ are relatively prime. So $b = 1$ or $b = 2$. Suppose $b = 2$.

We also have that $s^2+t^2 \in \mathbb{Z}$, so that $b^2d^2|(a^2d^2 + c^2b^2)$. Say $4d^2k = a^2d^2 + 4c^2$; rearranging, we have $d^2(4k - a^2) = 4c^2$. Let $p$ be a prime factor of $d$. Again because $c$ and $d$ are relatively prime, we have $p|4$, so that $p = 2$. So $d = 2^k$ for some $k \geq 0$. If $k \geq 2$, then we have 2|c\$, a contradiction. So $d = 1$ or $d = 2$. Suppose $d = 2$.

Now $(a^2+c^2)/4 \in \mathbb{Z}$, so that $a^2 + c^2 = 4k$ for some $k \in \mathbb{Z}$. In particular, $a^2 + c^2 \equiv 0$ mod 4. Note that the squares mod 4 are precisely 0 and 1, and the only solutions of this equivalence are $(a,c) \in \{(0,0), (2,0), (0,2), (2,2)\}$. In any case, $a$ and $c$ are either 0 (a contradiction) or divisible by 2 (a contradiction since they are relatively prime to $b$ and $d$, respectively.) Now $d = 1$. Again, we have $a^2 + 4c^2 = 4k$ for some integer $k$, so that $a^2 \equiv 0$ mod 4, a contradiction. So $b = 1$.

Thus $z = s+ti \in \mathbb{Z}[i]$ as desired.

Hence, the ring of algebraic integers in $\mathbb{Q}(i)$ is precisely $\mathbb{Z}[i]$.