Field with four elements (source code)

= Field with four elements
{title2=$\mathbb F_4$}

Build this <finite field> by taking a <quotient ring> of a <polynomial ring>:
$$
\mathbb F_4=\mathbb F_2[t]/(t^2+t+1),\qquad \alpha=[t].
$$
The <polynomial> $f(t)=t^2+t+1$ has $f(0)=f(1)=1$ in the <prime field> $\mathbb F_2$. A <polynomial> of <polynomial degree> two is an <irreducible polynomial> exactly when it has no <polynomial root> in the <coefficient> <field>. Thus the <quotient by an irreducible polynomial is a field> construction applies. Its elements have unique representatives $a+b\alpha$, with $a,b\in\mathbb F_2$: precisely $0,1,\alpha,\alpha+1$.

The defining relation is $\alpha^2+\alpha+1=0$. Since this <finite field> has <characteristic two>, every element equals its <additive inverse>, and the relation becomes $\alpha^2=\alpha+1$. <Addition> acts separately on the two <coefficients>:
$$
(a+b\alpha)+(c+d\alpha)=(a+c)+(b+d)\alpha.
$$
All <coefficient> calculations use <modular arithmetic> modulo two. For example, $(\alpha+1)+\alpha=1$ and $(\alpha+1)+(\alpha+1)=0$. Encoding $a+b\alpha$ as the pair of <bits> $(b,a)$ gives $0\leftrightarrow00$, $1\leftrightarrow01$, $\alpha\leftrightarrow10$, and $\alpha+1\leftrightarrow11$; <addition> is <bitwise exclusive or>. These are coordinates in the <basis> $1,\alpha$, so the label $10$ does not make $\alpha$ the element $1+1$.

For <multiplication>, expand using the <distributive property> and replace every $\alpha^2$ by $\alpha+1$:
$$
(a+b\alpha)(c+d\alpha)=(ac+bd)+(ad+bc+bd)\alpha.
$$
For example, $\alpha(\alpha+1)=\alpha^2+\alpha=1$, while $(\alpha+1)^2=\alpha^2+1=\alpha$. The following complete tables are computed from the <coefficient> rules. Colors identify results, rather than their numerical sizes. Every row of the <addition> table lists all four elements, and every nonzero row of the <multiplication> table does too: adding an element, or multiplying by a nonzero element, can be undone.

\Image[/finite-field-four-operations.png]
{title=Computed addition and multiplication tables for the field with four elements}

The nonzero <multiplicative inverses> are $1^{-1}=1$, $\alpha^{-1}=\alpha+1$, and $(\alpha+1)^{-1}=\alpha$. Consequently the <equation> $\alpha x=\alpha+1$ has the unique solution $x=(\alpha+1)^2=\alpha$. Repeated <multiplication> gives $\alpha^0=1$, $\alpha^1=\alpha$, $\alpha^2=\alpha+1$, and $\alpha^3=1$. They cycle through every element of the <multiplicative group of a finite field>.

Compare the <ring> $\mathbb Z/4\mathbb Z$, also with four elements. Its <addition> satisfies $1+1=2\ne0$, and its <multiplication> satisfies $2^2=0$. Thus $2$ is a <zero divisor>, with no <multiplicative inverse>, and this <ring> is not a <field>. Multiplying by $2$ collapses different inputs to the same output: both $0$ and $2$ give $0$, while both $1$ and $3$ give $2$. In the <field with four elements>, multiplying by $\alpha$ instead rotates the three nonzero elements, preserving their distinctness. The figure makes visible why counting four elements alone does not specify their <arithmetic>.

\Image[/finite-field-vs-mod-four.png]
{title=Four elements with different arithmetic: a field and integers modulo four}