galois.FieldArray.minimal_poly() Poly

Computes the minimal polynomial of a finite field element $$a$$.

Returns:

For scalar inputs, the minimal polynomial $$m_a(x)$$ of $$a$$ over $$\mathrm{GF}(p)$$.

Raises:
• NotImplementedError – If the array is a a square $$n \times n$$ matrix (2-D array).

• ValueError – If the array is not a single finite field element (scalar 0-D array).

An element $$a$$ of $$\mathrm{GF}(p^m)$$ has minimal polynomial $$m_a(x)$$ over $$\mathrm{GF}(p)$$. The minimal polynomial when evaluated in $$\mathrm{GF}(p^m)$$ annihilates $$a$$, that is $$m_a(a) = 0$$. The minimal polynomial always divides the characteristic polynomial. In prime fields $$\mathrm{GF}(p)$$, the minimal polynomial of $$a$$ is simply $$m_a(x) = x - a$$.

Examples

The minimal polynomial of the element $$a$$.

In : GF = galois.GF(3**5)

In : a = GF.Random(); a
Out: GF(174, order=3^5)

In : poly = a.minimal_poly(); poly
Out: Poly(x^5 + x^4 + 2x^3 + 1, GF(3))

# The minimal polynomial annihilates a
In : poly(a, field=GF)
Out: GF(0, order=3^5)

# The minimal polynomial always divides the characteristic polynomial
In : divmod(a.characteristic_poly(), poly)
Out: (Poly(1, GF(3)), Poly(0, GF(3)))

In : GF = galois.GF(3**5, repr="poly")

In : a = GF.Random(); a
Out: GF(2α^4 + 2α^2 + 1, order=3^5)

In : poly = a.minimal_poly(); poly
Out: Poly(x^5 + 2x^4 + x^3 + x^2 + x + 1, GF(3))

# The minimal polynomial annihilates a
In : poly(a, field=GF)
Out: GF(0, order=3^5)

# The minimal polynomial always divides the characteristic polynomial
In : divmod(a.characteristic_poly(), poly)
Out: (Poly(1, GF(3)), Poly(0, GF(3)))

In : GF = galois.GF(3**5, repr="power")

In : a = GF.Random(); a
Out: GF(α^233, order=3^5)

In : poly = a.minimal_poly(); poly
Out: Poly(x^5 + 2x^4 + 1, GF(3))

# The minimal polynomial annihilates a
In : poly(a, field=GF)
Out: GF(0, order=3^5)

# The minimal polynomial always divides the characteristic polynomial
In : divmod(a.characteristic_poly(), poly)
Out: (Poly(1, GF(3)), Poly(0, GF(3)))