galois.primitive_poly

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

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

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

Parameters
  • characteristic (int) – The prime characteristic \(p\) of the field \(\mathrm{GF}(p)\) that the polynomial is over.

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

  • method (str, optional) –

    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}(p)\).

Return type

galois.Poly

Examples

Notice primitive_poly() returns the lexicographically-minimal primitive polynomial, where conway_poly() returns the lexicographically-minimal primitive polynomial that is consistent with smaller Conway polynomials.

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

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