Lambert W function

From Wikipedia, the free encyclopedia

The graph of W0(x) for −1/e ≤ x ≤ 4
The graph of W0(x) for −1/ex ≤ 4

In mathematics, The Lambert W function, named after Johann Heinrich Lambert, also called the Omega function or product log, is the inverse function of f(w) = wew where ew is the natural exponential function and w is any complex number. We will denote the function here by W. For every complex number z, we have

z = W(z)eW(z).

Since the function f is not injective, the function W is multivalued (except at 0). If we restrict to real arguments x and demand w real, then the function is defined only for x ≥ −1/e, and is double-valued on (−1/e, 0); the additional constraint w ≥ −1 defines a single-valued function W0(x), whose graph is shown. We have W0(0) = 0 and W0(−1/e) = −1. The alternate branch on [−1/e, 0) with w ≤ −1 is denoted W−1(x) and decreases from W−1(−1/e) = −1 to W−1(0) = −∞.

The Lambert W function cannot be expressed in terms of elementary functions. It is useful in combinatorics, for instance in the enumeration of trees. It can be used to solve various equations involving exponentials and also occurs in the solution of time-delayed differential equations, such as y'(t) = a y(t − 1).

Lambert W function in the complex plane
Lambert W function in the complex plane

Contents

[edit] Differentiation and integration

By implicit differentiation, one can show that W satisfies the differential equation

z(1+W)\frac{dW}{dz}=W\quad\mathrm{for\ }z\neq -1/e \,,

and hence:

\frac{dW}{dz}=\frac{W(z)}{z(1 + W(z))}\quad\mathrm{for\ }z\neq -1/e \,.

The function W(x), and many expressions involving W(x), can be integrated using the substitution w = W(x), i.e. x = w ew:

\int W(x)\, dx = x \left( W(x) - 1 + \frac{1}{W(x)} \right) + C

[edit] Taylor series

The Taylor series of W0 around 0 can be found using the Lagrange inversion theorem and is given by


W_0 (x) = \sum_{n=1}^\infty \frac{(-n)^{n-1}}{n!}\ x^n = x - x^2 + \frac{3}{2}x^3 - \frac{8}{3}x^4 + \frac{125}{24}x^5 - \cdots

The radius of convergence is 1/e, as may be seen by the ratio test. The function defined by this series can be extended to a holomorphic function defined on all complex numbers with a branch cut along the interval (−∞, −1/e]; this holomorphic function defines the principal branch of the Lambert W function.

[edit] Applications

Many equations involving exponentials can be solved using the W function. The general strategy is to move all instances of the unknown to one side of the equation and make it look like Y = XeX at which point the W function provides the solution.

In other words :

 X = Y e ^ Y \; \Longleftrightarrow \; Y = W(X)

[edit] Examples

Example 1
2^t  = 5 t\,
\Rightarrow 1 = \frac{5 t}{2^t}\,
\Rightarrow 1 = 5 t \, e^{-t \ln 2}\,
\Rightarrow \frac{1}{5} = t \, e^{-t \ln 2}\,
\Rightarrow \frac{- \, \ln 2}{5} = ( - \, t \, \ln 2 ) \, e^{( -t \ln 2 )}\,
\Rightarrow -t \ln 2 = W \left ( \frac{- \ln 2}{5} \right )\,
\Rightarrow t = \frac{- W \left ( \frac{- \ln 2}{5} \right )}{\ln 2}\,

More generally, the equation

 ~p^{a x + b} = c x + d

where

 p > 0 \and c,d \neq 0

can be transformed via the substitution

 -t = a x + \frac{a d}{c}

into

 t p^t = R = -\frac{a}{c} p^{b-\frac{a d}{c}}

giving

 t = \frac{W(R\ln p)}{\ln p}

which yields the final solution

 x = -\frac{W(-\frac{a\ln p}{c}\,p^{b-\frac{a d}{c}})}{a\ln p} - \frac{d}{c}


Example 2

Similar techniques show that

x^x=z\, ,

has solution

x=\frac{\ln(z)}{W(\ln z)}\, ,

or, equivalently,

x=\exp\left(W(\ln(z))\right).
Example 3

Whenever the complex infinite exponential tetration

z^{z^{z^{\cdot^{\cdot^{\cdot}}}}} \!

converges, the Lambert W function provides the actual limit value as

c=\frac{W(-\ln(z))}{-\ln(z)}

where ln(z) denotes the principal branch of the complex log function.

Example 4

Solutions for

x \log_b \left(x\right) = a

have the form

x = \frac{a \ln(b)}{W(a \ln(b))}
Example 5

The solution for the current in a series diode/resistor circuit can also be written in terms of the Lambert W. See diode modeling.

Example 6

The delay differential equation

\dot{y}(t) = ay(t-1)

has characteristic equation λ = ae − λ, leading to λ = Wk(a) and y(t)=e^{W_k(a)t}, where k is the branch index. If a is real, only W0(a) need be considered.

[edit] Special values

W\left(-\frac{\pi}{2}\right) = \frac{i\pi}{2}
W\left(-\frac{\ln 2}{2}\right)= -\ln 2
W\left(-{1\over e}\right) = -1
W(0) = 0\,
W(1) = \Omega\, (the Omega constant)
W(e) = 1\,

[edit] Plots

[edit] Evaluation algorithm

The W function may be evaluated using the recurrence relation


w_{j+1}=w_j-\frac{w_j e^{w_j}-z}{e^{w_j}(w_j+1)-\frac{(w_j+2)(w_je^{w_j}-z)}
{2w_j+2}}

given in Corless et al. to compute W. Together with the evaluation error estimate given in Chapeau-Blondeau and Monir, the following Python code implements this:

import math
 
def lambertW(x, prec = 1E-12, maxiters = 100):
    w = 0
    for i in range(maxiters):
        we = w * pow(math.e,w)
        w1e = (w + 1) * pow(math.e,w)
        if prec > abs((x - we) / w1e):
            return w
        w -= (we - x) / (w1e - (w+2) * (we-x) / (2*w+2))
    raise ValueError("W doesn't converge fast enough for abs(z) = %f" % abs(x))

This computes the principal branch for x > 1 / e. It could be improved by giving better initial estimates.

The following closed form approximation may be used by itself when less accuracy is needed, or to give an excellent initial estimate to the above code, which then may need only a few iterations:

double
desy_lambert_W(double x) {
      double  lx1;
      if (x <= 500.0) {
              lx1 = ln(x + 1.0);
              return 0.665 * (1 + 0.0195 * lx1) * lx1 + 0.04;
      }
      return ln(x - 4.0) - (1.0 - 1.0/ln(x)) * ln(ln(x));
}

(from http://www.desy.de/~t00fri/qcdins/texhtml/lambertw/)

[edit] History

Lambert first considered the related Lamberts Transcendental Equation in 1758 which lead to a paper by Leonhard Euler in 1783 which discussed the special case of wew. However the inverse of wew was first described by Pólya and Szegö in 1925.

[edit] References and external links