The finite fields in GAP are of the form
, where
is a prime power and
is an integer. Let's start with
something simple: enter
and
and print out all
their elements.
gap> GF2:=GF(2); GF(2) gap> gf2:=Elements(GF2); [ 0*Z(2), Z(2)^0 ] gap> GF3:=GF(3); GF(3) gap> gf3:=Elements(GF3); [ 0*Z(3), Z(3)^0, Z(3) ]
What are
,
? In general,
is a cyclic group.
In GAP,
denote a particular generator of this
cyclic group. If
then giving a generator of
is equivalent to giving a primitive
root mod
. In fact,
is the smallest primitive root
mod
, as is obtained from the PrimitiveRootMod function.
Here's how to verify this for
:
gap> PrimitiveRootMod(3); 2 gap> 2*Z(3)^0=Z(3); true gap> PrimitiveRootMod(5)*Z(5)^0=Z(5); true
We turn to the analogous question for fields
with
.
gap> GF4:=GF(4); GF(2^2) gap> gf4:=Elements(GF4); [ 0*Z(2), Z(2)^0, Z(2^2), Z(2^2)^2 ] gap> GF7:=GF(7); GF(7) gap> GF8:=GF(8); GF(2^3) gap> gf8:=Elements(GF8); [ 0*Z(2), Z(2)^0, Z(2^3), Z(2^3)^2, Z(2^3)^3, Z(2^3)^4, Z(2^3)^5, Z(2^3)^6 ] gap> GF9:=GF(9); GF(3^2) gap> gf9:=Elements(GF9); [ 0*Z(3), Z(3)^0, Z(3), Z(3^2), Z(3^2)^2, Z(3^2)^3, Z(3^2)^5, Z(3^2)^6, Z(3^2)^7 ]
Note that
contains
but not
.
(It is a general fact that
contains
as a subfield
if and only if
divides
.)
What are Z(2^2), Z(2^3), Z(3^2), ...? They are less easy to
explicitly explain.
is a root of a certain irreducible
polynomial mod
called a Conway polynomial,
which we will not define here. GAP can construct Conway
polynomials, so in any given situation
we can check that this is
the case by plugging this supposed root
into the polynomial and see if we get
or not.
gap> R:=PolynomialRing(GF2,["x"]); <algebra-with-one over GF(2), with 1 generators> gap> p:=ConwayPolynomial(2,3); Z(2)^0+x+x^3 gap> Value(p,Z(8)); 0*Z(2)
This tells us that the generator of
is a root of the
polynomial
mod
.
Now we know how finite fields are represented as sets in GAP, notice how easy it is to use GAP to to basic arithmetic in a finite field. Let's try adding, subtracting, and multiplying field elements in GAP.
gap> gf9[3]; gf9[6]; gf9[3]+gf9[6]; Z(3) Z(3^2)^3 Z(3^2)^5 gap> gf9[3]; gf9[6]; gf9[3]*gf9[6]; Z(3) Z(3^2)^3 Z(3^2)^7 gap> gf8[4]; gf8[6]; gf8[4]*gf8[6]; Z(2^3)^2 Z(2^3)^4 Z(2^3)^6 gap> gf8[4]; gf8[6]; gf8[4]+gf8[6]; Z(2^3)^2 Z(2^3)^4 Z(2^3)