I have read How is it, that $\sqrt{x^2}$ is not $ x$, but $|x|$? and Is $\sqrt{x^2}=|x|$ or $=x$? Isn't $(x^2)^\frac12=x?$, but I can't understand what the value of $(\sqrt{-x})^2$ is when using complex numbers. My understanding is that it can be either
$x$, since
$$(\sqrt{-x})^2 = \sqrt{-x} \cdot \sqrt{-x} = \sqrt{(-x)\cdot(-x)} = \sqrt{x^2} = x$$
or $-x$, since
$$(\sqrt{-x})^2 = (\sqrt{x} \cdot i)^2 = \sqrt{x}^2 \cdot i^2 = x \cdot (-1) = -x$$
Is this reasoning wrong? If so, why is it wrong and what is the correct solution?
This is because the property $\sqrt{xy} = \sqrt{x}\sqrt{y}$ that we're using does not hold for $x,y \in \Bbb C$, only for $x,y \in \Bbb R$. The complex square root is not a function per se, it is a multi-valued function.