nmod_poly_minimal_irreducible
#include <flint/nmod_poly.h>void nmod_poly_minimal_irreducible(nmod_poly_t res, ulong n)sourceSets res to a monic irreducible polynomial of degree n \ge 1 over the prime field \mathbb{F}_p, p the modulus of res, with the least possible number of nonzero terms: a binomial x^n + a if one exists, otherwise a trinomial, a tetranomial or a pentanomial. Throws FLINT_ERROR if none of these exists; it is conjectured that a tetranomial (p > 2) or pentanomial (p = 2) always does.
An irreducible binomial of degree n exists if and only if every prime factor of n divides p - 1, and 4 \mid p - 1 if 4 \mid n. Among the polynomials with the least number of terms the function returns the first in the following order. A trinomial x^n + a x^k + b comes before its monic reversal x^n + a' x^{n-k} + b' if k < n - k. Writing f = x^n + a_1 x^{k_1} + \cdots + a_t x^{k_t} with n > k_1 > \cdots > k_t, the tuples (a_1, \ldots, a_t, k_1, \ldots, k_t) are ordered lexicographically, which favours small coefficients (all 1 if possible) and then small degrees of the middle terms. Sparse moduli make reduction cheap, see _nmod_poly_divrem_newton_n_preinv. The choice of defining polynomials for finite fields is discussed in Defining polynomials.
Guides#
The FLINT team, “nmod_poly_minimal_irreducible (nmod_poly.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/nmod_poly/nmod_poly_minimal_irreducible.html (generated 2026-10-20).
@misc{flint-doc-nmod-poly-nmod-poly-minimal-irreducible,
author = {{The FLINT team}},
title = {{nmod\_poly\_minimal\_irreducible (nmod\_poly.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/nmod_poly/nmod_poly_minimal_irreducible.html},
note = {Generated 2026-10-20}
}