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, 'a') sage: k Finite field in a 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 in a 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) [0, 1, 2, a, a + 1, a + 2, 2*a, 2*a + 1, 2*a + 2]
The following is a native Python set:
sage: set(k) set([a, 2*a + 1, a + 2, a + 1, 2*a + 2, 1, 0, 2, 2*a])
And the following is a SAGE enumerated set:
sage: EnumeratedSet(k) {a, 2*a + 1, a + 2, a + 1, 2*a + 2, 1, 0, 2, 2*a}
We can also make a list via comprehension:
sage: [x for x in k] [0, 1, 2, a, a + 1, a + 2, 2*a, 2*a + 1, 2*a + 2]
Next we compute with the finite field of order 16, where the name 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.multiplicative_order() 15
Of course one can also make prime finite fields.
sage: k = FiniteField(7)
Note that the generator is 1:
sage: k.gen() 1 sage: k.gen().multiplicative_order() 1
q, [name=None]) |
Create finite field of order q with variable printed as name.
INPUT: q -- integer, size of the finite field, not prime name -- (optional) variable used for printing element of the finite field. Also, two finite fields are considered equal if they have the same variable name, and not otherwise. OUTPUT: FiniteField -- a finite field of order q with given variable name.
sage: FiniteField(17) Finite field of size 17 sage: FiniteField(2**10) Finite field in x of size 2^10 sage: FiniteField(3**5, "b") Finite field in b 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 in x of size 19^2
characteristic,
degree,
gen,
modulus,
order,
polynomial
Further documentation:
) |
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
) |
The number of elements of the finite field.
sage: k = GF(2**10) sage: k Finite field in x 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:
__call__,
__len__,
__repr__,
_coerce_,
_pari_modulus,
_pari_one
Further documentation:
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 in a 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 in x of size 2^10 sage: len(k) 1024
) |
The polynomial mod p that defines the finite field, as a PARI object. This is implementation specific, and some finite fields might not be implemented using PARI, so you should avoid using this function.
INPUT: nothing OUTPUT: gen -- a pari polynomial gen
sage: GF(19**2, 'a')._pari_modulus() Mod(1, 19)*a^2 + Mod(18, 19)*a + Mod(2, 19)
sage: GF(13**3, 'a')._pari_modulus() Mod(1, 13)*a^3 + Mod(2, 13)*a + Mod(11, 13)
sage: FiniteField(2**4, "b")._pari_modulus() Mod(1, 2)*b^4 + Mod(1, 2)*b + Mod(1, 2)
) |
The PARI object Mod(1,p). This is implementation specific and should be ignored by users.
See About this document... for information on suggesting changes.