Solve the following equation in R : $x^{2x}=({2x})^x $ 
Solve the following equation in R :
  $x^{2x}=({2x})^x $

My try: by taking logarithm to both sides
$2x\ln{x} = x\ln {2x}$
$\iff \ln x^2 = \ln2x$
$\iff x^2=2x \to x=2$ (accepted)  $or x=0$ (rejected)
But when input $x=-2$ , it seems to be avalid solution!  ; so how can I get it too?  
 A: By using the equality $\ln(a^b) = b\ln(a)$, you're promising that both sides of this equation make sense - so, that $a$ is in the domain of $\ln$, which would mean $a > 0$. Here's a trick to try: let's make sure that the thing inside the logarithm will be positive regardless.
$$x^{2x} = (2x)^x$$
$$(x^2)^x = ((2x)^2)^{x/2}$$
$$x\ln(x^2) = \frac{x}{2}\ln((2x)^2)$$
$$\ln(x^2) = \frac{1}{2}\ln((2x)^2)$$
$$2\ln(x^2) = \ln((2x)^2)$$
$$\ln(x^4) = \ln((2x)^2)$$
$$x^4 = (2x)^2$$
$$x^4 - 4x^2 = 0$$
The solutions of this polynomial equation are $0$, $2$, and $-2$. As you've observed, $0$ can be discarded, so the actual solutions are just $\pm 2$.
A: To simply the approach done by Reese without the fancy get-around of avoiding the case $x < 0$. We know that if $x$ is negative, then $x$ must be a ratio $p/q$ with odd denominator $q$, since otherwise $(2x)^x$ is not real.
You already dealt with the case $x > 0$, because as the comment by Gallegos, your derivation applies.
For $x < 0$, we have $(2x)^x = x^{2x} = (x^2)^x$ is positive, because $x^2 > 0$. So, since $2x < 0$, $p$ is an even integer. This means that $(2x)^x = (-2x)^x$ and hence $(-2x)^x = (x^2)^x = ((-x)^2)^x$. Now, since both sides are non-zero, you can reciprocate each side to get $(-2x)^{-x} = ((-x)^2)^{-x}$, so $-x$ must be a solution to the original problem. And since the only positive solution is $x = 2$, the only negative solution is $x= -2$.
