The Lambert W function
- Cost
- O(log p) Halley steps with doubling precision, each dominated by one exponential, so the cost is a small multiple of that of exp at precision p.
The Lambert function solves . It has infinitely many branches , ; the principal branch is real on and is real on . The standard branch cuts are those of Corless et al. [CGHJK1996]: has the cut , the other branches have the cut , and has in addition a cut along the real segment , where it meets . acb_lambertw also offers two nonstandard conventions through its flags: ACB_LAMBERTW_LEFT rotates the cut on to , and ACB_LAMBERTW_MIDDLE joins in the upper half-plane and in the lower half-plane through , which extends the real function analytically. FLINT implements the function in arb (arb_lambertw, branches 0 and for real arguments) and acb (acb_lambertw, any branch given as an fmpz), following Johansson [Joh2017b]. Unlike the functions of the rest of this group, is not given by a convenient series; it is computed by solving the equation.
Starting values#
Large or . The asymptotic expansion
gives a starting value (in double precision when the exponents fit).
acb_lambertw_asympevaluates the full bivariate series in and with and terms and a rigorous error bound, which is finite when is large; for huge or this gives the final result directly.- Near the branch point . With , ; the series is evaluated with a bound on its coefficients, and when is extremely close to it gives the result directly. The quantity is computed once at high precision, since it suffers from cancellation exactly where it matters.
- Moderate . Double-precision approximations:
d_lambertwfor the principal branch, and rational approximations followed by a Halley step (d_lambertw_branch1) for on . - Small on the principal branch. The Taylor series , whose coefficients are bounded by for .
Halley iteration#
From an approximation , Halley's method for gives
which converges cubically. The iteration runs on midpoints (floating point, no ball arithmetic) with a precision that roughly triples at each step, so that the total cost is a small multiple of the last step, which is dominated by one exponential at the target precision.
Certification#
The result is certified a posteriori: for the final approximation , the residual is computed in ball arithmetic, and the error is bounded by
where the maximum is over the straight segment from to , which must not cross a branch cut of . For real arguments is bounded with for , for and ; in the complex case, acb_lambertw_bound_deriv uses bounds of the form with near the branch point and analogous ones elsewhere. A separate check (acb_lambertw_check_branch) verifies that lies in the region of the requested branch , which the residual alone cannot detect.
For an inexact input ball, the function is evaluated at the midpoint and the propagated error is bounded with the same derivative bounds. If the input ball straddles a branch cut, the result is the union of the values on both sides, computed separately.
Use in FLINT#
arb_lambertw,acb_lambertwand the genericgr_lambertwandgr_lambertw_fmpzfor ball contexts.- The power series versions
arb_poly_lambertw_seriesandacb_poly_lambertw_seriesuse the scalar function for the constant term and Newton iteration on power series for the other coefficients. d_lambertwofdouble_extrasand the internald_lambertw_branch1provide the double-precision starting values; other functions use them to estimate numbers of terms, for example the error function, the cosine integral and the gamma function of rational arguments inarb_hypgeom.
Referenced from#
References#
- [CGHJK1996] R. M. Corless, G. H. Gonnet, D. E. Hare, D. J. Jeffrey and D. E. Knuth, "On the Lambert W function", Advances in Computational Mathematics, 5(1) (1996), 329-359
- [Joh2017b] F. Johansson, "Computing the Lambert W function in arbitrary-precision complex interval arithmetic", preprint (2017), https://arxiv.org/abs/1705.03266
The FLINT team, “The Lambert W function,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/special-functions/lambert-w.html (generated 2026-11-02).
@misc{flint-doc-algorithms-special-functions-lambert-w,
author = {{The FLINT team}},
title = {{The Lambert W function}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/special-functions/lambert-w.html},
note = {Generated 2026-11-02}
}