Sparse interpolation
- Cost
- With a known support of monomials, evaluations and field operations to solve for the coefficients; with an unknown support, evaluations, operations for Berlekamp–Massey, root finding of a degree- polynomial and discrete logarithms.
The sparse GCD and factoring algorithms of FLINT reduce a problem in many variables to many problems in one or two variables, whose solutions are the values of the unknown polynomial (a GCD, a cofactor, a lifted factor) at chosen points. Sparse interpolation reconstructs a polynomial with terms from such values, independently of the number of variables and of the degrees, which would determine the cost of dense interpolation. The two classical approaches are Zippel's, which needs the support (set of monomials) of the result and finds it variable by variable [Zip1979; Zip1981], and Ben-Or and Tiwari's, which finds support and coefficients together from twice as many values [BenOrTiw1988; KalLak1988]. Both work over a finite field with large enough for the points chosen to be good with high probability; over the coefficients are then lifted or combined over several primes.
All methods need strict degree bounds . The number of values of (probes) they use, for with terms in variables, compares as follows; the presentation below, in particular of the Berlekamp–Massey algorithm as a half-gcd computation, follows Schultz's notes [Sch-mpoly].
| Method | Probes | Main difficulties |
|---|---|---|
| dense, variable by variable (Newton) | enough evaluation points | |
| Zippel (Zippel's variable-by-variable method) | about | enough points; inconsistent or underdetermined systems when the shape assumption fails; the linear algebra |
| Ben-Or–Tiwari (Unknown support: Ben-Or–Tiwari) | an element of order at least ; the linear algebra, root finding and discrete logarithms |
For Zippel's method the count comes from adding one variable at a time: each of the images needed for the new variable is found from as many probes as the current support has terms, at most .
Throughout, with distinct and nonzero . For a point write for the value of the -th monomial.
Known support: transposed Vandermonde systems#
If the are known, evaluating at the powers (componentwise) gives
a linear system for the whose matrix is a transposed Vandermonde matrix scaled by the . It is nonsingular if and only if the are distinct, and it can be solved in quadratic time.
Lemma 1 (Transposed Vandermonde solution). Let with distinct nonzero , and let . Then
All can be computed with operations from the and the coefficients of .
Proof. , and for , while . Given , the coefficients of follow by synthetic division in operations, and the numerator and denominator are accumulated during that division.
_nmod_zip_vand_solve implements this. With more than values it also checks the remaining equations, which detects a wrong support: it returns if two coincide (choose another point) and if the system is inconsistent (the assumed support was wrong).
Zippel's variable-by-variable method#
Zippel's algorithm applies this inside a recursion on the variables. Suppose has been interpolated in with the remaining variables at random values; write it as , the shape. To add , Zippel assumes that each coefficient of as a polynomial in has the same monomials in as in the image; new images at other values of are then found by Lemma 1 instead of a full recursive computation, and the dependence on is recovered by dense univariate interpolation.
Lemma 2 (Probability of a wrong shape). Let and let over monomials in . If the values of are chosen uniformly at random from , the image has fewer monomials than has distinct with probability at most .
Proof. The image lacks exactly when ; each is a nonzero polynomial of degree at most , so this has probability at most by the Schwartz–Zippel lemma (Lemma 1 of GCDs over small finite fields), and there are at most of them.
The method needs values per variable for degree , against for dense interpolation. A wrong shape is detected later, because the linear systems become inconsistent or the final verification (a division) fails, and the computation is restarted with new points.
Scaled images#
In GCD computations the values are not values of itself: an image is only determined up to a nonzero scalar unless the leading coefficient of the GCD is known. If the GCD is and the images are , then
a linear system in the and the , homogeneous, and normalised by fixing one coefficient. De Kleine, Monagan and Wittkopf [dKMW2005] solve it by eliminating the with the structure of Lemma 1 for each , which leaves a small system for the scalars. nmod_mpolyl_gcds_zippel does this (with a shortcut when the leading coefficient is a monomial, which makes the images monic).
Unknown support: Ben-Or–Tiwari#
Theorem 3 (Ben-Or–Tiwari). With for and distinct , the sequence satisfies the linear recurrence with characteristic polynomial , that is, for all , and no recurrence of smaller order. is determined by and can be computed from them by the Berlekamp–Massey algorithm in operations.
Proof. . A recurrence of order would give for a nonzero of degree and all , that is, a vanishing combination of the geometric sequences with coefficients , not all zero since has fewer than roots; this contradicts the independence of geometric sequences with distinct ratios (a Vandermonde determinant). The minimal polynomial of a linearly recurrent sequence of order is determined by its first terms, and the Berlekamp–Massey algorithm [Mas1969; ADL2006] finds it with operations.
The roots of are the monomial values , from which the exponents must be recovered, and then the coefficients follow by Lemma 1. Two devices make the recovery cheap:
- Kronecker substitution: with degree bounds , the substitution , , maps the monomials of injectively to powers of one variable , with exponents (Lemma 4 of Sparse and dense multiplication).
- Discrete logarithms: choose a prime for which has only small prime factors, and a generator of . Evaluating at gives , the are distinct because , and is the discrete logarithm of , computed by the Pohlig–Hellman algorithm [PohHel1978] in time polynomial in the largest prime factor of .
In practice the number of terms is unknown: the Berlekamp–Massey algorithm is run incrementally as values arrive, and the candidate is accepted when it stops changing, its roots are all in and distinct, the discrete logarithms are below , and the resulting polynomial passes a check at a random point. Compared with Zippel's method this needs about values in total instead of per variable, but the prime must be larger than , which grows with the degrees and the number of variables.
fmpz_mpolyl_gcd_zippel2 uses this for the coefficients of a GCD with respect to its two main variables (Sparse interpolation with Berlekamp–Massey): fmpz_next_smooth_prime chooses the prime, nmod_berlekamp_massey_t (or fmpz_mod_berlekamp_massey_t for primes beyond a word) runs the recurrence, the roots are found with nmod_poly root finding, and nmod_discrete_log_pohlig_hellman_run gives the exponents. Images modulo further primes reuse the support and only solve transposed Vandermonde systems.
Berlekamp–Massey as a partial Euclidean algorithm#
FLINT computes the recurrence of Theorem 3 by rational reconstruction with the extended Euclidean algorithm, in a form that accepts the values in batches and reuses the previous work, with the half-gcd for large steps [ThullYap1990]. For values ( a field) write
so that is the truncation of the series. If with , , as above and a shift , then
a rational function whose reduced denominator is when the are distinct, since every numerator is nonzero. Finding is therefore a rational reconstruction problem.
Theorem 4 (Rational reconstruction). Suppose that with , and that satisfy
Then .
Proof. Dividing by gives . Here , and because . Hence is . A nonzero numerator would make it at least of order , and , so the numerator is zero.
The Euclidean remainder sequence , , of Half-GCD comes with Bézout coefficients , . At the index of the half-gcd, , so and : if also , the theorem applies to . Conversely, if the series has a denominator of degree , then has degree less than , and by the uniqueness of rational reconstruction [GG2003, §5.7] is a multiple of the row , a scalar multiple because and are coprime. So values determine , as the half-gcd row made monic.
Since is not known, the computation is repeated as values are added, and is accepted once further values no longer change it. The next theorem shows how the half-gcd for values is extended to values. We use the notation of Half-GCD: with a product of quotient matrices, and the degree of the first entry.
Theorem 5 (Extending the half-gcd). Let be the matrix of the half-gcd of , with remainders , , and let with . Define
Then , are consecutive remainders of with and . If , then is the matrix of the half-gcd of . Otherwise let , , , and . Then , and if is the matrix of the half-gcd of , the matrix of the half-gcd of is with .
Proof. The entries of , and hence of , have degree at most . So the second term has degree less than , while has degree : thus , and because also has degree less than . As , Lemma 1 of Half-GCD shows that are consecutive remainders of (this is the lifting lemma Lemma 3 of Half-GCD with ). If they are the half-gcd remainders. Otherwise gives , and gives . The pair consists of the next consecutive remainders. By the lifting lemma applied to split at , the remainders are consecutive with , where is the first half-gcd remainder of , whose first entry has degree . The bound on the degrees of the entries of used above gives, in the same way, . So are the half-gcd remainders of .
The algorithm keeps the remainders and the second Bézout coefficients (the first ones are not needed), with ; multiplying and by the same matrix on the left preserves these relations.
State: ; as above, initially , , , , . Input: new values . Output: the updated state; is the candidate denominator.
- Let . Set for and .
- If , return: has not changed.
- Do one Euclidean step: , , .
- Let and . If is small, do Euclidean steps until . Otherwise compute the half-gcd matrix of and replace and by and .
By Theorem 5 the state after step 4 is the half-gcd of with its Bézout coefficients, and by Theorem 4 is the denominator of the series as soon as . When the new values do not change the reconstruction, only step 1 is executed, at the cost of two products of polynomials of degrees at most and less than . When they do, the half-gcd works on polynomials of degree , about twice the number of Euclidean steps still needed, rather than on polynomials of degree .
nmod_berlekamp_massey_reduce implements Algorithm 1, using Euclidean steps when and nmod_poly_hgcd otherwise; it returns whether changed. fmpz_mod_berlekamp_massey_reduce has the same structure but always uses Euclidean steps. In fmpz_mpolyl_gcd_zippel2 each coefficient of the bivariate GCD has its own instance; the values are the images at the successive powers of the evaluation point, the reduction is run after every eighth value, and a reduction that leaves a set of candidates unchanged triggers the root finding of Unknown support: Ben-Or–Tiwari and the verification. The coefficients then follow from the roots and the first values by Lemma 1, with the shift divided out.
Sparse interpolation in Hensel lifting#
In sparse Hensel lifting [Zip1981; Kal1985; MonTun2020] the unknowns are the coefficients of the lifted factors as polynomials in the new variable : each coefficient of is assumed to have the same support in the previous variables as the factor itself, and its values are obtained from bivariate factorisations at the points for . The values of all factors at the same points are only determined up to scalars whose product is known, and the leading coefficients are imposed as in the GCD case. nmod_mpoly_hlift_zippel (over ) and the -adic lifting inside fmpz_mpoly_factor_irred_zippel work this way; see Sparse Hensel lifting.
Use in FLINT#
- Transposed Vandermonde systems (Lemma 1):
_nmod_zip_vand_solve,_n_fq_zip_vand_solve,_n_fqp_zip_vand_solve, with the evaluation helpers_nmod_zip_eval_stepandn_polyun_zip_start,n_polyun_zip_solve. - Zippel's GCD with scaled images (Scaled images):
nmod_mpolyl_gcds_zippel,nmod_mpolyl_gcdp_zippel_smprime, used byfmpz_mpolyl_gcd_zippelandnmod_mpoly_gcd_zippel. - Ben-Or–Tiwari (Theorem 3):
fmpz_mpolyl_gcd_zippel2, withnmod_berlekamp_massey_t,fmpz_mod_berlekamp_massey_t,nmod_discrete_log_pohlig_hellman_tandfmpz_mod_discrete_log_pohlig_hellman_t. - Incremental Berlekamp–Massey (Algorithm 1):
nmod_berlekamp_massey_reduce(withnmod_poly_hgcd),fmpz_mod_berlekamp_massey_reduce. - Sparse Hensel lifting:
nmod_mpoly_hlift_zippel,fmpz_mpoly_factor_irred_zippel,nmod_mpoly_factor_irred_smprime_zippel.
int fmpz_mpolyl_gcd_zippel(fmpz_mpoly_t G, fmpz_mpoly_t Abar, fmpz_mpoly_t Bbar, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_ctx_t ctx, flint_rand_t randstate)int fmpz_mpolyl_gcd_zippel2(fmpz_mpoly_t G, fmpz_mpoly_t Abar, fmpz_mpoly_t Bbar, const fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_mpoly_t Gamma, const fmpz_mpoly_ctx_t ctx)int nmod_mpolyl_gcds_zippel(nmod_mpoly_t G, const ulong * Gmarks, slong Gmarkslen, nmod_mpoly_t A, nmod_mpoly_t B, slong *perm, slong l, slong var, const nmod_mpoly_ctx_t ctx, flint_rand_t state, slong * Gdegbound, n_poly_t Amarks, n_poly_t Bmarks)int nmod_mpoly_hlift_zippel(slong m, nmod_mpoly_struct * B, slong r, const ulong * alpha, const nmod_mpoly_t A, const slong * degs, const nmod_mpoly_ctx_t ctx, flint_rand_t state)Referenced from#
- Greatest common divisors (algorithm)
- Multivariate Hensel lifting (algorithm)
- GCDs over small finite fields (algorithm)
- Multivariate polynomials: representations and algorithms (overview)
nmod_berlekamp_massey_reduce
References#
- [Zip1979] R. Zippel. Probabilistic algorithms for sparse polynomials. Symbolic and Algebraic Computation (EUROSAM 1979), Lecture Notes in Computer Science 72, Springer, 1979, 216–226. https://doi.org/10.1007/3-540-09519-5_73
- [Zip1981] R. Zippel. Newton's iteration and the sparse Hensel algorithm. Proceedings of SYMSAC 1981, ACM, 68–72. https://doi.org/10.1145/800206.806373
- [BenOrTiw1988] M. Ben-Or and P. Tiwari. A deterministic algorithm for sparse multivariate polynomial interpolation. Proceedings of STOC 1988, ACM, 301–309. https://doi.org/10.1145/62212.62241
- [KalLak1988] E. Kaltofen and Y. N. Lakshman. Improved sparse multivariate polynomial interpolation algorithms. Symbolic and Algebraic Computation (ISSAC '88), Lecture Notes in Computer Science 358, Springer, 1989, 467–474. https://doi.org/10.1007/3-540-51084-2_44
- [Sch-mpoly] D. Schultz. Algorithms for multivariate polynomials. Notes in the FLINT source tree, src/mpoly/doc/MPolyAlgorithms.tex.
- [dKMW2005] J. de Kleine, M. Monagan and A. Wittkopf. Algorithms for the non-monic case of the sparse modular GCD algorithm. Proceedings of ISSAC 2005, ACM, 124–131. https://doi.org/10.1145/1073884.1073903
- [Mas1969] J. L. Massey. Shift-register synthesis and BCH decoding. IEEE Transactions on Information Theory 15 (1969), 122–127.
- [ADL2006] N. B. Atti, G. M. Diaz-Toca and H. Lombardi. The Berlekamp–Massey algorithm revisited. Applicable Algebra in Engineering, Communication and Computing 17 (2006), 75–82. https://doi.org/10.1007/s00200-005-0190-z
- [PohHel1978] S. C. Pohlig and M. E. Hellman, "An improved algorithm for computing logarithms over GF(p) and its cryptographic significance", IEEE Transactions on Information Theory 24 (1978), 106–110, https://doi.org/10.1109/TIT.1978.1055817
- [ThullYap1990] Thull, K. and Yap, C. : A Unified Approach to HGCD Algorithms for Polynomials and Integers, (1990)
- [GG2003] J. von zur Gathen and J. Gerhard, Modern Computer Algebra, second edition, Cambridge University Press (2003)
- [Kal1985] E. Kaltofen. Sparse Hensel lifting. EUROCAL '85, Lecture Notes in Computer Science 204, Springer, 1985, 4–17. https://doi.org/10.1007/3-540-15984-3_230
- [MonTun2020] M. Monagan and B. Tuncer. The complexity of sparse Hensel lifting and sparse polynomial factorization. Journal of Symbolic Computation 99 (2020), 189–230. https://doi.org/10.1016/j.jsc.2019.05.001
The FLINT team, “Sparse interpolation,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/multivariate/sparse-interpolation.html (generated 2026-11-02).
@misc{flint-doc-algorithms-multivariate-sparse-interpolation,
author = {{The FLINT team}},
title = {{Sparse interpolation}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/multivariate/sparse-interpolation.html},
note = {Generated 2026-11-02}
}