Solving $p^x = x^q$ [closed]
What is the best approach for solving the equations of the form
$p^x = x^q$ ; where $p$ and $q$ are some constants.
Basically, I wanted to solve $2^x = x^2$ to analyze algorithms with respective growth functions.
Such equations can be solved using the Lambert W function, defined to be an inverse function of $f(x)=xe^x$. Because $f$ is not injective, the Lambert W function is in fact a multifunction. It can be evaluated numerically, however there is a closed form for some values of $x$.
Now let us solve your equation: $$p^x=x^q \\ p^xx^{-q}=1$$
using the properties of $e$ and natural logarithms $$e^{x\ln p}x^{-q}=1 \\ e^{-\frac{x\ln p}{q}}x=1$$
Now we multiply by $-\frac{\ln p}{q}$ in order to use the definition of $W(x)$: $$-\frac{x\ln p}{q}\cdot e^{-\frac{x\ln p}{q}} =-\frac{\ln p}{q} \\ -\frac{x\ln p}{q}=W\left(-\frac{\ln p}{q} \right)$$
Finally, after some transformations we see that $$\boxed{x=-\dfrac{q\, W\left( -\frac{\ln p}{q}\right)}{\ln p}}$$ And that's the closest you can get to a closed form.