Ring of integers (source code)

= Ring of integers
{title2=$\mathcal O_K$}
{wiki}

= Ring of integers of a number field
{synonym}

The ring of integers of a <number field> $K$ is
$$
\mathcal O_K=\{\alpha\in K:\alpha\text{ is an algebraic integer}\}.
$$
It is the <integral closure> of $\mathbb Z$ in $K$. Its <additive group> is a <free abelian group> of rank $[K:\mathbb Q]$, so an <integral basis> $\omega_1,\ldots,\omega_n$ writes every element uniquely as $\sum_j a_j\omega_j$ with $a_j\in\mathbb Z$. Its <field of fractions> is $K$.https://www.jmilne.org/math/CourseNotes/ANT.pdf[Milne, Algebraic Number Theory, Chapter 2, rings of integers and integral bases]{ref}

For $K=\mathbb Q$, this gives $\mathcal O_K=\mathbb Z$; for $K=\mathbb Q(\sqrt2)$, it gives $\mathbb Z[\sqrt2]$. The <Gaussian integers> give the corresponding example inside $\mathbb Q(i)$. The <ring of integers> is determined by the <field>, and need not equal $\mathbb Z[\theta]$ for a chosen <algebraic integer> generator: in $\mathbb Q(\sqrt5)$, the larger <ring> $\mathbb Z[(1+\sqrt5)/2]$ contains $\mathbb Z[\sqrt5]$ with index two.

This is the setting for <divisibility>, <global units>, and <prime ideal factorization>. A <ring of integers> is a <Dedekind domain>, so every nonzero proper <ideal> factors uniquely into nonzero <prime ideals>, even when <unique factorization> of elements fails.https://www.numdam.org/item/BSMA_1877_2_1_1_207_1.pdf[Dedekind, Sur la théorie des nombres entiers algébriques, 1877, §25]{ref}