# galois.primitive_polys¶

galois.primitive_polys(order, degree)

Returns all monic primitive polynomials $$f(x)$$ over $$\mathrm{GF}(q)$$ with degree $$m$$.

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

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

Returns

All degree-$$m$$ monic primitive polynomials over $$\mathrm{GF}(q)$$.

Return type

list

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

All monic primitive polynomials over $$\mathrm{GF}(2)$$ with degree $$5$$.

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


All monic primitive polynomials over $$\mathrm{GF}(3^2)$$ with degree $$2$$.

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