lambert_w, a Python code which evaluates Lambert's W function.

Lambert's W function W(X) satisfies the equation

        W(x) * exp ( W(x) ) = x

The function is defined for -1/e <= x. There are two branches, joining at -1/e = x. The lower branch extends from -1/e <= x < 0 The upper branch extends from -1/e <= x The function is also known as the "Omega" function.

In Mathematica, the function can be evaluated by: W = ProductLog [ X ] In MATLAB, W = lambertw ( b, x ) In Python, W = scipy.special.lambertw ( x, b )


The computer code and data files made available on this web page are distributed under the MIT license


lambert_w is available in a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

flame_ode, a Python code which sets up an ordinary differential equation (ODE) that models the growth of a ball of flame in a combustion process. The exact solution is defined in terms of the Lambert W function.

polpak, an Octave code which evaluates a variety of mathematical functions, polynomials, and sequences, including Bell, Benford, Bernoulli, Bernstein, Cardan, Catalan, Charlier, Chebyshev, Collatz, Delannoy, Euler, Fibonacci, Gegenbauer, Gudermannian, Harmonic, Hermite, Hofstadter, Jacobi, Krawtchouk, Laguerre, Lambert W, Legendre, Lerch, Meixner, Mertens, Moebius, Motzkin, Phi, Stirling, Tau, Tribonacci, Zernike.

predator_prey_ode_period, a Python code which sets up a system of ordinary differential equations (ODE) for a Lotka-Volterra predator prey model in order to estimate the period of the limit cycle. The computation involves the Lambert W function.

test_values, a Python code which supplies test values of various mathematical functions, including Abramowitz, AGM, Airy, Bell, Bernoulli, Bessel, Beta, Binomial, Bivariate Normal, Catalan, Cauchy, Chebyshev, Chi Square, Clausen, Clebsch Gordan, Collatz, Cosine integral, Dawson, Debye, Dedekind, dilogarithm, Exponential integral, Elliptic, Error, Euler, Exponential integral, F probability, Fresnel, Frobenius, Gamma, Gegenbauer, Goodwin, Gudermannian, Harmonic, Hermite, Hypergeometric, inverse trigonometic, Jacobi, Julian Ephemeris Date, Kelvin, Laguerre, Lambert W, Laplace, Legendre, Lerch, Lobachevsky, Lobatto, Logarithmic integral, Log normal, McNugget numbers, Mertens, Mittag-Leffler, Moebius, Multinomial, Negative binomial, Nine J, Normal, Omega, Owen, Partition, Phi, Pi, Poisson, Polylogarithm, Polyomino, Prime, Psi, Rayleigh, Hyperbolic Sine integral, Sigma, Sine Power integral, Sine integral, Six J, Sphere area, Sphere volume, Spherical harmonic, Stirling, Stromgen, Struve, Student, Subfactorial, Student probability, Three J, Transport, Trigamma, Truncated normal, van der Corput, von Mises, Weibull, Wright omega, Zeta.

toms443, a Python code which evaluates Lambert's W function. This is a version of ACM TOMS algorithm 443.

toms743, a Python code which evaluates Lambert's W function. This is a version of ACM TOMS algorithm 743, by Barry, Barry and Culligan-Hensley.


  1. Fred Fritsch, RE Shafer, WP Crowley,
    Algorithm 443: Solution of the Transcendental Equation W*exp(W)=X,
    Communications of the ACM,
    Volume 16, Number 1, February 1973, pages 123-124.
  2. Andrew Barry, S. J. Barry, Patricia Culligan-Hensley,
    Algorithm 743: WAPR - A Fortran routine for calculating real values of the W-function,
    ACM Transactions on Mathematical Software,
    Volume 21, Number 2, June 1995, pages 172-181.

Source Code:

Last revised on 20 June 2023.