6.7.2.1 FiniteFieldElement Objects

class FiniteFieldElement
An element of a finite field.

Create elements by first defining the finite field F, then use the notation F(n), for n an integer. or let a = F.gen() and write the element in terms of a.

FiniteFieldElement( parent, value)

Create element of a finite field.

sage: k = GF(9)
sage: a = k(11); a
2
sage: a.parent()
Finite field in x of size 3^2

Instances of class FiniteFieldElement have the following methods (in addition to inherited methods and special methods):

charpoly,$  $ copy,$  $ is_square,$  $ lift,$  $ norm,$  $ order,$  $ polynomial,$  $ rational_reconstruction,$  $ trace

Further documentation:

charpoly( )

Returns the characteristic polynomial of this element.

sage: k = GF(3**3)
sage: a = k.gen()
sage: a.charpoly()
x^3 + 2*x + 1
sage: k.modulus()
x^3 + 2*x + 1
sage: b = a**2 + 1
sage: b.charpoly()
x^3 + x^2 + 2*x + 1

copy( )

Return a copy of this element.

sage: k = GF(3**3)
sage: a = k(5)
sage: a
2
sage: a.copy()
2
sage: b = a.copy()
sage: a == b
True
sage: a is b
False
sage: a is a
True

is_square( )

Returns True if and only if this element is a perfect square.

sage: k = GF(3**2)
sage: a = k.gen()
sage: a.is_square()
False
sage: (a**2).is_square()
True
sage: k = GF(2**2)
sage: a = k.gen()
sage: (a**2).is_square()
True
sage: k = GF(17**5); a = k.gen()
sage: (a**2).is_square()
True
sage: a.is_square()
False

lift( )

If this element lies in a prime finite field, return a lift of this element to an integer.

sage: k = GF(next_prime(10**10))
sage: a = k(17)/k(19)
sage: b = a.lift(); b
7894736858
sage: b.parent()
Integer Ring

norm( )

Returns the norm of this element, which is the constant term of the characteristic polynomial, i.e., the determinant of left multiplication.

sage: k = GF(3**3); a = k.gen()
sage: b = a**2 + 2
sage: b.charpoly()
x^3 + x^2 + 2
sage: b.trace()
2
sage: b.norm()
2

order( )

Returns the order of self.

polynomial( )

Elements of a finite field are represented as a polynomial modulo a modulus. This functions returns the representating polynomial as an element of the polynomial ring over the prime finite field, with the same variable as the finite field.

The default variable is a:

sage: k = GF(3**2)
sage: k.gen().polynomial()
x

The variable can be any string.

sage: k = FiniteField(3**4, "alpha")
sage: a = k.gen()
sage: a.polynomial()
alpha
sage: (a**2 + 1).polynomial()
alpha^2 + 1
sage: (a**2 + 1).polynomial().parent()
Univariate Polynomial Ring in alpha over Finite field of size 3

rational_reconstruction( )

If the parent field is a prime field, uses rational reconstruction to try to find a lift of this element to the rational numbers.

sage: k = GF(97)
sage: a = k(RationalField()('2/3'))
sage: a
33
sage: a.rational_reconstruction()
2/3

trace( )

Returns the trace of this element.

sage: k = GF(3**3); a = k.gen()
sage: b = a**2 + 2
sage: b.charpoly()
x^3 + x^2 + 2
sage: b.trace()
2
sage: b.norm()
2

Instances of class FiniteFieldElement also have the following special methods:

__abs__,$  $ __add__,$  $ __cmp__,$  $ __div__,$  $ __float__,$  $ __int__,$  $ __invert__,$  $ __long__,$  $ __mul__,$  $ __neg__,$  $ __pos__,$  $ __pow__,$  $ __rdiv__,$  $ __repr__,$  $ __sub__,$  $ _FiniteFieldElement__compat,$  $ _integer_,$  $ _pari_

Further documentation:

__cmp__( other)

Compare an element of a finite field with other. If other is not an element of a finite field, an attempt is made to coerce it so it is one.

sage: k = GF(3**3); a = k.gen()
sage: a == 1
False
sage: a**0 == 1
True
sage: a == a
True
sage: a < a**2
True
sage: a > a**2
False

__invert__( )

sage: k = GF(9); a = k.gen()
sage: ~a
x + 2
sage: (a+1)*a
2*x + 1

_pari_( )

Return PARI object corresponding to this finite field element.

sage: k = GF(3**3)
sage: a = k.gen()
sage: b = a**2 + 2*a + 1
sage: b._pari_()
Mod(Mod(1, 3)*x^2 + Mod(2, 3)*x + Mod(1, 3), Mod(1, 3)*x^3 + Mod(2, 3)*x +
Mod(1, 3))

Looking at the PARI representation of a finite field element, it's no wonder people find PARI difficult to work with directly. Compare our representation:

sage: b
x^2 + 2*x + 1
sage: b.parent()
Finite field in x of size 3^3

See About this document... for information on suggesting changes.