The Lambert W function
June 4th, 2008Most readers may be familiar with this particular definition of the natural logarithm:
The Lambert W function, named after J.H. Lambert who considered the solutions of a certain transcendental equation, is defined as follows:
Like the logarithm, Lambert’s function is multivalued, corresponding to the many possible complex solutions. Also like the logarithm, mathematicians have selected one of the function’s many possible branches to be the “principal branch”, sometimes denoted as . This particular branch is real for
.
This function only very recently came into prominence compared to other, more popular special functions, due to the efforts of Corless, Knuth, and others.
A method for computing the function would involve solving for in the equation
, and either of the iterative methods of Newton or Halley are suited for the task, due to the simple nature of the derivatives of the exponential function.
If Newton’s method is employed, the iteration becomes:
while the iteration using Halley’s method is:
The remaining problem is what to use as an initial approximation, or “seed” for either of the iterations to start with. Winitzki, in a paper on uniform approximations to transcendentals, presented the following expression:
where , and
4.6948,
=0.8842,
=0.9294,
=0.5106, and
=-1.213 are constants. This approximant matches the behavior of the Lambert W function at the points
,
, and at
, and is accurate to around two significant figures.
Here, then, are TI 83+ programs for computing the principal branch of the Lambert W function. This one employs Newton’s method:
PROGRAM:LAMW1
√(2℮X+2)→V
2ln(1+.8842V)→Y
(Y–ln(1+.9294ln(1+.5106V))–1.213)/(1+(Y+.213ֿ¹)ֿ¹)→Y
If abs(Y+1)
Then
Repeat V=Y
Y→V
Y–(Y–X℮^(-Y))/(1+Y)→Y
ln(X)–ln(Y)→Y
End:End
Y
This one uses Halley’s method:
PROGRAM:LAMW2
√(2℮X+2)→V
2ln(1+.8842V)→Y
(Y–ln(1+.9294ln(1+.5106V))–1.213)/(1+(Y+.213ֿ¹)ֿ¹)→Y
If abs(Y+1)
Then
Repeat V=Y
Y→V
Y–X℮^(-Y)→W
Y–W/(1+Y–.5W(Y+2)/(1+Y))→Y
ln(X)–ln(Y)→Y
End:End
Y
Theoretically, the program using Halley’s method would be more efficient due to the faster convergence associated with the method; in practice, there is little difference in performance between the two for most complex arguments.
- thornahawk
References:
Corless, R.M., Gonnet, G.H., Hare, D.E.G., Jeffrey, D.J., and Knuth, D.E. “On the Lambert W Function.” Adv. Comput. Math. 5, 329-359, 1996.
Winitzki, S. “Uniform Approximations for Transcendental Functions.” In Computational Science and Its Applications – ICCSA 2003