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?
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$.