galois.primitive_poly

galois.primitive_poly(order, degree, method='min')

Returns a monic primitive polynomial \(f(x)\) over \(\mathrm{GF}(q)\) with degree \(m\).

Parameters
order : int

The prime power order \(q\) of the field \(\mathrm{GF}(q)\) that the polynomial is over.

degree : int

The degree \(m\) of the desired primitive polynomial.

method : Literal['min', 'max', 'random']

The search method for finding the primitive polynomial.

  • "min" (default): Returns the lexicographically-minimal monic primitive polynomial.

  • "max": Returns the lexicographically-maximal monic primitive polynomial.

  • "random": Returns a randomly generated degree-\(m\) monic primitive polynomial.

Returns

The degree-\(m\) monic primitive polynomial over \(\mathrm{GF}(q)\).

Return type

galois.Poly

Notes

In addition to other applications, \(f(x)\) produces the field extension \(\mathrm{GF}(q^m)\) of \(\mathrm{GF}(q)\). Since \(f(x)\) is primitive, \(x\) is a primitive element \(\alpha\) of \(\mathrm{GF}(q^m)\) such that \(\mathrm{GF}(q^m) = \{0, 1, \alpha, \alpha^2, \dots, \alpha^{q^m-2}\}\).

Examples

Notice galois.primitive_poly() returns the lexicographically-minimal primitive polynomial but galois.conway_poly() returns the lexicographically-minimal primitive polynomial that is consistent with smaller Conway polynomials, which is not necessarily the same.

In [1]: galois.primitive_poly(2, 4)
Out[1]: Poly(x^4 + x + 1, GF(2))

In [2]: galois.conway_poly(2, 4)
Out[2]: Poly(x^4 + x + 1, GF(2))
In [3]: galois.primitive_poly(7, 10)
Out[3]: Poly(x^10 + 5x^2 + x + 5, GF(7))

In [4]: galois.conway_poly(7, 10)
Out[4]: Poly(x^10 + x^6 + x^5 + 4x^4 + x^3 + 2x^2 + 3x + 3, GF(7))

Last update: Apr 03, 2022