GAP knows about all the finite fields.
To create the finite field
in GAP, type
F:=GF(p); . For example,
F:=GF(5); Elements(F); returns
[ 0*Z(5), Z(5)^0, Z(5), Z(5)^2, Z(5)^3 ] .
Type Int(Z(5)); to determine the
value of
(as an integer mod
).
In general,
is the smallest primitive root
mod
, where
is a prime.
Addition is carried out using
and
multiplication using
.
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.
GAP uses this fact and lets
denote a 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
Onto 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
.
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. We can check this
in the case
in GAP by plugging this supposed root
into the polynomial and see if we get 0 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
.
Next, let's try adding, subtracting, and multiplying field elements in GAP.
gap> gf9[4]; gf9[5]; gf9[4]+gf9[5]; Z(3^2) Z(3^2)^2 Z(3^2)^3 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> gf9[4]; gf9[6]; gf9[4]*gf9[6]; Z(3^2) Z(3^2)^3 Z(3) 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)