thumb|Signum function <math>y = \sgn x</math>

In mathematics, the sign function or signum function (from signum, Latin for "sign") is a function that has the value , or according to whether the sign of a given real number is positive or negative, or the given number is itself zero. In mathematical notation the sign function is often represented as <math>\sgn x</math> or <math>\sgn (x)</math>.

Definition

The signum function of a real number <math>x</math> is a piecewise function which is defined as follows:

<math display="block"> \sgn x = 2 H(x) - 1 \,,</math>

where <math>H(x)</math> is the Heaviside step function using the standard <math>H(0)=\frac{1}{2}</math> formalism.

Using this identity, it is easy to derive the distributional derivative:

<math display="block"> \frac{\text{d}\sgn x}{\text{d}x} = 2 \frac{\text{d} H(x)}{\text{d}x} = 2\delta(x) \,.</math>

Integration

The signum function has a definite integral between any pair of finite values and , even when the interval of integration includes zero. The resulting integral for and is then equal to the difference between their absolute values:

<math display="block"> \int_a^b (\sgn x) \, \text{d}x = |b| - |a| \,.</math>

In fact, the signum function is the derivative of the absolute value function, except where there is an abrupt change in gradient at zero:

<math display="block"> \frac{\text{d} |x|}{\text{d}x} = \sgn x \qquad \text{for } x \ne 0\,.</math>

We can understand this as before by considering the definition of the absolute value <math>|x|</math> on the separate regions <math>x>0</math> and <math>x<0.</math> For example, the absolute value function is identical to <math>x</math> in the region <math>x>0,</math> whose derivative is the constant value , which equals the value of <math>\sgn x</math> there.

Because the absolute value is a convex function, there is at least one subderivative at every point, including at the origin. Everywhere except zero, the resulting subdifferential consists of a single value, equal to the value of the sign function. In contrast, there are many subderivatives at zero, with just one of them taking the value <math>\sgn(0) = 0</math>. A subderivative value occurs here because the absolute value function is at a minimum. The full family of valid subderivatives at zero constitutes the subdifferential interval <math>[-1,1]</math>, which might be thought of informally as "filling in" the graph of the sign function with a vertical line through the origin, making it continuous as a two dimensional curve.

In integration theory, the signum function is a weak derivative of the absolute value function. Weak derivatives are equivalent if they are equal almost everywhere, making them impervious to isolated anomalies at a single point. This includes the change in gradient of the absolute value function at zero, which prohibits there being a classical derivative.

The antiderivative of a function multiplied by the signum function is:<math display="block">\int {\sgn (x) f(x) \text{d}x} = \sgn (x) F(x) + B\sgn (x) + C \,,</math>where <math display="inline">B</math> and <math display="inline">C</math> are constants of integration. Outside of distribution theory, <math display="inline">B</math> can take on any value, most commonly 0. When considering the Dirac delta function, <math display="inline">B</math> has to equal <math display="inline">F(0)</math>. This can be proven using integration by parts:<math display="block">\int {\sgn (x) f(x) \text{d}x} = \sgn(x) F(x) - \int {2 \delta(x) F(x)\text{d}x}\,,</math>where <math display="inline">\delta(x)</math> is the Dirac delta function. Integrating, the following expression can be obtained:

<math>\sgn(x) F(x) - \int {2 \delta(x) F(x)\text{d}x} = \sgn (x) F(x) - 2F(0)H(x) + C = \sgn (x) F(x) - \sgn(x) F(0) + C \,,</math>

where <math display="inline">H(x)</math> is the Heaviside step function. Since <math display="inline">F(x)</math> already has its own integration constant, unrelated to <math display="inline">C</math>, <math display="inline">F(0)</math> can take on any value as long as it is defined. If Dirac delta function is considered, the integration constant of <math display="inline">F(x)</math> has to mach in both terms; otherwise, the derivative of the signum function is 0, so it can be multiplied by any constant in the second term.

Fourier transform

The Fourier transform of the signum function is

<math display="block">PV\int_{-\infty}^\infty (\sgn x) e^{-ikx}\text{d}x = \frac{2}{ik} \qquad \text{for } k \ne 0,</math>

where <math>PV</math> means taking the Cauchy principal value.

Generalizations

Complex signum

<!-- Complex sign function and Complex signum function redirect here -->

The signum function can be generalized to complex numbers as:

<math display="block">\sgn z = \frac{z}{|z|} </math>

for any complex number <math>z</math> except <math>z=0</math>. The signum of a given complex number <math>z</math> is the point on the unit circle of the complex plane that is nearest to <math>z</math>. Then, for <math>z\ne 0</math>,

<math display="block">\sgn z = e^{i\arg z}\,,</math>

where <math>\arg</math> is the complex argument function.

For reasons of symmetry, and to keep this a proper generalization of the signum function on the reals, also in the complex domain one usually defines, for <math>z=0</math>:

<math display="block">\sgn(0+0i)=0</math>

Another generalization of the sign function for real and complex expressions is <math>\text{csgn}</math>, which is defined as:

<math display="block">

\operatorname{csgn} z= \begin{cases}

1 & \text{if } \mathrm{Re}(z) > 0, \\

-1 & \text{if } \mathrm{Re}(z) < 0, \\

\sgn \mathrm{Im}(z) & \text{if } \mathrm{Re}(z) = 0

\end{cases}

</math>

where <math>\text{Re}(z)</math> is the real part of <math>z</math> and <math>\text{Im}(z)</math> is the imaginary part of <math>z</math>.

We then have (for <math>\mathrm{Re}(z)\ne 0</math>):

<math display="block">\operatorname{csgn} z = \frac{z}{\sqrt{z^2 = \frac{\sqrt{z^2{z}. </math>

Polar decomposition of matrices

<!-- Was "Generalization to matrices" -->

Thanks to the Polar decomposition theorem, a matrix <math>\boldsymbol A\in\mathbb K^{n\times n}</math> (<math>n\in\mathbb N</math> and <math>\mathbb K\in\{\mathbb R,\mathbb C\}</math>) can be decomposed as a product <math>\boldsymbol Q\boldsymbol P</math> where <math>\boldsymbol Q</math> is a unitary matrix and <math>\boldsymbol P</math> is a self-adjoint, or Hermitian, positive definite matrix, both in <math>\mathbb K^{n\times n}</math>. If <math>\boldsymbol A</math> is invertible then such a decomposition is unique and <math>\boldsymbol Q</math> plays the role of <math>\boldsymbol A</math>'s signum. A dual construction is given by the decomposition <math>\boldsymbol A=\boldsymbol S\boldsymbol R</math> where <math>\boldsymbol R</math> is unitary, but generally different than <math>\boldsymbol Q</math>. This leads to each invertible matrix having a unique left-signum <math>\boldsymbol Q</math> and right-signum <math>\boldsymbol R</math>.

In the special case where <math>\mathbb K=\mathbb R,\ n=2,</math> and the (invertible) matrix <math>\boldsymbol A = \left[\begin{array}{rr}a&-b\\b&a\end{array}\right]</math>, which identifies with the (nonzero) complex number <math>a+\mathrm i b=c</math>, then the signum matrices satisfy <math>\boldsymbol Q=\boldsymbol P=\left[\begin{array}{rr}a&-b\\b&a\end{array}\right]/|c|</math> and identify with the complex signum of <math>c</math>, <math>\sgn c = c/|c|</math>. In this sense, polar decomposition generalizes to matrices the signum-modulus decomposition of complex numbers.

Signum as a generalized function

<!-- Was "Generalized signum function" -->

At real values of <math>x</math>, it is possible to define a generalized function&ndash;version of the signum function, <math>\varepsilon (x)</math> such that <math>\varepsilon (x)^2=1</math> everywhere, including at the point <math>x=0</math>, unlike <math>\sgn</math>, for which <math>(\sgn 0)^2=0</math>. This generalized signum allows construction of the algebra of generalized functions, but the price of such generalization is the loss of commutativity. In particular, the generalized signum anticommutes with the Dirac delta function

<math display="block">\varepsilon (x) \delta(x)+\delta(x) \varepsilon(x) = 0 \, ;</math>

in addition, <math>\varepsilon (x)</math> cannot be evaluated at <math>x=0</math>; and the special name, <math>\varepsilon</math> is necessary to distinguish it from the function <math>\sgn</math>. (<math>\varepsilon (0)</math> is not defined, but <math>\sgn 0=0</math>.)

See also

  • Absolute value
  • Heaviside step function
  • Negative number
  • Rectangular function
  • Sigmoid function (Hard sigmoid)
  • Step function (Piecewise constant function)
  • Three-way comparison
  • Zero crossing
  • Polar decomposition
  • Parity of a permutation

Notes