The signum function expressed using a single formula
The signum function is defined as a piecewise function: $\operatorname{sgn} (x)=\left\{ \begin{matrix} 1,x>0 \\ 0,x=0 \\ -1,x<0 \\ \end{matrix} \right.$.
Naturally, we could simplify this: $\operatorname{sgn} (x)=\left\{ \begin{matrix} \frac{\left| x \right|}{x},x\ne 0 \\ 0,x=0 \\ \end{matrix} \right.$.
I’m just wondering is it possible to define this function using a single formula? I understand that the absolute value $\left| x \right|$ is a piecewise function itself but for the sake of this question let’s assume we are allowed to use modulus to define the signum function.
Edit:
I completely agree with the answers given below; however, my original question was about the possibility to define the signum function using only elementary functions and the absolute value function (which itself is not an elementary function) in such a way that would require exactly one formula (i.e., avoiding a piecewise function). For example, the following function $g\left( x \right)=\left\{ \begin{matrix} x,x>0 \\ 0,x\le 0 \\ \end{matrix} \right.$ can be defined in such a manner: $g\left( x \right)=\frac{x+\left| x \right|}{2}$.
$\endgroup$ 41 Answer
$\begingroup$Using only the arithmetic operations, the identity function and the absolute value, this does not seem possible, because the $\text{sgn}$ function is discontinuous. As far as I see, a discontinuity can only appear with a division by zero, which results in an undefined value in at least one point.
$\endgroup$