How to solve this equation $x^{2}=2^{x}$?

The equation can be written $x\log2=2\log|x|$. Let's consider the function $$ f(x)=x\log2-2\log|x| $$ defined for $x\ne0$. We have easily $$ \lim_{x\to-\infty}f(x)=-\infty, \qquad \lim_{x\to\infty}f(x)=\infty $$ and $$ \lim_{x\to0}f(x)=\infty. $$ Moreover $$ f'(x)=\log2-\frac{2}{x}=\frac{x\log2-2}{x} $$ Set $\alpha=2/\log2$; then $f'(x)$ is positive for $x<0$ and for $x>\alpha$, while it's negative for $0<x<\alpha$.

Thus the function is increasing in $(-\infty,0)$, which accounts for a solution in this interval. In the interval $(0,\infty)$ the function has a minimum at $\alpha$ and $$ f(\alpha)=\frac{2}{\log2}\log2-2\log\frac{2}{\log2} =2(1-\log2+\log\log2)\approx-0.85 $$ Since the minimum is negative, this accounts for two solutions in $(0,\infty)$, which clearly are $x=2$ and $x=4$.


Try this, first suppose $x > 0$, then you take $x<0$.

$$\begin{align}x^2 = 2^x &\Rightarrow (x^2)^{\frac{1}{2}} = (2^x)^\frac{1}{2} \Rightarrow x= 2^\frac{x}{2} \\ & \Rightarrow x \ e^{-x\frac{\ln\ 2}{2}} = 1 \Rightarrow -x \frac{\ln\ 2}{2}\ e^{-x\frac{\ln\ 2}{2}} = -\frac{\ln \ 2}{2} \\ &\Rightarrow -x \frac{\ln\ 2}{2} = W(-\frac{\ln\ 2}{2}) \Rightarrow x = -\frac{2\ W(-\frac{\ln \ 2}{2})}{\ln\ 2}\end{align}$$

Which gives us

$x = -\frac{2\ W(\frac{-\ln \ 2}{2})}{\ln\ 2} = 2$ , in case $x > 0$

Similarly we may find

$x = -\frac{2\ W(\frac{\ln \ 2}{2})}{\ln\ 2} \approx -0,76666$, in case $x < 0$

Where $W$ is the Lambert's funtion.