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 ?
Where did I make a mistake in simplifying this
lambert-w
Related Solutions
We can use a procedure known as "bootstrapping" to determine an approximation for the Lambert $W$ function. Let's go back to its definition.
For $x > 0$ the equation
$$ we^w = x $$
has exactly one positive solution $w = W(x)$ which increases with $x$. Note that $(w,x) = (1,e)$ is one such solution, so if $x > e$ then $w > 1$. By taking logarithms of both sides of the equation we get
$$ \log w + w = \log x $$
or
$$ w = \log x - \log w. \tag{1} $$
When $x > e$ we therefore have
$$ w = \log x - \log w < \log x. $$
In other words, our first approximation is that
$$ 1 < w < \log x \tag{2} $$
when $x > e$. We then have
$$ 0 < \log w < \log\log x, $$
and plugging this into $(1)$ yields
$$ \log x - \log \log x < w < \log x, \tag{3} $$
where the left side is positive for $x > 1$. Taking logarithms as before yields
$$ \log\log x + \log\left(1 - \frac{\log\log x}{\log x}\right) < \log w < \log\log x, $$
and upon substituting this back into $(1)$ we get
$$ \log x - \log\log x < w < \log x - \log\log x - \log\left(1 - \frac{\log\log x}{\log x}\right). $$
Since $w = W(x)$ we have shown that
$$ \log x - \log\log x < W(x) < \log x - \log\log x - \log\left(1 - \frac{\log\log x}{\log x}\right) \tag{4} $$ for $x > e$.
In your particular case we're interested in $W(e^{x+a})$, for which we have
$$ x+a - \log(x+a) < W(e^{x+a}) < x+a - \log(x+a) - \log\left(1 - \frac{\log(x+a)}{x+a}\right) $$
for $x+a > 1$. In this sense we have
$$ W(e^{x+a}) \approx x+a - \log(x+a) = x\left(1 - \frac{\log(x+a) - a}{x}\right) \tag{5} $$
when $x+a$ is large. Now by applying Taylor series a couple times we see that, for $x$ large and $a \ll x$,
$$ \begin{align} \frac{\log x - a}{x+1} &= \frac{\log x - a}{x} \cdot \frac{1}{1+\frac{1}{x}} \\ &\approx \frac{\log x - a}{x} \left(1-\frac{1}{x}\right) \\ &= \frac{\log x - a}{x} - \frac{\log x - a}{x^2} \\ &= \frac{\log(x+a-a) - a}{x} - \frac{\log x - a}{x^2} \\ &= \frac{\log(x+a) + \log\left(1-\frac{a}{x+a}\right) - a}{x} - \frac{\log x - a}{x^2} \\ &= \frac{\log(x+a) - a}{x} + \frac{\log\left(1-\frac{a}{x+a}\right)}{x} - \frac{\log x - a}{x^2} \\ &\approx \frac{\log(x+a) - a}{x} - \frac{a}{x(x+a)} - \frac{\log x - a}{x^2} \\ &\approx \frac{\log(x+a) - a}{x}. \end{align} $$
We may then conclude from $(5)$ that
$$ W(e^{x+a}) \approx x \left(1 - \frac{\log x - a}{x+1}\right) $$
for $x$ large and $a \ll x$.
$$1-x=\frac{\alpha x}{e^{\alpha x}-1}$$ $$(1-x)(e^{\alpha x}-1)=\alpha x$$ $$(1-x)e^{\alpha x}-1+x=\alpha x$$
Your equation is an equation of elementary functions. For rational $\alpha$, the equation is related to an algebraic equation in dependence of $x$ and $e^x$. Because the terms $x,e^x$ are algebraically independent and the equation is irreducible, we don't know how to rearrange the equation for $x$ by only elementary operations (means elementary functions). A theorem of Lin (1983) proves, if Schanuel's conjecture is true, that irreducible algebraic equations involving both $x$ and $e^x$ don't have solutions in the elementary numbers.
$$(1-x)e^{\alpha x}=\alpha x+1-x$$ $$(1-x)e^{\alpha x}=(\alpha-1)x+1$$ $$\frac{1-x}{(\alpha-1)x+1}e^{\alpha x}=1$$ $$\frac{1-x}{x+\frac{1}{\alpha-1}}e^{\alpha x}=\alpha-1$$
We see, your equation cannot be solved in terms of Lambert W but in terms of Generalized Lambert W:
$$\frac{x-1}{x+\frac{1}{\alpha-1}}e^{\alpha x}=1-\alpha$$ $$\frac{x-1}{x-\frac{1}{1-\alpha}}e^{\alpha x}=1-\alpha$$ $$x=W\left(^{\ \ \ 1}_{\frac{1}{1-a}};1-a\right)$$
The inverse relation of your kind of equations is what Mezö et al. call $r$-Lambert function. They write: "Depending on the parameter $r$, the $r$-Lambert function has one, two or three real branches and so the above equations can have one, two or three solutions"
So we have a closed form for $x$, and the representations of Generalized Lambert W give some hints for calculating $x$.
[Mező 2017] Mező, I.: On the structure of the solution set of a generalized Euler-Lambert equation. J. Math. Anal. Appl. 455 (2017) (1) 538-553
[Mező/Baricz 2017] Mező, I.; Baricz, Á.: On the generalization of the Lambert W function. Transact. Amer. Math. Soc. 369 (2017) (11) 7917–7934 (On the generalization of the Lambert W function with applications in theoretical physics. 2015)
[Castle 2018] Castle, P.: Taylor series for generalized Lambert W functions. 2018
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$.