fmpz_poly_roots_fmpz, fmpz_poly_roots_fmpq
#include <flint/fmpz_poly.h>slong fmpz_poly_roots_fmpz(fmpz * res, slong * exp, const fmpz_poly_t poly)sourceslong fmpz_poly_roots_fmpq(fmpq * res, slong * exp, const fmpz_poly_t poly)sourceCompute 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.
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).
@misc{flint-doc-fmpz-poly-fmpz-poly-roots-fmpz,
author = {{The FLINT team}},
title = {{fmpz\_poly\_roots\_fmpz, fmpz\_poly\_roots\_fmpq (fmpz\_poly.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/fmpz_poly/fmpz_poly_roots_fmpz.html},
note = {Generated 2026-10-20}
}