# Base Classes for Finite Fields¶

Base Classes for Finite Fields

TESTS:

sage: K.<a> = NumberField(x^2 + 1)
sage: F = K.factor(3)[0][0].residue_field()
True

class sage.rings.finite_rings.finite_field_base.FiniteField

Bases: sage.rings.ring.Field

Abstract base class for finite fields.

algebraic_closure()

Return the algebraic closure of self (not implemented).

Note

This is not yet implemented for finite fields.

EXAMPLES:

sage: GF(5).algebraic_closure()
Traceback (most recent call last):
...
NotImplementedError: Algebraic closures of finite fields not implemented.

cardinality()

Return the cardinality of self.

Same as order().

EXAMPLES:

sage: GF(997).cardinality()
997

factored_order()

Returns the factored order of this field. For compatibility with integer_mod_ring.

EXAMPLES:

sage: GF(7^2,'a').factored_order()
7^2

factored_unit_order()

Returns the factorization of self.order()-1, as a 1-element list.

The format is for compatibility with integer_mod_ring.

EXAMPLES:

sage: GF(7^2,'a').factored_unit_order()
[2^4 * 3]

gen()

Return a generator of this field (over its prime field). As this is an abstract base class, this just raises a NotImplementedError.

EXAMPLES:

sage: K = GF(17)
sage: sage.rings.finite_rings.finite_field_base.FiniteField.gen(K)
Traceback (most recent call last):
...
NotImplementedError

is_field(proof=True)

Returns whether or not the finite field is a field, i.e., always returns True.

EXAMPLES:

sage: k.<a> = FiniteField(3^4)
sage: k.is_field()
True

is_finite()

Return True since a finite field is finite.

EXAMPLES:

sage: GF(997).is_finite()
True

is_prime_field()

Return True if self is a prime field, i.e., has degree 1.

EXAMPLES:

sage: GF(3^7, 'a').is_prime_field()
False
sage: GF(3, 'a').is_prime_field()
True

modulus()

Return the minimal polynomial of the generator of self (over an appropriate base field).

The minimal polynomial of an element $$a$$ in a field is the unique irreducible polynomial of smallest degree with coefficients in the base field that has $$a$$ as a root. In finite field extensions, $$\GF{p^n}$$, the base field is $$\GF{p}$$. Here are several examples:

sage: F.<a> = GF(7^2, 'a'); F
Finite Field in a of size 7^2
sage: F.polynomial_ring()
Univariate Polynomial Ring in a over Finite Field of size 7
sage: f = F.modulus(); f
x^2 + 6*x + 3
sage: f(a)
0


Although $$f$$ is irreducible over the base field, we can double-check whether or not $$f$$ factors in $$F$$ as follows. The command F[x](f) coerces $$f$$ as a polynomial with coefficients in $$F$$. (Instead of a polynomial with coefficients over the base field.)

sage: f.factor()
x^2 + 6*x + 3
sage: F[x](f).factor()
(x + a + 6) * (x + 6*a)


Here is an example with a degree 3 extension:

sage: G.<b> = GF(7^3, 'b'); G
Finite Field in b of size 7^3
sage: g = G.modulus(); g
x^3 + 6*x^2 + 4
sage: g.degree(); G.degree()
3
3

multiplicative_generator()

Return a primitive element of this finite field, i.e. a generator of the multiplicative group.

You can use multiplicative_generator() or primitive_element(), these mean the same thing.

Warning

This generator might change from one version of Sage to another.

EXAMPLES:

sage: k = GF(997)
sage: k.multiplicative_generator()
7
sage: k.<a> = GF(11^3)
sage: k.primitive_element()
a
sage: k.<b> = GF(19^32)
sage: k.multiplicative_generator()
b + 5


TESTS:

Check that large characteristics work (trac ticket #11946):

sage: p = 10^20 + 39
sage: x = polygen(GF(p))
sage: K.<a> = GF(p^2, modulus=x^2+1)
sage: K.multiplicative_generator()
a + 12

ngens()

The number of generators of the finite field. Always 1.

EXAMPLES:

sage: k = FiniteField(3^4, 'b')
sage: k.ngens()
1

order()

Return the order of this finite field.

EXAMPLES:

sage: GF(997).order()
997

polynomial()

Return the defining polynomial of this finite field.

EXAMPLES:

sage: f = GF(27,'a').polynomial(); f
a^3 + 2*a + 1
sage: parent(f)
Univariate Polynomial Ring in a over Finite Field of size 3

polynomial_ring(variable_name=None)

Returns the polynomial ring over the prime subfield in the same variable as this finite field.

EXAMPLES:

sage: k.<alpha> = FiniteField(3^4)
sage: k.polynomial_ring()
Univariate Polynomial Ring in alpha over Finite Field of size 3

primitive_element()

Return a primitive element of this finite field, i.e. a generator of the multiplicative group.

You can use multiplicative_generator() or primitive_element(), these mean the same thing.

Warning

This generator might change from one version of Sage to another.

EXAMPLES:

sage: k = GF(997)
sage: k.multiplicative_generator()
7
sage: k.<a> = GF(11^3)
sage: k.primitive_element()
a
sage: k.<b> = GF(19^32)
sage: k.multiplicative_generator()
b + 5


TESTS:

Check that large characteristics work (trac ticket #11946):

sage: p = 10^20 + 39
sage: x = polygen(GF(p))
sage: K.<a> = GF(p^2, modulus=x^2+1)
sage: K.multiplicative_generator()
a + 12

random_element(*args, **kwds)

A random element of the finite field. Passes arguments to random_element() function of underlying vector space.

EXAMPLES:

sage: k = GF(19^4, 'a')
sage: k.random_element()
a^3 + 3*a^2 + 6*a + 9


Passes extra positional or keyword arguments through:

sage: k.random_element(prob=0)
0

some_elements()

Returns a collection of elements of this finite field for use in unit testing.

EXAMPLES:

sage: k = GF(2^8,'a')
sage: k.some_elements() # random output
[a^4 + a^3 + 1, a^6 + a^4 + a^3, a^5 + a^4 + a, a^2 + a]

unit_group_exponent()

The exponent of the unit group of the finite field. For a finite field, this is always the order minus 1.

EXAMPLES:

sage: k = GF(2^10, 'a')
sage: k.order()
1024
sage: k.unit_group_exponent()
1023

vector_space()

Return the vector space over the prime subfield isomorphic to this finite field as a vector space.

EXAMPLES:

sage: GF(27,'a').vector_space()
Vector space of dimension 3 over Finite Field of size 3

zeta(n=None)

Returns an element of multiplicative order n in this finite field, if there is one. Raises a ValueError if there is not.

EXAMPLES:

sage: k = GF(7)
sage: k.zeta()
3
sage: k.zeta().multiplicative_order()
6
sage: k.zeta(3)
2
sage: k.zeta(3).multiplicative_order()
3
sage: k = GF(49, 'a')
sage: k.zeta().multiplicative_order()
48
sage: k.zeta(6)
3


Even more examples:

sage: GF(9,'a').zeta_order()
8
sage: GF(9,'a').zeta()
a
sage: GF(9,'a').zeta(4)
a + 1
sage: GF(9,'a').zeta()^2
a + 1

zeta_order()

Return the order of the distinguished root of unity in self.

EXAMPLES:

sage: GF(9,'a').zeta_order()
8
sage: GF(9,'a').zeta()
a
sage: GF(9,'a').zeta().multiplicative_order()
8

class sage.rings.finite_rings.finite_field_base.FiniteFieldIterator

Bases: object

An iterator over a finite field. This should only be used when the field is an extension of a smaller field which already has a separate iterator function.

next()

x.next() -> the next value, or raise StopIteration

sage.rings.finite_rings.finite_field_base.is_FiniteField(x)

Return True if x is of type finite field, and False otherwise.

EXAMPLES:

sage: from sage.rings.finite_rings.finite_field_base import is_FiniteField
sage: is_FiniteField(GF(9,'a'))
True
sage: is_FiniteField(GF(next_prime(10^10)))
True


Note that the integers modulo n are not of type finite field, so this function returns False:

sage: is_FiniteField(Integers(7))
False

sage.rings.finite_rings.finite_field_base.unpickle_FiniteField_ext(_type, order, variable_name, modulus, kwargs)

Used to unpickle extensions of finite fields. Now superseded (hence no doctest), but kept around for backward compatibility.

EXAMPLES:

sage: # not tested

sage.rings.finite_rings.finite_field_base.unpickle_FiniteField_prm(_type, order, variable_name, kwargs)

Used to unpickle finite prime fields. Now superseded (hence no doctest), but kept around for backward compatibility.

EXAMPLE:

sage: # not tested


#### Previous topic

Finite Fields of characteristic 2 and order strictly greater than 2.

#### Next topic

Finite Extension Fields implemented via PARI.