Reduction modulo the defining polynomial
- Cost
- multiplications in for a polynomial of length and a defining polynomial with nonzero terms; for Newton division.
In the polynomial representations of fq and fq_nmod, an element of , , is stored as its representative of degree less than . A product of two elements is computed as a product of polynomials, of length at most , and then reduced modulo . For the small degrees that are common in practice the reduction costs about as much as the product, so FLINT chooses defining polynomials with few nonzero terms when it can (Defining polynomials) and exploits them.
Throughout, let , with nonzero terms in total, so that the sum runs over exponents . The context stores the coefficients and the exponents of the monic polynomial , which generates the same ideal as .
Sparse elimination#
Input: .
Output: , in the coefficients .
- For : for every , ; then .
- Reduce modulo .
Proposition 1. Algorithm 1 computes with multiplications.
Proof. Step 1 replaces by , which does not change its class modulo and clears the coefficient of , since has leading term ; the coefficients modified have indices . After the iteration for , all coefficients of index at least are zero, so at the end . Each iteration costs multiplications.
For a product, , so a trinomial costs multiplications, much less than a product of polynomials of degree . _fq_sparse_reduce works with unreduced integer coefficients (fmpz_submul) and reduces modulo only at the end, so the coefficients grow by about bits per elimination that touches them; this is cheaper than reducing after every step for the small for which the method is used. _fq_nmod_sparse_reduce reduces after each step and has four variants: for the update is an exclusive or of bits; if all are 1 (as for and other polynomials with unit coefficients), only subtractions are needed; for the update fits in one word and is reduced with a Barrett reduction (n_mod_barrett); otherwise nmod_addmul is used.
Newton division#
For a dense defining polynomial, the reduction is a division with remainder by using a precomputed power series inverse. Let denote the reversal of a polynomial of length . When the context is created, the series is computed and stored (ctx->inv).
Proposition 2. Let with , and let with . Then .
Proof. Reversing gives . Modulo the last term vanishes, and multiplying by , the inverse of modulo and hence modulo because , gives the claim.
The quotient thus costs one truncated product of length and the remainder another product, about operations in all, independently of the number of terms of [GG2003, §9.1]. _fq_dense_reduce and _fq_nmod_dense_reduce call _fmpz_mod_poly_divrem_newton_n_preinv and _nmod_poly_divrem_newton_n_preinv, which require ; this is the precondition of fq_reduce and fq_nmod_reduce for dense moduli. The sparse method has no such limit, and fq_set_fmpz_poly and fq_nmod_set_nmod_poly use a general division for longer inputs.
_fq_reduce and _fq_nmod_reduce use Algorithm 1 if has at most five nonzero terms (the flag sparse_modulus, set when the context is created) and Newton division otherwise. With and , the sparse method costs at most multiplications.
Delayed reduction#
Since reduction is linear, a sum of products of elements can be reduced once: the products of the representatives are accumulated as an unreduced polynomial of length , over for fq or modulo for fq_nmod, and only the sum is reduced. The dot products of _fq_vec_dot and _fq_nmod_vec_dot (implemented in the gr contexts), and hence the classical matrix and polynomial multiplications, which are built on them, save all but one reduction per output entry. Kronecker substitution (Multiplying polynomials over finite fields, fq_mat_mul_KS) goes further: the whole product is computed over and each output coefficient is reduced once when it is unpacked.
Use in FLINT#
_fq_reduce,_fq_sparse_reduce,_fq_dense_reduceandfq_reduceinfq;_fq_nmod_reduce,_fq_nmod_sparse_reduce,_fq_nmod_dense_reduceandfq_nmod_reduceinfq_nmod.fq_mul,fq_sqr,_fq_pow,fq_bit_unpackand the correspondingfq_nmodfunctions reduce every product.- The
fq_zechmultiplication algorithm for polynomials reduces the blocks of the substituted product with its own copy of Algorithm 1, accumulating several updates in one word when .
Referenced from#
- Defining polynomials (algorithm)
- Arithmetic in unramified extensions (algorithm)
- fq.h (module)
- fq_nmod.h (module)
_fq_nmod_reduce,_fq_nmod_sparse_reduce,_fq_nmod_dense_reduce
References#
- [GG2003] J. von zur Gathen and J. Gerhard, Modern Computer Algebra, second edition, Cambridge University Press (2003)
The FLINT team, “Reduction modulo the defining polynomial,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/finite-fields/reduction.html (generated 2026-11-02).
@misc{flint-doc-algorithms-finite-fields-reduction,
author = {{The FLINT team}},
title = {{Reduction modulo the defining polynomial}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/finite-fields/reduction.html},
note = {Generated 2026-11-02}
}