Lambert- W -Function calculation?

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.


Although an old post, I'm surprised nobody mentioned this:

$$n\log n=(e^{\log n})\log n=x$$

Now it should be obvious on how to proceed.

$$W(x)=\log n$$

$$e^{W(x)}=n$$

And because $W(x)e^{W(x)}=x$, $e^W(x)=\frac{x}{W(x)}$ so,

$$\frac{x}{W(x)}=n$$


Although this has already been answered, I think a step by step explanation is more informative than a general one.

The following is my attempt:

\begin{align*} n \ln (n) =x \quad & \Rightarrow \quad \ln n^n=x \\ & \Rightarrow \quad n^n=e^x \\ & \Rightarrow \quad n=e^{x/n} \\ & \Rightarrow \quad n \times \frac{x}{n}=\frac{x}{n}e^{x/n} \\ & \Rightarrow \quad x=\frac{x}{n}e^{x/n} \\ & \Rightarrow \quad W(x)=W \left(\frac{x}{n}e^{x/n} \right) \\ & \Rightarrow \quad W(x)=\frac{x}{n} \\ & \Rightarrow \quad \boxed{n=\frac{x}{W(x)}} \\ & \Rightarrow \quad n=\frac{x}{x/e^{W(x)}} \quad \text{(since $W(x)e^{W(x)}=x$)}\\ & \Rightarrow \quad \boxed{n=e^{W(x)}} \\ \end{align*}