Book contents
Contents
raw Math
RAW Book Analysis Lambert W Function

Introduction to Lambert W function

Robert Eisele

Johann Heinrich Lambert (1728-1777), the tailor’s son who taught himself from a private library-became a polymath: cartography (Lambert projection), hygrometry, pyrometry, statistics, philosophy, and pure math. He proved \(\pi\) is irrational (a milestone toward the impossibility of straightedge-and-compass squaring of the circle). While studying “trinomial” equations and series reversion, Lambert essentially anticipated the Lagrange Inversion Theorem. Euler later cast one of Lambert’s problems in a form that leads directly to the function we now call Lambert-\(W\).

When we look at classical exponentials, the inverse is the logarithm:

Now consider the map \(F(w)=we^w\). Unlike the exponential map, this function is not one-to-one on the complex plane, so it has no single-valued complex inverse. Its inverse branches are the Lambert-\(W\) functions.

Definition of Lambert W function

For a complex number \(z\), every solution \(w\) of

\[we^w=z\]

is a value of the Lambert-\(W\) inverse. There are countably many complex branches, conventionally written \(W_k(z)\), \(k\in\mathbb{Z}\). When branch choice is irrelevant or the principal branch is intended, we write \(W(z)\) or \(W_0(z)\). The defining identity, valid on every branch, is

\[ \boxed{W(F(x)) = W(xe^x) = x,} \qquad\Longleftrightarrow\qquad \boxed{W(y)e^{W(y)} = y}. \]

Core Identities of Lambert-W function

The definition has the immediate consequences:

The first quotient is not defined at \(x=0\); there \(W_0(0)=0\) and \(e^{W_0(0)}=1\) directly.

Real branches

Restrict now to real inputs. For \(-1/e<x<0\), there are two real branches:

At \(x=-1/e\) these two real branches meet at \(W=-1\); for \(x<-1/e\), no real value exists. At \(x=0\), only \(W_0(0)=0\) is finite. For \(x>0\), there is one real value, \(W_0(x)>0\). The meeting point \((-1/e,-1)\) is a square-root branch point: the two inverse branches cease to be locally separate there. [CorlessJeffrey]

In the complex plane, every branch is single-valued only after a branch cut is chosen. The point \(-1/e\) is the finite nonzero branch point where \(W_0\) and \(W_{-1}\) meet; nonprincipal branches also have logarithmic branching at zero. Thus “\(W(z)\)” without an index is ambiguous unless the principal branch is understood.

xW(x)−1/e0(−1/e, −1) W₀ W₋₁
The two real inverse branches meet at the fold of \(x=we^w\). The lower branch tends to \(-\infty\) as \(x\to0^-\).

The principal power series

Near zero, only the principal branch is analytic. Its series can be derived directly rather than guessed. Rearrange \(w e^w=z\) as \(w=z e^{-w}\), then apply the Lagrange inversion formula: if \(w=z\phi(w)\), then the coefficient of \(z^n\) in \(w(z)\) is \(\frac1n[u^{n-1}]\phi(u)^n\). With \(\phi(u)=e^{-u}\),

\[[z^n]W_0(z)=\frac1n[u^{n-1}]e^{-nu}.\]

\[\frac1n[u^{n-1}]e^{-nu}=\frac1n\frac{(-n)^{n-1}}{(n-1)!}.\]

\[[z^n]W_0(z)=\frac{(-n)^{n-1}}{n!}.\]

Therefore

\[\boxed{W_0(z)=\sum_{n=1}^{\infty}\frac{(-n)^{n-1}}{n!}z^n.}\]

\[\begin{aligned} W_0(z)&=z-z^2+\frac32z^3\\ &\quad-\frac83z^4+\frac{125}{24}z^5-\cdots. \end{aligned}\]

Stirling's formula shows that the coefficients have magnitude asymptotic to \(e^n/(\sqrt{2\pi}\,n^{3/2})\), so the radius of convergence is \(1/e\). The nearest singularity is exactly the branch point \(-1/e\). The lower real branch \(W_{-1}\) is not represented by a Taylor series at zero because it diverges as \(z\to0^-\).

General Inversion

For \(b>0, b\neq1\), solving \(y=xb^x=x e^{x\ln b}\) gives

\[\begin{aligned} (x\ln b)e^{x\ln b}&=y\ln b,\\ x_k&=\frac{W_k(y\ln b)}{\ln b}. \end{aligned}\]

This is a family of inverse branches, not necessarily one global inverse: \(xb^x\) is not one-to-one on all real inputs. Keep every real branch whose argument \(y\ln b\) lies in its real domain, then apply the original problem's restrictions on \(x\). For example, with \(b>1\), the graph has a minimum at \(x=-1/\ln b\); values between that minimum and zero have two real preimages, one from \(W_0\) and one from \(W_{-1}\).

Lambert-W function Calculator

The form field computes \(W(z)\) numerically. Enter any real \(z\).

\(W(\) \()) = W( x\cdot e^x) = x \approx\) 0.5671432904097838

Calculating Lambert-W

Using Newton's method

Basic Idea: approximate \(f\) by a straight line near the current guess

Suppose we have a current guess \(w_n\) for the root. For a small change \(\Delta\),

\[ f(w_n+\Delta)\approx f(w_n)+f'(w_n),\Delta \]

(this is the first-order Taylor approximation, i.e., “use the tangent line”).

We want the next guess \(w_{n+1}=w_n+\Delta\) to satisfy \(f(w_{n+1})\approx 0\). Set the linear approximation to zero and solve for \(\Delta\):

\[ 0 \approx f(w_n)+f'(w_n)\Delta \quad\Rightarrow\quad \Delta \approx -\frac{f(w_n)}{f'(w_n)}. \]

From this follows the general Newton step:

\[ \boxed{w_{n+1}=w_n-\frac{f(w_n)}{f'(w_n)}}. \]

Newton's method for Lambert-W

Here \(f(w)=w e^{w}-y\). Differentiate:

\[ f'(w)=(w+1)e^{w}. \]

Plug into the Newton step:

\[ \boxed{w_{n+1}=w_n-\frac{w_n e^{w_n}-y}{(w_n+1)e^{w_n}}}. \]

That's Newton's method for \(W\). It usually converges quadratically (errors roughly square each step) once you’re close.

Halley's method

Newton used a line (first-order). Halley upgrades the local model to a curve using a second-order approximation and solves that more accurately.

Second-order Taylor model of \(f\) near \(w_n\)

Let \(\Delta=w-w_n\). Then

\[ f(w_n+\Delta)\approx f_n+f'_n\Delta+\frac{1}{2}f''_n\Delta^2, \]

where \(f_n=f(w_n),\ f'_n=f'(w_n),\ f''_n=f''(w_n)\).

We want \(f(w_n+\Delta)\approx 0\). Solve the quadratic

\[ \frac{1}{2}f''_n\Delta^2+f'_n\Delta+f_n\approx 0. \]

Directly using the quadratic formula is possible but can be numerically touchy. Halley’s trick is to take the root that is a second-order correction to Newton’s step. That root can be written compactly as

\[ \Delta_{\text{Halley}} = -\frac{2 f_n f'_n}{2 (f'_n)^2 - f_n f''_n}. \]

From this follows the general Halley step:

\[ \boxed{w_{n+1}=w_n-\frac{2 f(w_n) f'(w_n)}{2[f'(w_n)]^2 - f(w_n) f''(w_n)}}. \]

This method has cubic convergence near the root (errors roughly cube each step), so it’s typically faster than Newton once you’re in the basin of attraction.

Halley's method for Lambert-W

For \(f(w)=w e^{w}-y\),

\[ f'(w)=(w+1)e^{w},\qquad f''(w)=(w+2)e^{w}. \]

Insert into Halley’s formula:

\[ \boxed{w_{n+1} = w_n-\frac{2(w_n e^{w_n}-y)(w_n+1)e^{w_n}} {2(w_n+1)^2 e^{2w_n} - (w_n e^{w_n}-y)(w_n+2)e^{w_n}}}. \]

You can cancel a common (e^{w_n}) if you like:

\[ w_{n+1} = w_n-\frac{2(w_n e^{w_n}-y)(w_n+1)} {2(w_n+1)^2 e^{w_n} - (w_n e^{w_n}-y)(w_n+2)}. \]

Calculating the Omega constant

Take \(y=1\) (so \(W(1)=\Omega)\). With Newton’s formula above and start \(w_0=0.5\):

\[ w_1\approx 0.57102,\quad w_2\approx 0.56716,\quad w_3\approx 0.56714,\dots \]

So \(\Omega\approx 0.567143\) and indeed \(\Omega e^{\Omega}=1\).

Fixed-point iteration (simple "mental math" hint)

From \(y=we^{w}\) we get \(\ln y=\ln w + w\), so

\[ \boxed{w=\ln\Big(\tfrac{y}{w}\Big)}. \]

With a guess \(w_0\) (e.g. \(w_0=\ln y\) when \(y>e\)), iterate

\[ w_{k+1}=\ln\Big(\frac{y}{w_k}\Big)\ \longrightarrow\ W(y) \]

In practice this method is often slow, but easy to remember.

Derivative of the Lambert \( W \) Function

Choose an analytic branch \(W_k\) and write \(w=W_k(x)\). Starting from the defining relationship:

\[ x = W_k(x)e^{W_k(x)}, \]

we differentiate both sides with respect to \( x \):

\[ 1 = \frac{d}{dx} \left( W_k(x) e^{W_k(x)} \right). \]

Applying the product rule:

\[ 1 = W_k'(x)e^{W_k(x)} + W_k(x) W_k'(x) e^{W_k(x)}. \]

Factoring \(W'(x)e^{W(x)}\), we obtain:

\[ 1 = W_k'(x)e^{W_k(x)} \left( 1 + W_k(x) \right). \]

For \(W_k(x)\ne-1\), rearranging gives the form that remains valid at \(x=0\):

\[ W_k'(x) = \frac{e^{-W_k(x)}}{1 + W_k(x)}. \]

For \(x\ne0\), substituting \(e^{W_k(x)}=x/W_k(x)\) gives the familiar equivalent expression:

\[ W_k'(x) = \frac{W_k(x)}{x \left( 1 + W_k(x) \right)}. \]

On the principal branch, \(W_0(x)=x+O(x^2)\) near zero, so \(W_0'(0)=1\). At the branch point \(x=-1/e\), where \(W_0=W_{-1}=-1\), the denominator vanishes and the derivative is singular. The lower real branch has no finite value at \(x=0\).

ODE viewpoint. The derivative formula says \(W\) solves

\[\frac{dW_0}{dx}=\frac{e^{-W_0}}{1+W_0},\qquad W_0(0)=0.\]

Applying Lambert-W to Tetration

If the infinite power tower \(y=x^{x^{x^{\cdot^{\cdot}}}}\) converges, it satisfies \(x^{y}=y\). Solving gives

\[ \boxed{y=-\frac{W(-\ln x)}{\ln x},}. \]

(Use the branch that makes \(y>0\) when it exists.)

For complex \(x\), the iteration may diverge or settle into cycles (length (2,3,\dots)); plotting parameters reveals fractal-like boundaries.

Worked Examples

Solving \(a^{32}=2^a\): three real solutions

Because the exponent is even, take the nonnegative 32nd root on both sides:

\[|a|=2^{a/32}=e^{ca},\qquad c=\frac{\ln 2}{32}.\]

First suppose \(a>0\). Then \(a=e^{ca}\), so

\[a e^{-ca}=1 \quad\Longrightarrow\quad (-ca)e^{-ca}=-c \quad\Longrightarrow\quad a=-\frac{W_k(-c)}{c}.\]

Here \(-1/e<-c<0\), so both real branches apply. The principal branch gives \(W_0(-c)\approx-0.022145899498\), hence \(a_1\approx1.02239294022\). On the lower branch, \(W_{-1}(-c)=-8\ln 2\), since \((-8\ln 2)e^{-8\ln 2}=-\ln 2/32\). Therefore the second positive solution is exactly \(a_3=256\). The branch index is what recovers this much larger root.

Now suppose \(a<0\), and set \(b=-a>0\). The absolute value in the initial root equation matters: \(b=e^{-cb}\). Thus

\[b e^{cb}=1 \quad\Longrightarrow\quad (cb)e^{cb}=c \quad\Longrightarrow\quad a=-\frac{W_0(c)}{c}.\]

The argument \(c\) is positive, so only \(W_0\) is real here. With \(W_0(c)\approx0.021206338381\), this gives \(a_2\approx-0.97901693496\). The complete set of real solutions is therefore

\[\boxed{a\approx-0.97901693496,\qquad a\approx1.02239294022,\qquad a=256.}\]

Substitution in the original equation verifies the values. The negative root comes from the principal branch at a positive argument; the two positive roots come from the two real branches at a negative argument.

Solving \(x^x=2\)

\[\begin{array}{rrl} &x^x &= 2\\ \Leftrightarrow&\ln(x^x) &= \ln(2)\\ \Leftrightarrow&x\ln(x) &= \ln(2)\\ \Leftrightarrow&\ln(x) e^{\ln(x)} &= \ln(2)\\ \Leftrightarrow&W(\ln(x) e^{\ln(x)}) &= W(\ln(2))\\ \Leftrightarrow&\ln(x) &= W(\ln(2))\\ \Leftrightarrow&x&= e^{W(\ln(2))}\\ \Leftrightarrow& x & \approx 1.55961047 \end{array}\]

Solving \(\frac{x}{\ln(x)}=y\)

\[\begin{array}{rrl} &\frac{x}{\ln(x)} &= y\\ \Leftrightarrow&\ln(x) &= \frac{x}{y}\\ \Leftrightarrow&\ln(x)e^{-\ln(x)} &= \frac{1}{y}\\ \Leftrightarrow&(-\ln(x))e^{-\ln(x)} &= -\frac{1}{y}\\ \Leftrightarrow&-\ln(x) &= W\left(-\frac{1}{y}\right)\\ \Leftrightarrow&x &= e^{-W\left(-\frac{1}{y}\right)} \end{array}\]

Solving \(x^x=y\)

\[\begin{array}{rrl} &x^x &= y\\ \Leftrightarrow&x\ln(x) &= \ln(y)\\ \Leftrightarrow&e^{\ln(x)}\ln(x) &= \ln(y)\\ \Leftrightarrow&\ln(x) &= W\left(\ln(y)\right)\\ \Leftrightarrow&x &= e^{W\left(\ln(y)\right)} \end{array}\]

Here \(x>0\) and \(y>0\). The branch in that formula matters. Write \(u=\ln x\); then \(ue^u=\ln y\), so every positive solution is

\[x=\exp\!\left(W_k(\ln y)\right).\]

The function \(x\ln x\) has its minimum \(-1/e\) at \(x=1/e\). Therefore there are no positive solutions for \(0<y<e^{-1}\), one repeated solution \(x=1/e\) for \(y=e^{-1}\), two solutions for \(e^{-1}<y<1\) (branches \(W_{-1}\) and \(W_0\)), and one solution for \(y\ge1\) (the principal branch). In particular, the existing example \(x^x=2\) has one positive solution; equations closer to the minimum need both branches.

Solving \(a^x + bx = c\)

\[\begin{array}{rrl} & a^x + bx &= c\\ \Leftrightarrow & a^x &= c - bx\\ \Leftrightarrow & \frac{a^x}{b} &= \frac{c}{b} - x\\ \Leftrightarrow & \frac{1}{b} &= (\frac{c}{b} - x) \cdot a^{-x}\\ \Leftrightarrow & \frac{a^{c/b}}{b} &= (\frac{c}{b} - x) \cdot a^{\frac{c}{b} - x}\\ \Leftrightarrow & \frac{a^{c/b}}{b} &= (\frac{c}{b} - x) \cdot e^{\log(a)\cdot(\frac{c}{b} - x)}\\ \Leftrightarrow & \log(a)\cdot \frac{a^{c/b}}{b} &= \log(a)\cdot(\frac{c}{b} - x) \cdot e^{\log(a)\cdot(\frac{c}{b} - x)}\\ \Leftrightarrow & W\left(\log(a)\cdot \frac{a^{c/b}}{b}\right) &= \log(a)\cdot(\frac{c}{b} - x)\\ \Leftrightarrow & x &= \frac{c}{b} - \frac{W\left(\log(a)\cdot \frac{a^{c/b}}{b}\right)}{\log(a)}\\ \end{array}\]

Solving \(x^a \cdot b^x = c\)

\[\begin{array}{rrl} &x^a \cdot b^x &= c\\ \Leftrightarrow & x \cdot b^{x/a} &= c^{1/a}\\ \Leftrightarrow & \frac{x}{a} \cdot b^{x/a} &= \frac{c^{1/a}}{a}\\ \Leftrightarrow & \log(b) \cdot \frac{x}{a} \cdot e^{\log(b) \cdot x/a} &= \log(b) \cdot \frac{c^{1/a}}{a}\\ \Leftrightarrow & \log(b) \cdot \frac{x}{a} &= W\left(\log(b) \cdot \frac{c^{1/a}}{a}\right)\\ \Leftrightarrow & x &= \frac{a \cdot W\left(\log(b) \cdot \frac{c^{1/a}}{a}\right)}{\log(b)}\\ \end{array}\]

Solving \(a^x = x^b\)

\[\begin{array}{rrl} &a^x &= x^b\\ \Leftrightarrow & x \ln(a) &= b \ln(x) \\ \Leftrightarrow& \frac{\ln(x)}{x} &= \frac{\ln(a)}{b} \\ \Leftrightarrow& -\frac{\ln(x)}{x} &= -\frac{\ln(a)}{b} \\ \Leftrightarrow& (-\ln(x))e^{-\ln(x)} &= -\frac{\ln(a)}{b} \\ \Leftrightarrow& -\ln(x) &= W\left(-\frac{\ln(a)}{b}\right) \\ \Leftrightarrow& \ln(x) &= -W\left(-\frac{\ln(a)}{b}\right) \\ \Leftrightarrow& x &= e^{-W(-\frac{\ln(a)}{b})} \end{array}\]

Solving \(z^3 = 3^z\) in \(\mathbb{C}\)

We seek all complex \(z\) such that

\[ z^3 = 3^z. \]

Taking logarithms on branches gives

\[ 3\log z = z\log 3 + 2\pi i m, \qquad m\in\mathbb{Z}. \]

Divide by \(3\), then set \(u = -\frac{\log 3}{3}z\). This transforms the equation into Lambert-W form

\[ u\,e^u = -\frac{\log 3}{3} e^{2\pi i j/3}, \qquad j\in\{0,1,2\}, \]

where \(j\) captures the three cube-root families.

Hence the complete complex solution family is

\[ \boxed{ z_{j,k}= -\frac{3}{\log 3} W_k\!\left(-\frac{\log 3}{3}e^{2\pi i j/3}\right), \qquad j\in\{0,1,2\},\; k\in\mathbb{Z}. } \]

For the principal cube-root family \((j=0)\), this simplifies to

\[ z = -\frac{3}{\log 3}W_k\!\left(-\frac{\log 3}{3}\right) = \frac{1}{e^{W_k\left(-\frac{\log 3}{3}\right)}}. \]

Solving \(x =\ln(4x)\)

\[\begin{array}{rrl} & x &= \ln(4x)\\ \Leftrightarrow& e^x &= 4x\\ \Leftrightarrow& \frac{1}{x}e^x &= 4\\ \Leftrightarrow& -xe^{-x} &= -\frac{1}{4}\\ \Leftrightarrow& W(-xe^{-x}) &= W(-\frac{1}{4})\\ \Leftrightarrow& -x &= W(-\frac{1}{4})\\ \Leftrightarrow& x &= -W(-\frac{1}{4})\\ \Leftrightarrow& x & \approx 0.357402956 \end{array}\]

Example \(x^2e^x =2\)

\[\begin{array}{rrl} & x^2e^x &= 2\\ \Leftrightarrow& \sqrt{x^2e^x} &= \sqrt{2}\\ \Leftrightarrow& xe^{\frac{x}{2}} &= \sqrt{2}\\ \Leftrightarrow& \frac{x}{2}e^{\frac{x}{2}} &= \frac{\sqrt{2}}{2} = \frac{1}{\sqrt{2}}\\ \Leftrightarrow& W\left(\frac{x}{2}e^{\frac{x}{2}}\right) &= W\left(\frac{1}{\sqrt{2}}\right)\\ \Leftrightarrow& \frac{x}{2} &= W\left(\frac{1}{\sqrt{2}}\right)\\ \Leftrightarrow& x &= 2W\left(\frac{1}{\sqrt{2}}\right)\\ \Leftrightarrow& x & \approx 0.901201032 \end{array}\]

Example \(x+e^x =2\)

\[\begin{array}{rrl} &x +e^x&= 2\\ \Leftrightarrow&e^x&= 2 -x \\ \Leftrightarrow&1 &= (2 -x)^{e^{-x}}\\ \Leftrightarrow&e^2 &= (2 -x)^{e^{2-x}}\\ \Leftrightarrow&W(e^2) &= W((2 -x)^{e^{2-x}})\\ \Leftrightarrow&W(e^2) &= 2 -x\\ \Leftrightarrow&x &= 2 - W(e^2)\\ \Leftrightarrow&x &\approx 0.442854401 \end{array}\]

Example \(3^x + x = 2\)

\[\begin{array}{rrl} &3^x + x &= 2 \\ \Leftrightarrow&3^x &= 2-x \\ \Leftrightarrow&1 &= (2-x) \cdot 3^{-x} \\ \Leftrightarrow&3^2 &= (2-x) \cdot 3^{2-x} \\ \Leftrightarrow&9 &= (2-x) \cdot {e^{\ln(3)}}^{2-x} \\ \Leftrightarrow&\ln(3) \cdot 9 &= \ln(3)(2-x) \cdot e^{\ln(3)(2-x)} \\ \Leftrightarrow&W(\ln(3)\cdot 9) &= \ln(3)(2-x) \\ \Leftrightarrow&x &= 2 - \frac{W(\ln(3)\cdot 9)}{\ln(3)} \\ \Leftrightarrow&x &\approx 0.41769372 \end{array}\]

Example \(x^{\sqrt{x}} = 3\)

\[\begin{array}{rrl} &x^{\sqrt{x}} &= 3\\ \Leftrightarrow & \sqrt{x}\cdot\ln(x) &= \ln(3)\\ \Leftrightarrow & x^{1/2}\cdot\ln(x) &= \ln(3)\\ \Leftrightarrow & e^{u}\cdot 2u &= \ln(3)\; \text{ with } u = \frac{1}{2}\ln(x)\\ \Leftrightarrow & u\cdot e^{u} &= \frac{1}{2}\ln(3)\\ \Leftrightarrow & u &= W\left(\frac{1}{2}\ln(3)\right)\\ \Leftrightarrow & \ln(x) &= {2W\left(\frac{1}{2}\ln(3)\right)}\\ \Leftrightarrow & x &= e^{2W\left(\frac{1}{2}\ln(3)\right)}\\ \Leftrightarrow & x &= 2.124799\\ \end{array}\]

References