-
galois.irreducible_poly(order: int, degree: int, method: 'min' | 'max' | 'random' =
'min'
) Poly Returns a monic irreducible 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 irreducible polynomial.
- method: 'min' | 'max' | 'random' =
'min'
¶ The search method for finding the irreducible polynomial.
"min"
(default): Returns the lexicographically-minimal monic irreducible polynomial."max"
: Returns the lexicographically-maximal monic irreducible polynomial."random"
: Returns a randomly generated degree-\(m\) monic irreducible polynomial.
- Returns¶
The degree-\(m\) monic irreducible polynomial over \(\mathrm{GF}(q)\).
See also
Notes¶
If \(f(x)\) is an irreducible polynomial over \(\mathrm{GF}(q)\) and \(a \in \mathrm{GF}(q) \backslash \{0\}\), then \(a \cdot f(x)\) is also irreducible.
In addition to other applications, \(f(x)\) produces the field extension \(\mathrm{GF}(q^m)\) of \(\mathrm{GF}(q)\).
Examples¶
Find the lexicographically minimal and maximal monic irreducible polynomial. Also find a random monic irreducible polynomial.
In [1]: galois.irreducible_poly(7, 3) Out[1]: Poly(x^3 + 2, GF(7)) In [2]: galois.irreducible_poly(7, 3, method="max") Out[2]: Poly(x^3 + 6x^2 + 6x + 4, GF(7)) In [3]: galois.irreducible_poly(7, 3, method="random") Out[3]: Poly(x^3 + 2x^2 + 2x + 6, GF(7))
Monic irreducible polynomials scaled by non-zero field elements (now non-monic) are also irreducible.
In [4]: GF = galois.GF(7) In [5]: f = galois.irreducible_poly(7, 5, method="random"); f Out[5]: Poly(x^5 + 2x^4 + 4x^3 + 2x^2 + 2x + 6, GF(7)) In [6]: f.is_irreducible() Out[6]: True In [7]: g = f * GF(3); g Out[7]: Poly(3x^5 + 6x^4 + 5x^3 + 6x^2 + 6x + 4, GF(7)) In [8]: g.is_irreducible() Out[8]: True