FLINT3.7.0-dev

fmpz_poly_roots_fmpz, fmpz_poly_roots_fmpq

Synopsis#include <flint/fmpz_poly.h>
slong fmpz_poly_roots_fmpz(fmpz * res, slong * exp, const fmpz_poly_t poly)source
slong fmpz_poly_roots_fmpq(fmpq * res, slong * exp, const fmpz_poly_t poly)source

Compute the distinct integer (respectively rational) roots of the nonzero polynomial poly, write them to res in increasing order and return their number. If exp is not NULL, the multiplicities are written to exp. The arrays must have room for \deg(\mathit{poly}) entries. A zero polynomial raises an exception.

After removing roots at zero, if the constant and leading coefficients are small with few divisors, the candidates a/b with a dividing the constant and b the leading coefficient are tested directly. Otherwise the roots are found modulo a suitable prime p, lifted p-adically by Newton iteration to the precision needed to recover rational roots of bounded height, and verified. This is much faster than factoring the polynomial. Multiplicities are found with a squarefree factorisation, computed only if the polynomial is not squarefree.

Cite this page

The FLINT team, “fmpz_poly_roots_fmpz, fmpz_poly_roots_fmpq (fmpz_poly.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpz_poly/fmpz_poly_roots_fmpz.html (generated 2026-10-20).