Artificial intelligent assistant

How to indicate keeping the sign when squaring a number. I have a vector $x$, which I wish to transform according the the following computer code xstar = sign(x) * x^2 with $x^*$ preserving the positiveness or negativeness of $x$. How would I write this in proper mathematics? Obviously $x^2$ is incorrect, and $$x^*=\begin{cases} x^2 & \text{if } x \geq 0 \\\ -x^2 & \text{if } x < 0 \end{cases}$$ is very clunky. Surely there must be something...

How about $x\cdot|x|$? That avoids the need for piecewise definition. And if $|x|$ is defined piecewise for you, then you can use $x\sqrt{x^2},$ instead.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 01206f0ea3c2c9c090359bab2fd371c2