Newton iteration for power series and division
- Cost
- With products of cost and middle products: inverse in about , power series quotient in about , division with remainder of length by length in about ; square roots and exponentials in a small constant times .
Newton's method doubles the number of correct terms of a power series approximation with each step. Since the last step dominates, computing an inverse, a quotient, a square root or an exponential to terms costs a small constant times one multiplication of length . Power series inversion by Newton iteration is due to Sieveking [Sie1972] and Kung [Kun1974]; Brent and Kung [BrentKung1978] treated general equations and elementary functions. Textbook treatments are [GG2003, Ch. 9] and [BZ2011, §4.2]; Hanrot and Zimmermann [HZ2004] and Bernstein [Ber2008] discuss the constants.
Throughout, the coefficients lie in for a word-size modulus (we write rather than to keep for the precision), is the bit length of , "to precision " means modulo , and is the cost of multiplying two polynomials of length . We assume, as is true for all methods in Multiplying polynomials over Z/nZ, that is nondecreasing, so . With the FFT, a low product of length and a middle product with output length cost about each (Middle products and the transposition principle).
Generic version#
The iterations described here are implemented once in gr_poly and are valid over any commutative ring, not only : each step uses ring operations and one inversion of the constant coefficient (the leading coefficient of the divisor for division with remainder), and the algorithms return GR_DOMAIN if that coefficient is not invertible. Over real and complex balls they give enclosures of the exact result, since every operation does. The generic dispatchers use the basecase for short inputs or when the ring has only classical multiplication (inverse and quotient of power series below length 9, division when the quotient or the divisor has length at most 10, exponential below length 10), Newton iteration otherwise, and middle products when the ring provides them (Division and Newton iteration). When a leading coefficient is not invertible, as for division by over , division with remainder and power series division fall back to algorithms that divide exactly at each step and succeed whenever the quotient lies in the ring. The rings nmod, fmpz_mod, mpn_mod and the fq family override the dispatchers to use their own basecase kernels and cutoffs, as nmod does with the tables quoted below; the ball rings divide through power series with error bounds.
The general step#
Lemma 1 (Quadratic convergence). Let , let satisfy with invertible, and let . If and , then .
Proof. Let . By Taylor expansion, and , so . Since , replacing by changes by . Hence .
FLINT runs Newton iterations from the target precision downwards: it records , until is below a cutoff, computes the solution to precision by a basecase (quadratic) algorithm, and then lifts from to . This avoids overshooting: no step computes more terms than are needed. The same scheme lifts -adic solutions, with in place of (Hensel lifting of inverses, square roots and Teichmüller lifts).
Inverse#
Let be a unit and . Then , and since ,
so is correct to terms and to . The first is the Newton step of Lemma 1 for . The low coefficients of are , so only the window has to be computed, which is a middle product, and .
Input: with a unit, a precision .
Output: .
- If is below the cutoff, compute by the recurrence , and return.
- Compute recursively, with (or in a third-order step).
- coefficients of (middle product).
Second order (): .
Third order (): .
Proposition 2. With middle products, Algorithm 1 with second-order steps costs about ; computing the full product instead of the middle product gives the classical bound of about [GG2003, Th. 9.4].
Proof. The step from to costs one middle product with output length and one low product of length , about , and the sum over all steps is at most about . Forming the low coefficients of the product of and instead costs about (a product with output length ), giving per step and about in total.
Exploiting the structure of the FFT further (reusing transforms between steps and between the two products) lowers the constant; the best known value is , due to Harvey [Har2011], who also gives for the square root. FLINT does not use these FFT-specific methods.
The third-order step costs one more short squaring but triples the precision, so there are fewer steps. FLINT uses it for in rings of finite characteristic, where it is 5–10% faster with the FFT. (Over and the coefficients of can be much larger than those of the result.)
In FLINT. nmod_poly_inv_series uses the recurrence (with _nmod_vec_dot_rev and delayed reduction) for , and otherwise calls the gr_poly code with the nmod context, which uses the recurrence if is below a cutoff depending on (NMOD_BITS(mod)), or if is short, and _gr_poly_inv_series_newton otherwise. With fft_small the cutoff is about 40 for , 80–300 for , about 400 for , and 230–450 above. The recurrence is used for any when is below a second table (between 39 and 141 for ; smaller moduli do not use this rule), since it costs only . If is a binomial , the inverse is a geometric series and is written down directly. nmod_poly_inv_series_newton is the same function.
Quotient of power series#
To compute , one could invert to terms and multiply. The Karp–Markstein trick [KM1997] instead merges the multiplication by into the last Newton step.
Lemma 3 (Karp–Markstein). Let and . Then .
Proof. , and both factors are because and . Dividing by gives the claim.
Input: , with a unit, a precision ; .
Output: .
- by Algorithm 1.
- (low product).
- (middle product; the low coefficients of vanish).
- Return .
This costs an inverse to terms plus three products of length about , about , instead of .
In FLINT. nmod_poly_div_series uses the recurrence for , and otherwise _gr_poly_div_series_newton (Algorithm 2) above a cutoff that, with fft_small, is about 80–340 for , about 600 for and 320–490 above, with a separate table for short .
Division with remainder#
Let with , , and . Write .
Lemma 4. . Consequently, if the leading coefficient of is a unit, .
Proof. Substitute in and multiply by ; the term is multiplied by . The constant term of is the leading coefficient of .
So the quotient is a power series quotient of length , which needs only the top coefficients of and of , and the remainder is , a low product.
Input: of length , of length with invertible leading coefficient; .
Output: , with , .
- Let be the reversal of the top coefficients of and the reversal of the top coefficients of .
- reversal of (Algorithm 2).
- (low product, then a subtraction of coefficients).
By Lemma 4 the algorithm is correct. For and it costs about , compared with operations for schoolbook division.
If many dividends are reduced modulo the same , the power series inverse of can be computed once (it is usually computed to terms; terms suffice). Then each quotient with is one low product, and the division costs two products: this is how _nmod_poly_div_newton_n_preinv, _nmod_poly_divrem_newton_n_preinv and everything built on them (nmod_poly_mulmod_preinv, nmod_poly_powmod_ui_binexp_preinv, nmod_poly_compose_mod_brent_kung_preinv) work. For a sparse divisor (at most five nonzero coefficients below the leading one, and ), _nmod_poly_divrem_newton_n_preinv instead eliminates directly, at a cost of a few operations per coefficient of the quotient.
In FLINT. nmod_poly_divrem and nmod_poly_rem use schoolbook division (_nmod_poly_divrem_basecase_preinv1, with delayed reduction) if or is less than 400 (for on x86-64 with AVX2; 200 without AVX2) or 80 (for ), and Algorithm 3 otherwise. Without fft_small, divide-and-conquer division is used instead for , and . nmod_poly_div uses schoolbook division if or , and steps 1 and 2 of Algorithm 3 otherwise.
Square roots#
Let be invertible and let have a square root in . For the reciprocal square root, let and . Since ,
FLINT uses this third-order iteration throughout (_gr_poly_rsqrt_series_newton): each step computes the square (low product), the window of (middle product), the short square and one low product with , and triples the precision. When the term in is dropped.
The square root itself is obtained from the reciprocal square root to half precision by a Karp–Markstein step:
Lemma 5. Let and , so that . Then .
Proof. . Here and , so .
For short , FLINT uses instead J. C. P. Miller's recurrence for powers [Knu1997, §4.7]: satisfies , which gives each coefficient of from the previous ones in operations. It divides by , so it is used only when is less than the modulus, and only for below a tuned bound (with fft_small, about 40 to 190 depending on , and only for ) and (square root) or (reciprocal square root).
nmod_poly_sqrt_series and nmod_poly_invsqrt_series call these algorithms. nmod_poly_sqrt, the square root of a polynomial that is a perfect square, removes an even power of , computes the series square root to half the length plus one, and checks the result by comparing the high half of its square (_nmod_poly_mulhigh) with the input.
Exponential and logarithm#
For , and of power series are defined if are invertible, which for prime modulus means . The logarithm is
one power series division and an integration (_gr_poly_log_series, called by nmod_poly_log_series; if is a binomial the coefficients are written down directly).
For the exponential, FLINT uses a Newton iteration that computes and together [HZ2004; BZ2011, §4.2.5].
Lemma 6. Let and , with of length . Then , and with
we have and .
Proof. Since , . Note . Let , which is . Then is the product of an and an series, so . Finally , so .
Input: with , a precision .
Output: (and optionally ).
- If is small, compute by the basecase and by Algorithm 1, and return.
- Recursively compute , to precision .
- coefficients of (middle product; these equal those of , as has degree ).
- , integrated as the coefficients of : .
- .
- If is needed at this precision: coefficients of (middle product) and .
Each step costs two middle products and three low products of length about ; the last step skips the update of unless is requested. Faster but more complicated methods are known: by van der Hoeven [vdH2010] and by Harvey [Har2009b], both relying on FFT-specific techniques.
The basecase uses the recurrence from , costing . An intermediate method (_gr_poly_exp_series_basecase_mul) splits with and uses . nmod_poly_exp_series uses the basecase if is below a tuned bound (230–490 with fft_small), the split method below a second bound (470–1491), and Algorithm 4 otherwise, with the second bound as its basecase cutoff. nmod_poly_exp_expinv_series computes the exponential and then inverts it; nmod_poly_sinh_series and nmod_poly_cosh_series use it. The other trigonometric and inverse trigonometric series functions are computed by their gr_poly counterparts.
Use in FLINT#
All the Newton iterations live in gr_poly and are called by nmod_poly through the gr context for , which supplies the nmod_poly multiplication and middle product and the tuned cutoffs quoted above (tables indexed by ).
| Operation | nmod_poly function | Iteration |
|---|---|---|
| inverse | nmod_poly_inv_series | _gr_poly_inv_series_newton |
| quotient | nmod_poly_div_series | _gr_poly_div_series_newton |
| division with remainder | nmod_poly_divrem, nmod_poly_div, nmod_poly_rem | _gr_poly_divrem_newton, _gr_poly_div_newton |
| with precomputed inverse | nmod_poly_divrem_newton_n_preinv, nmod_poly_div_newton_n_preinv | one low product per quotient |
| reciprocal square root | nmod_poly_invsqrt_series | _gr_poly_rsqrt_series_newton |
| square root | nmod_poly_sqrt_series, nmod_poly_sqrt | _gr_poly_sqrt_series_newton |
| exponential | nmod_poly_exp_series | _gr_poly_exp_series_newton |
| logarithm | nmod_poly_log_series | via _gr_poly_div_series |
The nmod_poly cutoffs between the basecase algorithms and Newton iteration are listed in Algorithms for series inversion and division and in Algorithms for division with remainder.
Power series composition and reversion, which also use Newton iteration for long series, are treated in Composition and modular composition.
void nmod_poly_inv_series(nmod_poly_t Qinv, const nmod_poly_t Q, slong n)void nmod_poly_div_series(nmod_poly_t Q, const nmod_poly_t A, const nmod_poly_t B, slong n)void nmod_poly_divrem(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B)void nmod_poly_divrem_newton_n_preinv(nmod_poly_t Q, nmod_poly_t R, const nmod_poly_t A, const nmod_poly_t B, const nmod_poly_t Binv)void nmod_poly_sqrt_series(nmod_poly_t g, const nmod_poly_t h, slong n)void nmod_poly_exp_series(nmod_poly_t f, const nmod_poly_t h, slong n)void nmod_poly_log_series(nmod_poly_t res, const nmod_poly_t f, slong n)Referenced from#
acb_poly_divrem- Power series in ball arithmetic (algorithm)
- Arithmetic in finite fields (overview)
- Hensel lifting of inverses, square roots and Teichmüller lifts (algorithm)
- Composition and modular composition (algorithm)
- Hensel lifting (algorithm)
- Middle products and the transposition principle (algorithm)
- Multiplying polynomials over Z/nZ (overview)
- Polynomial arithmetic over generic rings and its specialisations (overview)
- Multipoint evaluation and interpolation (algorithm)
arb_poly_divrem- Getting started with fmpq_poly
fmpq_poly_inv_series_newton- fmpq_poly.h (module)
- Getting started with fmpz_mod_poly
- fmpz_mod_poly.h (module)
_fmpz_mod_poly_divrem,fmpz_mod_poly_divrem- Division and pseudo-division
- fmpz_poly.h (module)
- Power series
- fq_nmod_poly.h (module)
- fq_poly.h (module)
- fq_zech_poly.h (module)
- gr_poly.h (module)
- Division with remainder
- nmod_poly.h (module)
- Power series inversion and division
- Computing modulo a fixed polynomial
- Multiplying polynomials
padic_poly_inv_series
References#
- [Sie1972] M. Sieveking, "An algorithm for division of power series", Computing 10 (1972), 153–156
- [Kun1974] H. T. Kung, "On computing reciprocals of power series", Numerische Mathematik 22 (1974), 341–348
- [BrentKung1978] Brent, R. P. and Kung, H. T. : Fast Algorithms for Manipulating Formal Power Series, J. ACM 25:4 (1978) 581–595
- [GG2003] J. von zur Gathen and J. Gerhard, Modern Computer Algebra, second edition, Cambridge University Press (2003)
- [BZ2011] R. P. Brent and P. Zimmermann, Modern Computer Arithmetic, Cambridge University Press (2011), http://www.loria.fr/~zimmerma/mca/pub226.html
- [HZ2004] G. Hanrot and P. Zimmermann, "Newton Iteration Revisited" (2004), http://www.loria.fr/~zimmerma/papers/fastnewton.ps.gz
- [Ber2008] D. J. Bernstein, "Fast multiplication and its applications", in Algorithmic Number Theory, MSRI Publications 44 (2008), 325–384
- [Har2011] D. Harvey, "Faster algorithms for the square root and reciprocal of power series", Mathematics of Computation 80 (2011), 387–394
- [KM1997] A. H. Karp and P. Markstein, "High-precision division and square root", ACM Transactions on Mathematical Software 23:4 (1997), 561–589
- [Knu1997] Knuth, D. E. The Art of Computer Programming, volume 2: Seminumerical algorithms, 1997
- [vdH2010] J. van der Hoeven, "Newton's method and FFT trading", Journal of Symbolic Computation 45:8 (2010), 857–878
- [Har2009b] D. Harvey, "Faster exponentials of power series", preprint (2009), https://arxiv.org/abs/0911.3110
The FLINT team, “Newton iteration for power series and division,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/polynomials/newton.html (generated 2026-11-02).
@misc{flint-doc-algorithms-polynomials-newton,
author = {{The FLINT team}},
title = {{Newton iteration for power series and division}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/polynomials/newton.html},
note = {Generated 2026-11-02}
}