mdbtxt1
mdbtxt2
Proceed to Safety

The Lambert W Function    

This page concerns the Lambert W function and sequences related to it. W(x) is the inverse of the function X(w)=wew and is useful for solving many problems like the inverse of xx and of z = xx(y-1)

Derivative

The Wikipedia page Lambert W function says that the derivative of W(x) can be found by implicit differentiation with the result

dW(x)/dx = W(x)/x(W(x)+1)

However, this is numerically poor because it has two singularities (at x=0 and at W(x)=-1). Though the x=0 singularity is removable, there are better-looking alternatives.

It is easy to derive dW(x)/dx directly from dx/dw.

For readbility, let x and w be the variables, equivalent to the two functions (Lambert W and its inverse) like so:

x = X(w) = wew

w = W(x) = Lambert W function, inverse of wew

It is easy using the product rule to find the derivative of x with respect to w:

dX(w)/dW(x) = dx/dw = wew + ew

dw/dx is just the reciprocal of this:

dw/dx = 1/(x + ew)

To see that this is the same as Wikipedia's formula W(x)/x(W(x)+1), we start by substituting wew for the x:

dw/dx = 1/(wew + ew)

Factor out the ew and move it to the numerator as e-w:

dw/dx = e-w/(w+1)

This is the best version to use when computing the primary branch W0(x) (see footnote 1). To get to Wikipedia's formula, we multiply by x/x (this is where the removable singularity at 0 is introduced):

dw/dx = xe-w/x(w+1)

Then expand the top x back into wew so we can cancel out the powers of e:

dw/dx = wewe-w/x(w+1)

dw/dx = w/x(w+1) = W(x)/x(W(x)+1)


Footnotes

1 : Numercally, you may be able to avoid computing e-w if you use the Newton or Halley iterations to compute W(x), because ew is computed as part of the iteration, and the final value of this might be accurate enough to use here.


Robert Munafo's home pages on AWS    © 1996-2024 Robert P. Munafo.    about    contact
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. Details here.

This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2013 Feb 05. s.27