Create a finite field with q = p^n elements using
i1 : F = GF(81,Variable=>a) |
This creates the ring of characteristic 3, having 3^4 = 81 elements. The elements of this ring are 0, a, a^2, a^3, ..., a^80.
i2 : a^80 |
i3 : a^40 |
Note that, except for 0 and 1, every element is displayed as a power of the variable a. Use ambient to see the quotient ring the field is made from.
i4 : ambient F |
Now check that a satisfies this equation.
i5 : a^4 + a - 1 |
It is often preferable to view elements of F as polynomials in a rather than as powers of a. This can be accomplished by lifting the elements back to this ambient ring.
i6 : lift(a^20, ambient F) |
i7 : apply({20,40,80}, i -> lift(a^i, ambient F)) |
(for more details on lift, see , working with multiple rings).
Finite fields can be used as base rings for polynomial rings.
i8 : R = F[x,y,z] |
i9 : f = random(2,R) |
i10 : f = (leadCoefficient f)^(-1) * f |
Groebner bases, and all related computations work in these rings.
The prime finite fields can be made easily as quotient rings of ZZ.
i11 : ZZ/101 |
In general, to make a finite field with q elements, we use GF.
i12 : k = GF 81 |
The generator of the field can be obtained as usual.
i13 : k_0 |
Notice that the name of the generator is displayed with a $ in it to indicate that it is not accessible by typing. Of course, you could assign the generator to the symbol of your choice, but it will still print the same way.
i14 : a = k_0 |
i15 : a^20+1 |
You may use ambient to see the quotient ring the field is made from.
i16 : ambient k |
Use ideal to see the ideal that defined that quotient ring.
i17 : ideal oo |
Finally, you may use _ to recover the generator of the ideal.
i18 : oo_0 |
To specify a different name for the generator when the field is created, use the Variable option.
i19 : F = GF(16, Variable => b) |
i20 : b^20 + 1 |
i21 : random F |
Finite fields can be used as base rings for polynomial rings.
i22 : R = F[x,y,z] |
i23 : random(2,R) |
If you have a quotient ring that you know is a finite field, then you can convert it to ring that is known by the system to be a finite field.
i24 : GF (ZZ/2[T]/(T^9+T+1), Variable => T) |
You may also provide your own choice of primitive element. Internally, elements of the finite field are stored as powers of the primitive element. First we assign our quotient ring to a global variable to ensure that T gets set to a value in the quotient ring, and then we call GF.
i25 : A = ZZ/2[T]/(T^9+T+1) |
i26 : k = GF (A, PrimitiveElement => T^3+1) |
Notice that T is still recorded as an element of its quotient ring, rather than this finite field.
i27 : T |
Use promote to see how the generator T appears as an element of the finite field.
i28 : promote(T,k) |
Conversely, a given element of the finite field can be transferred back to the quotient ring with lift.
i29 : lift(k_0, ring T) |
We can even lift it back to the polynomial ring.
i30 : lift(k_0, ambient ring T) |
For more information see GaloisField.