Computation

The field with four elements

The integers modulo four are not a field: two times two is zero and two has no reciprocal. There is nevertheless a field with four elements, and building it means giving up on counting as the way to make arithmetic finite.

Worth reading first: Numbers that wrap.

Arithmetic on a finite set is usually introduced by wrapping the integers around a circle. That works when the circle’s length is prime and quietly fails when it is not.

The arithmetic of GF(4), and of the integers mod 4Addition and multiplication tables of a finite field, optionally beside the table of a ring of the same kind of size.+01αα+101αα+101αα+110α+1ααα+101α+1α10×01αα+101αα+1000001αα+10αα+110α+11α× mod 40000012302020321the 4 elements of GF(4), built as polynomials in α modulo α+1 + α² — every product of two non-zero elements is non-zerobeside it the integers mod 4, where 2 × 2 = 0 and 1 element has no reciprocal
Fig. 1 Two arithmetics on four symbols. On the left the field with four elements, where no two non-zero entries multiply to zero. On the right the integers mod 4, where 2 × 2 does — the shaded cell is the failure, found rather than pointed at.

What a field is required to do

A field is a set with addition and multiplication in which the ordinary rules hold: both operations commute and associate, multiplication distributes over addition, there is a zero and a one, every element has a negative, and every non-zero element has a reciprocal.

That last clause is the only demanding one, and it is what separates a field from a ring. It is also the clause every argument in the previous four essays used: dividing in Lagrange’s formula, inverting a matrix, and the root-counting that made the code work.

An immediate consequence: a field has no zero divisors. If ab=0ab = 0 with a0a \ne 0, multiplying both sides by aa’s reciprocal gives b=0b = 0. So two non-zero elements never multiply to nothing, and a polynomial of degree dd can never have more than dd roots.

Where wrapping around fails

The integers modulo nnthe arithmetic of a clock face — form a ring for every nn. They form a field exactly when nn is prime.

For nn prime it works because of Bézout: if aa shares no factor with nn, whole numbers uu and vv exist with au+nv=1au + nv = 1, so au1au \equiv 1 and uu is aa’s reciprocal. Every non-zero residue is coprime to a prime, so every one is invertible.

For nn composite, write n=abn = ab with both factors between 11 and nn. Then aa and bb are both non-zero modulo nn and their product is zero. So there is a zero divisor, and a zero divisor cannot have a reciprocal.

The arithmetic of GF(4), and of the integers mod 6Addition and multiplication tables of a finite field, optionally beside the table of a ring of the same kind of size.+01αα+101αα+101αα+110α+1ααα+101α+1α10×01αα+101αα+1000001αα+10αα+110α+11α× mod 6000000012345024024030303042042054321the 4 elements of GF(4), built as polynomials in α modulo α+1 + α² — every product of two non-zero elements is non-zerobeside it the integers mod 6, where 2 × 3 = 0 and 3 elements have no reciprocal
Fig. 2 The same contrast at a size where the field is small and the ring is larger. Mod 6 has two shaded cells — 2 × 3 and 3 × 4 both vanish — and four of its five non-zero elements are without a reciprocal.

The generator does not take that on trust either way. For the ring it searches for a pair of non-zero elements whose product is zero and for elements with no reciprocal, and asserts that both lists are empty exactly when the modulus is prime. For the field it checks every axiom over every triple.

The arithmetic of GF(5)Addition and multiplication tables of a finite field, optionally beside the table of a ring of the same kind of size.+01234012340123412340234013401240123×01234012340000001234024130314204321the 5 elements of GF(5) — every product of two non-zero elements is non-zeroassociativity and distributivity were checked over all 125 triples
Fig. 3 A prime modulus, where wrapping works: the field with five elements, with no shaded cell anywhere in the multiplication table because there is nothing to shade.

So four elements should be impossible

The obvious conclusion is that fields exist only at prime sizes, and the obvious conclusion is wrong.

There is a field with four elements. It is not the integers mod 44 and it cannot be, since that ring has a zero divisor and the property of having one is not a matter of presentation. What it is instead is an arithmetic built on a different principle entirely.

Polynomials, modulo one that will not factor

Start with the two-element field GF(2)GF(2), which is the integers mod 22 and is a field because 22 is prime.

Consider polynomials in one variable with coefficients from it: 00, 11, xx, x+1x+1, x2x^2, x2+xx^2+x, and so on. Adding and multiplying them is ordinary polynomial arithmetic with the coefficients reduced mod 22.

Now pick a polynomial and work modulo it, exactly as the integers are worked modulo nn. Take x2+x+1x^2 + x + 1. The remainders on division by it are the polynomials of degree less than two, of which there are four:

0,1,x,x+1.0,\quad 1,\quad x,\quad x+1.

Multiplication is polynomial multiplication followed by reduction. So xx=x2x \cdot x = x^2, and x2=(x2+x+1)+(x+1)x+1x^2 = (x^2+x+1) + (x+1) \equiv x+1. Writing α\alpha for xx, the whole multiplication table is generated by α2=α+1\alpha^2 = \alpha + 1.

The result is a field, and the reason is the same reason the integers mod a prime are one: x2+x+1x^2+x+1 does not factor over GF(2)GF(2). It has no root there, since substituting 00 gives 11 and substituting 11 gives 1+1+1=11+1+1 = 1, and a quadratic with no root does not factor. An irreducible modulus is a prime modulus, and the argument for reciprocals goes through unchanged.

The generator finds the modulus rather than being given it: it tries every monic polynomial of the right degree and takes the first with no root in the base field. Then it verifies the result — closure, commutativity, associativity over all q3q^3 triples, distributivity, and a reciprocal for every non-zero element.

What that field looks like

Two features of GF(4)GF(4) are worth noticing because they are what makes it not the integers mod 44.

Adding anything to itself gives zero. 1+1=01+1 = 0, and α+α=0\alpha + \alpha = 0. The additive structure is two independent copies of GF(2)GF(2), not a cycle of length four. Nothing in it counts to four.

Every element satisfies z4=zz^4 = z. The non-zero ones satisfy z3=1z^3 = 1, so the multiplicative structure is a cycle of length three — which is the subject of the next essay.

The number 44 therefore appears in this field as 222^2 and never as four of anything. That is the general situation, and it is why the answer to “which sizes are possible?” is about prime powers rather than about primes.

The arithmetic of GF(8)Addition and multiplication tables of a finite field, optionally beside the table of a ring of the same kind of size.+01αα+1α²α²+1α²+αα²+α+101αα+1α²α²+1α²+αα²+α+101αα+1α²α²+1α²+αα²+α+110α+1αα²+1α²α²+α+1α²+ααα+101α²+αα²+α+1α²α²+1α+1α10α²+α+1α²+αα²+1α²α²α²+1α²+αα²+α+101αα+1α²+1α²α²+α+1α²+α10α+1αα²+αα²+α+1α²α²+1αα+101α²+α+1α²+αα²+1α²α+1α10×01αα+1α²α²+1α²+αα²+α+101αα+1α²α²+1α²+αα²+α+10000000001αα+1α²α²+1α²+αα²+α+10αα²α²+αα+11α²+α+1α²+10α+1α²+αα²+1α²+α+1α²1α0α²α+1α²+α+1α²+ααα²+110α²+11α²αα²+α+1α+1α²+α0α²+αα²+α+11α²+1α+1αα²0α²+α+1α²+1α1α²+αα²α+1the 8 elements of GF(8), built as polynomials in α modulo α+1 + α³ — every product of two non-zero elements is non-zeroassociativity and distributivity were checked over all 512 triples
Fig. 4 The same construction one step further: eight elements, built as polynomials of degree under three modulo an irreducible cubic. The addition table has no cycle of length eight in it anywhere.

Reading the tables

The two grids in each figure repay a slow look, because the difference between a field and a ring is visible in them without any algebra.

In a field’s multiplication table, every row and every column past the zeroth is a permutation of the elements. Multiplying by a fixed non-zero aa is an invertible map — its inverse is multiplication by aa’s reciprocal — so it shuffles the field without collisions. Each symbol appears exactly once in each such row. That makes the table a Latin square with its first row and column removed, and it is the visual signature of invertibility.

In the integers mod 44, the row for 22 reads 0,2,0,20, 2, 0, 2. A symbol appears twice, another not at all, and the row is not a permutation. That is what having no reciprocal looks like: multiplication by 22 collapses four elements onto two, so nothing can undo it.

The shaded cells in the figures mark the products of two non-zero elements coming out zero, and there is exactly one such cell for each way the modulus factors. Their presence and the failure of the permutation property are the same fact seen twice.

Why prime powers, and nothing else

The classification is short enough to give in full, and it explains the shape of everything above.

Let FF be a finite field. Add 11 to itself repeatedly: 1,1+1,1+1+1,1, 1+1, 1+1+1, \ldots Since FF is finite the sequence repeats, so some sum of pp ones is zero, and the smallest such pp is the characteristic.

That pp must be prime. If p=abp = ab with both factors smaller, then the sums of aa ones and of bb ones are two non-zero elements whose product is zero, which a field cannot have.

So FF contains a copy of GF(p)GF(p) — the sums of ones — and FF is a vector space over it, since scaling by a sum of ones is defined and behaves. A finite vector space over GF(p)GF(p) of dimension kk has exactly pkp^k elements, because an element is a list of kk coordinates each with pp choices.

Therefore F=pk|F| = p^k. There is no field with six elements, or ten, or fifteen — not because nobody has found one, but because 66 is not a prime power and the argument above admits no exceptions.

The converse is also true and needs the construction: for every prime power there is a field, built as above from an irreducible polynomial of the right degree, and irreducible polynomials of every degree exist over every GF(p)GF(p).

The arithmetic of GF(9), and of the integers mod 9Addition and multiplication tables of a finite field, optionally beside the table of a ring of the same kind of size.+012αα+1α+22α+12α+2012αα+1α+22α+12α+2012αα+1α+22α+12α+2120α+1α+2α2α+12α+2201α+2αα+12α+22α+1αα+1α+22α+12α+2012α+1α+2α2α+12α+2120α+2αα+12α+22α+12012α+12α+2012αα+1α+22α+12α+2120α+1α+2α2α+22α+1201α+2αα+1×012αα+1α+22α+12α+2012αα+1α+22α+12α+2000000000012αα+1α+22α+12α+20212α+22α+1αα+2α+10α2α+22α+21α+12α+10α+12α+2α+212α+12α0α+22α+12α+21αα+120α12α+1α+122α+2α+202α+1α+2α+122α+2α102α+2α+12α+1α2α+21× mod 9000000000012345678024681357036036036048372615051627384063063063075318642087654321the 9 elements of GF(9), built as polynomials in α modulo 1 + α² — every product of two non-zero elements is non-zerobeside it the integers mod 9, where 3 × 3 = 0 and 2 elements have no reciprocal
Fig. 5 Nine elements two ways. On the left the field, built from a quadratic over GF(3); on the right the integers mod 9, where 3 × 3 = 0 and three of the eight non-zero elements have no reciprocal. Same size, and only one of them is a field.

That figure is the cleanest statement of the whole essay. Nine is a prime power, so a field of that size exists; the integers modulo nine are not it; and both objects have nine elements. Size does not determine structure, and the naive construction gives the wrong object at every non-prime prime power.

Two constructions, side by side

It is worth laying the two recipes next to each other, because they are more alike than the difference in outcome suggests.

The integers modulo nn. Take the integers, which are closed under addition and multiplication, and quotient by the multiples of nn. Result: a field exactly when nn is prime.

Polynomials modulo ff. Take the polynomials over GF(p)GF(p), which are closed under addition and multiplication, and quotient by the multiples of ff. Result: a field exactly when ff is irreducible.

The two are the same construction applied to two different systems, and “prime” and “irreducible” are the same word in each. Both systems have division with remainder, both therefore have a Euclidean algorithm, and both therefore have Bézout’s identity — which is what produces the reciprocal in each case.

That parallel is not decoration; it is why the polynomial construction was even attempted. Everything that makes the integers mod pp work is a consequence of the integers having a division algorithm and unique factorisation, and polynomials over a field have both. The objects being quotiented are unrecognisably different and the machinery does not notice.

The arithmetic of GF(3), and of the integers mod 4Addition and multiplication tables of a finite field, optionally beside the table of a ring of the same kind of size.+012012012120201×012012000012021× mod 40000012302020321the 3 elements of GF(3) — every product of two non-zero elements is non-zerobeside it the integers mod 4, where 2 × 2 = 0 and 1 element has no reciprocal
Fig. 6 The smallest instructive pair: three elements, which works because 3 is prime, beside four, which does not. The failure is one cell — and one cell is all it takes, because a zero divisor cannot have a reciprocal.

One field per size, and what that means

A second theorem completes the picture and is more surprising than the first.

For each prime power there is exactly one field of that size, up to renaming. Two people who choose different irreducible polynomials of the same degree build objects that look different — different tables, different labels — and there is always a relabelling carrying one onto the other.

That is why the notation GF(q)GF(q) names a field by its size alone and nobody has to say which construction was meant. It also means the choice made by the generator on this page, of the first irreducible polynomial found by search, costs nothing: any other choice gives the same field with the entries permuted.

Uniqueness is a stronger statement than it sounds. The integers modulo nn are unique for trivial reasons; here there are genuinely many constructions and they genuinely coincide. Over GF(2)GF(2) there are three irreducible cubics’ worth of ways to build GF(8)GF(8), and all three give the same field.

The small case that lies

There is a trap in this subject that the smallest examples set, and it is worth naming because it catches people who have understood everything above.

For n=2,3,5,7n = 2, 3, 5, 7 the integers modulo nn are the field of that size, so the first four examples anybody meets suggest that finite fields are clock arithmetic. Then GF(4)GF(4) arrives and the pattern breaks, and it breaks in a way that cannot be repaired by adjusting the modulus.

The same trap operates in the other direction. Because GF(4)GF(4) is built from polynomials, it is tempting to think its elements are polynomials in some essential way. They are not: the polynomials are a presentation, and the uniqueness theorem says the field does not remember which one was used. The elements of GF(4)GF(4) are four things with an arithmetic, and every description of them is a coordinate system.

Small cases lying about the general pattern is a recurring hazard in this collection — the first few primes suggesting regularities that fail, the first few rows of a triangle suggesting the wrong rule. Here the lie is unusually well set up, because four consecutive examples support it.

There is a third version of the trap worth flagging, since it is the one that produces wrong code rather than wrong intuition. Arithmetic modulo 2k2^k is what a fixed-width integer does in a computer — a byte is the integers mod 256256 — and it is not GF(256)GF(256). The two have the same number of elements and different multiplication entirely: 16×16=016 \times 16 = 0 in one and not in the other. Anything relying on division, including every argument in the previous anchor, is wrong in the first and right in the second, and nothing about the sizes gives any warning.

One further consequence of the classification deserves mention here, because it surprises people who arrive from ordinary algebra. In a field of characteristic pp, adding any element to itself pp times gives zero. So in the field with four elements, whose multiplicative structure is a cycle of three and which has characteristic 22, the identity (a+b)2=a2+2ab+b2(a+b)^2 = a^2 + 2ab + b^2 becomes

(a+b)2=a2+b2,(a+b)^2 = a^2 + b^2,

because the middle term is abab added to itself and therefore zero. Squaring is additive.

That is not a curiosity; it is one of the most useful facts in the subject. The map zzpz \mapsto z^p is a structure-preserving map of the field to itself — it respects addition by the argument just given and multiplication trivially — and it is the engine behind most of the theory of finite fields, including the reason the multiplicative group turns out to be a single cycle.

It also makes a familiar impossibility disappear. Over the real numbers, x2=1x^2 = -1 has no solution and adjoining one produces the complex numbers. Over GF(4)GF(4) every element is already a square, since squaring is an invertible map, and the notion of a square root is uninteresting. Which properties of arithmetic are essential and which are accidents of the reals is exactly what a finite field is good at exposing.

What it is for

A classification theorem is more convincing when the objects classified are being used for something, and these are used constantly.

The codes of the previous anchor need an alphabet whose arithmetic has no zero divisors, and they need it to be large enough to supply nn distinct evaluation points. Both requirements point at GF(256)GF(256): two hundred and fifty-six elements, so a symbol is a byte, and the arithmetic is the polynomial construction of this page at degree eight over GF(2)GF(2).

That is not a metaphor for byte arithmetic; it is byte arithmetic, done in hardware. Addition of two bytes is the exclusive-or, which every processor has. Multiplication is a polynomial multiply followed by a reduction modulo a fixed degree-eight polynomial, which is a handful of shifts and exclusive-ors and is a single instruction on modern chips because encryption standards need it.

A degree-2 polynomial over GF(11), and the 7 values sentA grid of the finite field with the polynomial's value at each point marked, and the transmitted symbols picked out.012345678910012345678910sentf(0) = 4f(1) = 8f(2) = 7f(3) = 1f(4) = 1f(5) = 7f(6) = 8the message 4, 1, 3 read as 3x² + 1x + 4 over GF(11), evaluated at x = 0…6all 35 ways of keeping 3 of the 7 values were interpolated and every one returned the message
Fig. 7 The construction that needs all of this. A polynomial over a field, sent as its values — and every step of the recovery is a division, which is exactly the operation a ring with zero divisors cannot supply.

The same fields carry the arithmetic behind the block cipher standard, the arithmetic behind elliptic-curve cryptography over binary fields, and the arithmetic behind the checksums in storage systems. In each case the property being used is the one this essay is about: division always works, so the algebra has no exceptions to handle.

Where this anchor goes

The additive structure of a finite field is settled: kk independent copies of GF(p)GF(p), with nothing more to say.

The multiplicative structure is not, and it turns out to be the interesting half. The non-zero elements of GF(q)GF(q) form a group of order q1q-1 under multiplication, and that group is always a single cycle — every non-zero element is a power of one of them. That is not obvious, it is not true for the integers modulo a composite, and it is what makes multiplication in a finite field into addition of exponents.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Named objects

A dashed tag is an object no other essay names yet.

CharacteristicClosureCounterexampleFinite fieldIrreducible polynomialModular arithmeticPrime powerZero divisor