y=sgnxy = \operatorname{sgn} x

Graph of the Sign Function y=sgnxy = \operatorname{sgn} x

y=sgnxy = \operatorname{sgn} x is called the sign function. It extracts nothing but the sign of a real number xx and returns one of three values1.

sgnx={1(x>0)0(x=0)1(x<0)\operatorname{sgn} x = \begin{cases} 1 & (x > 0) \\ 0 & (x = 0) \\ -1 & (x < 0) \end{cases}
xxsgnx\operatorname{sgn} x
3.53.511
0000
2-21-1

Domain and range

The domain is all real numbers, but the range consists of just three values: 1-1, 00 and 11. The graph is two horizontal half-lines, at height 1-1 for x<0x < 0 and at height 11 for x>0x > 0, with a single isolated point of height 00 at the origin.

Symmetry

Since sgn(x)=sgnx\operatorname{sgn}(-x) = -\operatorname{sgn} x, the function is odd, with point symmetry about the origin. The value sgn(0)=0\operatorname{sgn}(0) = 0 is consistent with that symmetry; indeed taking 00 at the origin is forced by oddness.

Discontinuity and jump

The origin is the only point of discontinuity. The limit from the left is 1-1 and from the right is +1+1, so the two disagree and the jump has size 22. The value itself is 00, halfway between. Everywhere else the function is constant, hence continuous, with derivative 00.

Relation to the absolute value

The sign function is closely tied to the absolute value.

x=xsgnxsgnx=xx(x0)\begin{align*} |x| &= x \cdot \operatorname{sgn} x \\ \operatorname{sgn} x &= \frac{x}{|x|} \quad (x \neq 0) \end{align*}

The second holds only for x0x \neq 0. Differentiating x|x| gives sgnx\operatorname{sgn} x on x0x \neq 0: differentiating a function with a corner produces a function with a jump.

Relation to the step function

It is related to the Heaviside step function H(x)H(x) as follows2.

sgnx=2H(x)1\operatorname{sgn} x = 2H(x) - 1

The step function takes the two values 00 and 11; doubling it vertically and lowering it by 11 gives the sign function. The range then becomes symmetric between 1-1 and 11, which makes it convenient for representing a direction.

Applications

  • Computing an absolute value, and folding a case analysis into a single formula
  • On-off control in control engineering
  • Classification by sign in machine learning

It comes into its own wherever the direction of a quantity matters more than its size.

  1. Sign function, Wikipedia
  2. Heaviside step function, Wikipedia