Lambert's W function
In mathematics, Lambert's W function, named after Johann Heinrich Lambert, also called the Omega function, is the inverse function of f(w) = w·ew for complex numbers w; where ew is the exponential function.
This means that for every complex number z, we have
By implicit differentiation, one can show that W satisfies the differential equation
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 x ex, at which point the W function provides the solution. For instance, to solve the equation 2t = 5t, we divide by 2t to get 1 = 5t e-ln(2)t, then divide by 5 and multiply by -ln(2) to get -ln(2)/5 = -ln(2)t e-ln(2)t. Now application of the W function yields −ln(2)t = W(−ln(2)/5), i.e. t = −W(−ln(2)/5) / ln(2).
Similar techniques show that
- .
| Table of contents |
|
2 References 3 See also |
See also: Omega constant
Special values
Together with the evaluation error estimate given in Chapeau-Belandeau and Monir, the following Python code implements this:import math
class Error(Exception):
pass
def lambertW(x, prec=1e-12):
w = 0
for i in xrange(100):
wTimesExpW = w*math.exp(w)
wPlusOneTimesExpW = (w+1)*math.exp(w)
if prec>abs((x-wTimesExpW)/wPlusOneTimesExpW):
break
w = w-(wTimesExpW-x)/(
wPlusOneTimesExpW-(w+2)*(wTimesExpW-x)/(2*w+2))
else:
raise Error, "W doesn't converge fast enough for %f"%x
return w
This computes the principal branch for . It could be improved by giving better initial estimates.References
See also