FLINT3.7.0-dev

_fmpz_poly_cyclotomic, fmpz_poly_cyclotomic

Synopsis#include <flint/fmpz_poly.h>
void _fmpz_poly_cyclotomic(fmpz * a, ulong n, nn_ptr factors, slong num_factors, ulong phi)source
void fmpz_poly_cyclotomic(fmpz_poly_t poly, ulong n)source

Set poly to the cyclotomic polynomial Φn(x)=∏ω(x−ω)\Phi_n(x) = \prod_\omega (x - \omega), where ω\omega runs over the primitive nn-th roots of unity. The non-underscore version writes n=qsn = qs with qq squarefree and uses Φn(x)=Φq(xs)\Phi_n(x) = \Phi_q(x^s).

The underscore version requires n≥3n \ge 3 squarefree, the array factors of its num_factors prime factors (with 2 first if nn is even) and φ(n)\varphi(n) as phi, and writes only the low ⌊(φ(n)+1)/2⌋\lfloor (\varphi(n) + 1)/2 \rfloor coefficients; the others follow by symmetry, since Φn\Phi_n is palindromic for n≠1n \ne 1. It uses the sparse power series algorithm (Algorithm 4) of [ArnoldMonagan2011], based on Φn(x)=∏d∣n(xd−1)μ(n/d)\Phi_n(x) = \prod_{d \mid n} (x^d - 1)^{\mu(n/d)}, in which multiplications and divisions by xd−1x^d - 1 cost O(φ(n))O(\varphi(n)) additions, for O(2kφ(n))O(2^k \varphi(n)) operations in total for kk prime factors. Machine integers are used when no overflow is possible: by Table 6 of [ArnoldMonagan2011], all coefficients of Φn\Phi_n have at most 27 bits for n<10163195n < 10163195 and at most 60 bits for n<169828113n < 169828113, and they are 0,±10, \pm 1 when nn has two prime factors. The cases n=pn = p and n=2mn = 2m with mm odd (Φn(x)=Φm(−x)\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
Cite this page

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-11-02).