Create with the command FiniteField(modulus)
INPUT: q - int, prime power, order of the finite field OUTPUT: FiniteField - finite field of order q.
sage: k = FiniteField(9) sage: k Finite field of size 3^2 sage: k.is_field() True sage: k.characteristic() 3 sage: a = k.gen() sage: a a sage: a.parent() Finite field of size 3^2 sage: a.charpoly() x^2 + 2*x + 2 sage: [a**i for i in range(8)] [1, a, a + 1, 2*a + 1, 2, 2*a, 2*a + 2, a + 2]
Fields can be coerced into sets or list and iterated over:
sage: list(k) [1, a, a + 1, 2*a + 1, 2, 2*a, 2*a + 2, a + 2, 0] sage: set(k) set([a, 2*a + 1, a + 2, a + 1, 0, 1, 2*a + 2, 2, 2*a]) sage: [x for x in k] [1, a, a + 1, 2*a + 1, 2, 2*a, 2*a + 2, a + 2, 0]
Next we compute with the finite field of order 16, where the variable is named b.
sage: k16 = FiniteField(16, "b") sage: z = k16.gen() sage: z b sage: z.charpoly() x^4 + x + 1 sage: k16.is_field() True sage: k16.characteristic() 2 sage: z.order() 15
Of course one can also make prime finite fields.
sage: k = FiniteField(7)
Note that the generator is a primitive root of unity.
sage: k.gen() 3 sage: k.gen().order() 6
q, [var=a]) |
Create finite field of order q with variable var.
INPUT: q -- integer, size of the finite field, not prime var -- (optional, defaults to 'a') variable used for printing element of the finite field. Also, two finite fields are considered equivalent if they have the same variable. OUTPUT: FiniteField -- a finite field of order q with variable var.
sage: FiniteField(17) Finite field of size 17 sage: FiniteField(2**10) Finite field of size 2^10 sage: FiniteField(3**5, "b") Finite field of size 3^5 sage: FiniteField(3**5, "b").gen() b
You can also create a finite field using GF, which is a synonym for FiniteField.
sage: GF(19**2) Finite field of size 19^2
characteristic,
degree,
gen,
name,
order,
polynomial
These methods are defined as follows:
) |
Returns the characteristic of the finite field, which is a prime int.
sage: k = FiniteField(3**4) sage: k.characteristic() 3
) |
Returns the degree of the finite field, which is a positive integer.
sage: FiniteField(3).degree() 1 sage: FiniteField(3**20).degree() 20
[n=0]) |
Return chosen generator of the finite field. This generator is a root of the defining polynomial of the finite field, and is guaranteed to be a generator for the multiplicative group.
INPUT: nothing OUTPUT: FiniteFieldElement -- field generator of finite field
sage: FiniteField(2**4, "b").gen() b sage: k = FiniteField(3**4, "alpha") sage: a = k.gen() sage: a alpha sage: a**4 alpha^3 + 1
) |
Short description string that determines the finite field.
sage: FiniteField(3**4).name() 'GF3_4'
) |
The number of elements of the finite field.
sage: k = GF(2**10) sage: k Finite field of size 2^10 sage: k.order() 1024
) |
Return the irreducible characteristic polynomial of the generator of this finite field, i.e., the polynomial f(x) so elements of the finite field as elements modulo f.
sage: k = FiniteField(17) sage: k.polynomial() x sage: k = FiniteField(9) sage: k.polynomial() x^2 + 2*x + 2
Instances of class FiniteField_ext_pari also have the following special methods:
x) |
Coerce x into the finite field.
INPUT: x -- object OUTPUT: FiniteFieldElement -- if possible, makes a finite field element from x.
sage: k = GF(3**4,'a') sage: b = k(5) sage: b.parent() Finite field of size 3^4 sage: a = k.gen() sage: k(a + 2) a + 2
WARNING: Finite fields are currently implemented somewhat naively using polynomials modulo p and the PARI ffinit function. In particular, we do not use Conway polynomials and define natural consistent inclusion maps between different finite fields.
) |
The number of elements of the finite field.
sage: k = GF(2**10) sage: k Finite field of size 2^10 sage: len(k) 1024
See About this document... for information on suggesting changes.