Hensel lifting of inverses, square roots and Teichmüller lifts
- Cost
- Inverse and square root to precision : bit operations in and in , plus the cost at precision 1; Teichmüller lift: multiplications at each precision, in total for .
Many -adic quantities are roots of an equation whose reduction modulo is easy to solve: the inverse of a unit, a square root, a root of unity. Hensel's lemma [Hen1908] lifts a simple root modulo to a root modulo , and in the Newton form used by FLINT each step doubles the number of correct digits, so the whole computation costs a constant number of multiplications at the target precision. The same pattern appears for power series in Newton iteration for power series and division; textbook treatments are [GG2003, §9] and [BZ2011, §4.2].
Throughout, is or the ring of integers of an unramified extension of degree (Arithmetic in unramified extensions); in both rings generates the maximal ideal and is a field. is the cost of multiplying -bit integers.
Newton's method in R#
Lemma 1 (Quadratic convergence). Let , let and let with and . Then satisfies , and .
Proof. By Taylor expansion, with . With we get , and both terms are divisible by .
In particular, if is a unit at a root of modulo , there is a unique root of in congruent to modulo (Hensel's lemma), and Newton's iteration converges to it. The inverse need only be known to the current precision, so it can be updated by its own Newton step instead of being recomputed.
The precision sequence#
FLINT runs the iteration from the target precision downwards. For a target , _padic_lifts_exps computes
and _padic_lifts_pows computes the moduli with about one multiplication each, since is the square of , possibly divided by . The input is reduced modulo every once, from the top. Then the root is found modulo and lifted through by Lemma 1, which applies because . Lifting to and then to , rather than doubling from 1, never computes more digits than needed.
Proposition 2. If one step at precision costs and is nondecreasing, the whole iteration costs at most plus the cost of the base case modulo .
Proof. Since , the sum of over is bounded by a geometric series with ratio up to the rounding terms.
Inverses#
For a unit the inverse is the root of ; the Newton step simplifies to
so the number of correct digits doubles exactly, as the identity on the right shows without appeal to Lemma 1. _padic_inv_precomp computes modulo by the extended Euclidean algorithm (fmpz_invmod) and applies the step modulo , using at each level the reduction of modulo . Each step costs two multiplications and a reduction. _padic_inv uses fmpz_invmod alone for and, for , fmpz_invmod_2exp, which runs the same iteration on the limbs of without divisions. In , _qadic_inv uses the same step with products reduced modulo the defining polynomial, and computes the inverse modulo by the extended Euclidean algorithm in .
Square roots#
Let be a unit. FLINT computes the inverse square root by Newton's method for and obtains the square root at the last step, a variant of the Karp–Markstein trick. Write .
Lemma 3. Let be odd. If and , then . If , and , then .
Proof. We have . For odd , and are units, and is divisible by . For , and are divisible by .
Lemma 4 (Final step). Let be odd, , , and . Then satisfies (for the appropriate sign of ).
Proof. Write and with . Then and , and all three correction terms are divisible by .
_padic_sqrt for odd computes a square root modulo with fmpz_sqrtmod (which decides whether is a square: by Hensel's lemma a unit is a square in if and only if it is a square modulo ), inverts it, lifts the inverse square root by Lemma 3 through , and applies Lemma 4 from to . The last step replaces an inverse square root step and a multiplication by one step of about the same cost.
For the derivative of is not a unit, and the precision grows from to only. A unit is a square in if and only if it is ; _padic_sqrt tests this and then calls fmpz_sqrtmod_2exp. In with , qadic_sqrt lifts the inverse square root with the sequence , (stopping at 2), which satisfies . Its starting value is an inverse square root modulo 2, which always exists since is an automorphism of , corrected by a root of an Artin–Schreier equation over . That equation is solvable if and only if is a square, and is solved by linear algebra over (Square roots).
Teichmüller lifts#
Let . Every unit has a unique Teichmüller lift : a -th root of unity congruent to modulo . It is the root of congruent to , which exists and is unique by Hensel's lemma since .
Lemma 5. If and , then .
Proof. With and , , we have , because and . Hence and Lemma 1 applies.
_padic_teichmuller () and _qadic_teichmuller () start from and , and at each precision of the sequence apply Lemma 5 and then a Newton step for the inverse. The power dominates the cost: multiplications at each precision. For the only odd root of unity in is 1, and _padic_teichmuller returns it directly.
Use in FLINT#
- Inverses:
_padic_inv,_padic_inv_precomp(used repeatedly inpadic_log_balanced),padic_inv,padic_div,padic_poly_inv_series(for the constant coefficient),_qadic_inv,qadic_inv. - Square roots:
_padic_sqrt,padic_sqrt,qadic_sqrt; thepadic_radixfunctionspadic_radix_sqrtandpadic_radix_rsqrtuse the analogous lifting in the radix representation (radix_integer_sqrtmod_limbs,radix_integer_rsqrtmod_limbs). - Teichmüller lifts:
_padic_teichmuller,padic_teichmuller,_qadic_teichmuller,qadic_teichmuller. - The Frobenius lift in
_qadic_frobenius_ais a Newton iteration of the same shape for the defining polynomial (The Frobenius automorphism).
Referenced from#
- The p-adic exponential and logarithm (algorithm)
- Frobenius automorphism and Teichmüller lifts in unramified extensions (algorithm)
- Arithmetic in unramified extensions (algorithm)
- Newton iteration for power series and division (algorithm)
padic_invpadic_sqrtpadic_teichmuller- padic.h (module)
- Frobenius, Teichmüller lifts, norm and trace
References#
- [Hen1908] K. Hensel. Theorie der algebraischen Zahlen. Teubner, Leipzig, 1908.
- [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
The FLINT team, “Hensel lifting of inverses, square roots and Teichmüller lifts,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/p-adic/hensel-lifting.html (generated 2026-11-02).
@misc{flint-doc-algorithms-p-adic-hensel-lifting,
author = {{The FLINT team}},
title = {{Hensel lifting of inverses, square roots and Teichmüller lifts}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/p-adic/hensel-lifting.html},
note = {Generated 2026-11-02}
}