FLINT3.7.0-dev
Algorithm

Defining polynomials

Cost
A table lookup for Conway polynomials; an expected O(d)O(d) irreducibility tests for random search; primitivity testing requires the factorisation of pd−1p^d - 1.

A field Fpd\mathbb{F}_{p^d} is constructed as Fp[x]/(f)\mathbb{F}_p[x]/(f) for an irreducible ff of degree dd. Any such ff gives an isomorphic field, but the choice matters in practice:

  • a sparse ff, with few nonzero terms, makes the reduction after each multiplication cheap (Reduction modulo the defining polynomial);
  • a primitive ff, whose roots generate Fq×\mathbb{F}_q^\times, is required by the Zech logarithm representation and gives a known generator of the multiplicative group (used, for example, as the non-square in fq_sqrt);
  • a standard ff makes results reproducible across systems and allows compatible embeddings between fields of different degrees.

Counting irreducible and primitive polynomials#

The number of monic irreducible polynomials of degree dd over Fp\mathbb{F}_p is 1d∑e∣dμ(d/e)pe\frac{1}{d} \sum_{e \mid d} \mu(d/e) p^e, which lies between pd/d−2pd/2/dp^d/d - 2p^{d/2}/d and pd/dp^d/d [LN1997]; so a random monic polynomial of degree dd is irreducible with probability about 1/d1/d, and random search with an irreducibility test (Irreducibility testing over finite fields) needs about dd attempts. Of the pd−1p^d - 1 nonzero elements, φ(pd−1)\varphi(p^d - 1) are primitive, and each primitive polynomial has dd primitive roots, so there are φ(pd−1)/d\varphi(p^d - 1)/d primitive polynomials, roughly a fraction φ(pd−1)/(pd−1)\varphi(p^d - 1)/(p^d - 1) of the irreducible ones, which is at least c/log⁡log⁡(pd)c/\log\log(p^d) for a constant c>0c > 0. Testing primitivity requires the factorisation of pd−1p^d - 1 (fq_multiplicative_order).

Conway polynomials#

Definition 1. The Conway polynomial Cp,dC_{p,d} is the least monic primitive polynomial ff of degree dd over Fp\mathbb{F}_p, in a fixed ordering of polynomials, such that for every proper divisor mm of dd, the polynomial Cp,m(x(pd−1)/(pm−1))C_{p,m}(x^{(p^d - 1)/(p^m - 1)}) is divisible by ff.

The ordering is lexicographic on the sequence (−fd−1,fd−2,−fd−3,…,(−1)df0)(-f_{d-1}, f_{d-2}, -f_{d-3}, \ldots, (-1)^d f_0) of coefficients with alternating signs, each reduced to an integer in [0,p)[0, p). The compatibility condition says that if αd\alpha_d is a root of Cp,dC_{p,d} and m∣dm \mid d, then αd(pd−1)/(pm−1)\alpha_d^{(p^d - 1)/(p^m - 1)} is a root of Cp,mC_{p,m}; so the roots of the Conway polynomials of all degrees form a compatible system, and the field Fp[x]/(Cp,m)\mathbb{F}_p[x]/(C_{p,m}) embeds into Fp[x]/(Cp,d)\mathbb{F}_p[x]/(C_{p,d}) by x↦x(pd−1)/(pm−1)x \mapsto x^{(p^d-1)/(p^m-1)}. Conway polynomials were defined by Parker for the computation of modular character tables and named after J. H. Conway; they are used by GAP, Magma, Sage and other systems as the standard defining polynomials. Computing them is expensive, since the definition requires a search through primitive polynomials (with the factorisation of pd−1p^d - 1) and compatibility tests; Heath and Loehr give algorithms [HeaLoe2004], and Lübeck maintains the reference tables [Lüb2004].

FLINT stores a compressed copy of Lübeck's table in nmod_poly (_nmod_poly_conway), for all primes p<109988p < 109988 and the degrees for which a Conway polynomial is known: degrees up to 409 for p=2p = 2, up to about 200 for p<20p < 20, and fewer for larger primes (up to 12 for p<300p < 300, 9 for p<3371p < 3371, 6 for p<11000p < 11000 and 4 above), in each case with gaps. Since Conway polynomials are primitive, they are always suitable for the Zech representation, but they are not sparse in general.

Sparse and minimal-weight polynomials#

When no Conway polynomial is available, the modules choose sparse polynomials, which minimise the cost of reduction.

Binomials. By a classical theorem [LN1997], xd−ax^d - a is irreducible over Fp\mathbb{F}_p if and only if every prime divisor of dd divides the order ee of aa but not (p−1)/e(p - 1)/e, and p≡1(mod4)p \equiv 1 \pmod 4 if 4∣d4 \mid d. In particular an irreducible binomial of degree dd exists only if every prime factor of dd divides p−1p - 1.

Trinomials xd+axk+bx^d + a x^k + b exist for most but not all (p,d)(p, d): by Swan's theorem there is no irreducible trinomial of degree d≡0(mod8)d \equiv 0 \pmod 8 over F2\mathbb{F}_2 [Swa1962], and other obstructions are known. It is conjectured that an irreducible tetranomial (p>2p > 2) or pentanomial (p=2p = 2) always exists.

nmod_poly_minimal_irreducible returns a monic irreducible polynomial with the least possible number of terms, trying binomials, trinomials, tetranomials and pentanomials in this order and returning the first one in a fixed ordering, after sieving out candidates with small factors; it is deterministic. fmpz_mod_poly_randtest_sparse_irreducible draws random irreducible trinomials, then pentanomials, then random sparse polynomials, for multiprecision pp.

Choices in FLINT#

ModuleDefault defining polynomial
fq (fq_ctx_init)Conway polynomial if p<109988p < 109988 and it is in the table; otherwise a random sparse irreducible polynomial (trinomial or pentanomial if one is found), with a fixed random state
fq_nmod (fq_nmod_ctx_init_ui)Conway polynomial if in the table; otherwise the minimal-weight polynomial of nmod_poly_minimal_irreducible
fq_zech (fq_zech_ctx_init_ui)Conway polynomial if in the table; otherwise a random monic primitive polynomial (nmod_poly_randtest_monic_primitive, which draws random irreducible polynomials until the root is primitive)
fq_defaultthat of the representation it chooses

In all modules a polynomial can also be given explicitly (fq_ctx_init_modulus and its analogues); it must be irreducible, and primitive for fq_zech. The choices for fq and fq_zech without a Conway polynomial are reproducible for a given FLINT version, but are not standardised; programs that exchange elements with other software should give the defining polynomial explicitly.

Use in FLINT#

Referenced from#

References#

  • [LN1997] R. Lidl and H. Niederreiter. Finite Fields. Second edition, Encyclopedia of Mathematics and its Applications 20, Cambridge University Press, 1997.
  • [HeaLoe2004] L. S. Heath and N. A. Loehr. New algorithms for generating Conway polynomials over finite fields. Journal of Symbolic Computation 38:2 (2004), 1003–1024.
  • [Lüb2004] F. Lübeck, "Conway polynomials for finite fields", RTWH Aachen, https://www.math.rwth-aachen.de/~Frank.Luebeck/data/ConwayPol/index.html, (accessed 2024-01-12)
  • [Swa1962] R. G. Swan. Factorization of polynomials over finite fields. Pacific Journal of Mathematics 12 (1962), 1099–1106.
Cite this page

The FLINT team, “Defining polynomials,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/finite-fields/defining-polynomials.html (generated 2026-11-02).