TITLE: Should the sign be reversed if I square both sides of an inequality?
QUESTION [16 upvotes]: Let us say I have the following:
$$x>y$$
Now, I want to take the square of both sides. Should it result in $$x^2>y^2$$ or $$x^2<y^2$$
I suspect there is no way to give a general answer to this. I would like to know how to analyze this nevertheless.

REPLY [4 votes]: Maybe this will be helpful:
$$
x \geq y \Longleftrightarrow \mathrm{sgn}(x)x^2 \geq \mathrm{sgn}(y)y^2
$$
Where $ \mathrm{sgn}(\cdot) $ is the sign function. It is what I use to test inequalities for computational purposes. You can check it on a case-by-case level, i.e. by checking the three possible cases

$x\geq0,y\geq0$,
$x\geq 0,y\leq 0$,
$x\leq 0,y\leq 0$.