Where did I make a mistake in simplifying this

lambert-w

So I found general solution to $x^y=y^x$ for positive values on the Internet via Lambert $W$ function and it goes like this: $$y=\frac{-x\cdot W\left(\frac{-\log(x)}{x}\right)}{\log(x)}.$$ Now there is an identity for Lambert $W$ function $$W\left(\frac{-\log(x)}{x}\right)=\log({x}^{-1}).$$ Using this identity you can simplify the solution to $y=x$. Which certainly is not general solution, so I think I made a mistake somewhere here when used this identity, maybe it is something connected with the values for which the identity is true. So where is the mistake ?

Best Answer

Lambert $W$ function is defined as an inverse function to $f(x)=xe^x$, which is not injective on $\mathbb{R}$. So actually there are multiple different Lambert $W$ functions (branches), or, you can view this as $W(x)$ being a multi-valued function.

Specifically we have two branches (well in complex numbers there are actually infinitely many, but that is another story), usually denoted $W_0(x)$ defined for $(-1/e,\infty)$ (also called principal branch, corresponding to the inverse on $(-1,\infty)$), and $W_{-1}(x)$ defined for $(-1/e,0)$ (corresponding to the inverse on $(-\infty,-1)$).

Now both branches satisfy the first equation you came to, so far no problem there. Problem becomes with the identity $W\left(\frac{-\log x}{x}\right)=\log({x}^{-1})$, which is true for each of the branches only with certain restrictions. Specifically, $$W_0\left(\frac{-\log x}{x}\right)=\log({x}^{-1})$$ for $x \in (0,e]$, and similarly $$W_{-1}\left(\frac{-\log x}{x}\right)=\log({x}^{-1})$$ for $x \in (e,\infty)$.

How does that apply to your problem? Well it just means that by applying the identity above, you have only considered subset of solutions. To get all solutions, you also need to add $y=\frac{-x}{\log x}\cdot W_0\left(\frac{-\log x}{x}\right)$ for $x>e$, and similarly $y=\frac{-x}{\log x}\cdot W_{-1}\left(\frac{-\log x}{x}\right)$ for $x \leq e$. And indeed, this covers some previously missing cases, for example with $x=4$ we obtain $y=\frac{-4}{\log4 }\cdot W_0\left(\frac{-\log 4}{4}\right)=2$.