How to solve $x^2=2^x$ algebraically? I've been trying to solve this very basic looking equation algebraically and can't find a way. Is there one?
$$2^x=x^2$$
So far I have:
$$\ln 2^x=\ln x^2$$
$$x\ln 2=2\ln x$$
$$\frac{x}{\ln x}=\frac{2}{\ln 2}$$
But now I'm stuck. Any hints appreciated!
 A: You will have to use the Lambert W function, which is the inverse of $f(z)=ze^z$, in order to solve it algebraically.
Here is the work, following yours:
$$\frac{x}{\log x}=\frac 2{\log 2}$$
$$\frac{\log x}{x}= \frac{\log 2}2$$
$$-\frac{\log x}{x}= -\frac{\log 2}2$$
$$-{\log x} \cdot e^{-\log x}= \frac{\log 2}2$$
$$-\log x=W\left(\frac{\log 2}2\right)$$
$$\log x=-W\left(\frac{\log 2}2\right)$$
$$x=\exp\left({-W\left(\frac{\log 2}2\right)}\right)$$
As stated in the comments, $x=2,4$ are solutions. There is also another solution $x\approx -0.767$, which can be quickly found with Newton's method.
However, there are also infinitely many complex solutions! Some are:
$$7.6545-11.9537i$$
$$10.0368-30.8181i$$
$$11.3157-49.2037i$$
These can be found with Newton's method as well, just starting from an imaginary number.
A: We can solve equations of the form $x^\alpha=\beta^x$ for $x\in\Bbb C$ analytically using the special function known as the Lambert W function $W(z)$, defined as the inverse function of $ze^z$. It has infinitely many branches (like how $\log z$ is only defined up to an integer multiple of $2\pi i$), so there will in general by an infinite number of complex solutions.
Here's how. To start off with, we can absorb the constants together and introduce $\exp$:
$$x^\alpha=\beta^x\iff x=\beta^{x/\alpha}=e^{\gamma x} \qquad{\rm where}~\gamma=\frac{\ln\beta}{\alpha}$$
The way forward from here goes as follows:
$$\begin{array}{ll} x=e^{\gamma x} & \iff xe^{-\gamma x}=1 \\ & \iff -\gamma x e^{-\gamma x}=-\gamma \\ & \iff -\gamma x=W(-\gamma) \\ & \iff x=\frac{W(-\gamma)}{-\gamma}=-\frac{\alpha}{\ln\beta}W(-\frac{\ln\beta}{\alpha}).\end{array}$$
Of course this doesn't help us find $x=2,4$ in this case, but the theory can help us numerically approximate solutions in general where there are no easy symbolic solutions.
A: Unfortunately, you can't.
To solve this mixed equation,
you can use the
Lambert W function.
