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.
parent, value) |
Create element of a finite field.
sage: k = GF(9) sage: a = k(11); a 2 sage: a.parent() Finite field of size 3^2
charpoly,
copy,
is_square,
lift,
norm,
order,
pari,
polynomial,
rational_reconstruction,
trace
These methods are defined as follows:
) |
Returns the characteristic polynomial of this element.
sage: k = GF(3**3) sage: a = k.gen() sage: a.charpoly() x^3 + 2*x^2 + x + 1 sage: k.modulus() x^3 + 2*x^2 + x + 1 sage: b = a^2 + 1 sage: b.charpoly() x^3 + x^2 + x + 2
) |
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
) |
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
) |
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/19) sage: b = a.lift(); b 7894736858 sage: b.parent() Integer Ring
) |
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*x + 1 sage: b.trace() 2 sage: b.norm() 1
) |
Returns the order of self.
) |
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)*a^2 + Mod(2, 3)*a + Mod(1, 3), Mod(1, 3)*a^3 + Mod(2, 3)*a + 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 a^2 + 2*a + 1 sage: b.parent() Finite field of size 3^3
) |
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() a
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
) |
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(Q('2/3')) sage: a 33 sage: a.rational_reconstruction() 2/3
) |
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*x + 1 sage: b.trace() 2 sage: b.norm() 1
Instances of class FiniteFieldElement also have the following special methods:
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
) |
sage: k = GF(9); a = k.gen() sage: ~a a + 1 sage: (a+1)*a 1
See About this document... for information on suggesting changes.