_fmpz_poly_cyclotomic, fmpz_poly_cyclotomic
#include <flint/fmpz_poly.h>void fmpz_poly_cyclotomic(fmpz_poly_t poly, ulong n)sourceSet poly to the cyclotomic polynomial \Phi_n(x) = \prod_\omega (x - \omega), where \omega runs over the primitive n-th roots of unity. The non-underscore version writes n = qs with q squarefree and uses \Phi_n(x) = \Phi_q(x^s).
The underscore version requires n \ge 3 squarefree, the array factors of its num_factors prime factors (with 2 first if n is even) and \varphi(n) as phi, and writes only the low \lfloor (\varphi(n) + 1)/2 \rfloor coefficients; the others follow by symmetry, since \Phi_n is palindromic for n \ne 1. It uses the sparse power series algorithm (Algorithm 4) of [ArnoldMonagan2011], based on \Phi_n(x) = \prod_{d \mid n} (x^d - 1)^{\mu(n/d)}, in which multiplications and divisions by x^d - 1 cost O(\varphi(n)) additions, for O(2^k \varphi(n)) operations in total for k prime factors. Machine integers are used when no overflow is possible: by Table 6 of [ArnoldMonagan2011], all coefficients of \Phi_n have at most 27 bits for n < 10163195 and at most 60 bits for n < 169828113, and they are 0, \pm 1 when n has two prime factors. The cases n = p and n = 2m with m odd (\Phi_n(x) = \Phi_m(-x)) are handled directly.
References#
- [ArnoldMonagan2011] Arnold, Andrew and Monagan, Michael : Calculating cyclotomic polynomials, Mathematics of Computation 80:276 (2011) 2359–2379
The FLINT team, “_fmpz_poly_cyclotomic, fmpz_poly_cyclotomic (fmpz_poly.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpz_poly/_fmpz_poly_cyclotomic.html (generated 2026-10-20).
@misc{flint-doc-fmpz-poly-fmpz-poly-cyclotomic,
author = {{The FLINT team}},
title = {{\_fmpz\_poly\_cyclotomic, fmpz\_poly\_cyclotomic (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_cyclotomic.html},
note = {Generated 2026-10-20}
}