[Math] Lambert- W -Function calculation

lambert-wlogarithms

I have an equation of the form:

$$ n \log n = x $$

Upon searching I came across the term "Lambert- W -Function" but couldn't find a proper method for evaluation, and neither any computer code for it's evaluation.

Any ideas as to how I can evaluate?

Best Answer

Let us consider the function $$f(x)=x \log(x)-a$$ Effcetively, the solution of $f(x)=0$ is given by $$x=\frac{a}{W(a)}$$ and, if I properly understood, you look for a computation method for getting $W(a)$.

From definition $W(a)$ is defined such that $a=W(a)e^{W(a)}$ so Newton method seems to be (and is) very good.

I strongly suggest you have a look at http://en.wikipedia.org/wiki/Lambert_W_function. In the paragraph entitled "Numerical evaluation", they give Newton and Halley formulae (the latest one has been massively used by Corless et al. to compute $W(a)$.

In the same Wikipedia page, you will find very nice and efficient approximations of $W(a)$ for small and large values. These estimates will allow you to start really close to the solution.

If I may underline one thing which is really nice : all derivatives od $W(a)$ express as functions of $a$ and $W(a)$ itself and this is extremely convenient.

You could be interested by http://people.sc.fsu.edu/~jburkardt/cpp_src/toms443/toms443.html where the source code is available.

Related Question