A number field enlarges \(\mathbb Q\) by adjoining algebraic numbers. Its ring of integers is the correct replacement for \(\mathbb Z\): it is stable under arithmetic, has a finite integral basis, and supports norms, traces, discriminants, ideals, and valuations.
Number fields, trace, and norm
Definition. A number field is a finite extension \(K/\mathbb Q\). Multiplication by \(\alpha\in K\) is a \(\mathbb Q\)-linear map \(m_\alpha:K\to K\). Define \[ \operatorname{Tr}_{K/\mathbb Q}(\alpha)=\operatorname{tr}(m_\alpha), \qquad N_{K/\mathbb Q}(\alpha)=\det(m_\alpha). \]
If \(K/\mathbb Q\) is separable with embeddings \(\sigma_1,\ldots,\sigma_n:K\hookrightarrow\mathbb C\), then \[ \operatorname{Tr}(\alpha)=\sum_i\sigma_i(\alpha),\qquad N(\alpha)=\prod_i\sigma_i(\alpha). \] Thus \(N(\alpha\beta)=N(\alpha)N(\beta)\).
Algebraic integers
Definition. An element \(\alpha\in K\) is an algebraic integer if it satisfies a monic polynomial in \(\mathbb Z[x]\). The set of all such elements is the ring of integers \(\mathcal O_K\).
Theorem (integrality criterion). For \(\alpha\in K\), the following are equivalent: \(\alpha\) is integral over \(\mathbb Z\); the group \(\mathbb Z[\alpha]\) is finitely generated as a \(\mathbb Z\)-module; and there exists a finitely generated faithful \(\mathbb Z[\alpha]\)-module.
Proof. A monic relation reduces every power of \(\alpha\) to the span of \(1,\alpha,\ldots,\alpha^{d-1}\). The second condition implies the third. For the converse, multiplication by \(\alpha\) acts on a finite \(\mathbb Z\)-generating set; the determinant trick applied to the resulting matrix gives a monic polynomial annihilating the module. Faithfulness makes that polynomial annihilate \(\alpha\).
This criterion shows that sums and products of algebraic integers remain integral. Hence \(\mathcal O_K\) is indeed a ring.
Integral bases and discriminants
Theorem. If \([K:\mathbb Q]=n\), then \(\mathcal O_K\) is a free abelian group of rank \(n\). A basis \((\omega_1,\ldots,\omega_n)\) is an integral basis.
Definition. For a basis \(\alpha_1,\ldots,\alpha_n\), \[ \operatorname{disc}(\alpha_1,\ldots,\alpha_n) =\det\bigl(\operatorname{Tr}(\alpha_i\alpha_j)\bigr). \] The field discriminant \(d_K\) is the discriminant of an integral basis.
A change of basis by \(A\) multiplies the discriminant by \((\det A)^2\), so \(d_K\) is basis independent. A rational prime ramifies in \(K\) only if it divides \(d_K\).
Quadratic fields
Theorem. For squarefree \(d\), \[ \mathcal O_{\mathbb Q(\sqrt d)} = \begin{cases} \mathbb Z[(1+\sqrt d)/2],&d\equiv1\pmod4,\\ \mathbb Z[\sqrt d],&d\equiv2,3\pmod4. \end{cases} \] The discriminant is \(d\) in the first case and \(4d\) in the second.
Example. In \(K=\mathbb Q(i)\), \(\mathcal O_K=\mathbb Z[i]\), \[ N(a+bi)=a^2+b^2,\qquad d_K=-4. \] The norm turns factorization questions into equations over ordinary integers.