FLINT3.7.0-dev

nmod_poly_minimal_irreducible

Synopsis#include <flint/nmod_poly.h>
void nmod_poly_minimal_irreducible(nmod_poly_t res, ulong n)source

Sets 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#

Cite this page

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).