Sign function
Template:Short description Template:Redirect Template:Distinguish
In mathematics, the sign function or signum function (from signum, Latin for "sign") is a function that has the value Template:Math, Template:Math or Template:Math 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>.<ref name=":0">{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>
DefinitionEdit
The signum function of a real number <math>x</math> is a piecewise function which is defined as follows:<ref name=":0" /> <math display="block"> \sgn x :=\begin{cases} -1 & \text{if } x < 0, \\ 0 & \text{if } x = 0, \\ 1 & \text{if } x > 0. \end{cases}</math>
The law of trichotomy states that every real number must be positive, negative or zero. The signum function denotes which unique category a number falls into by mapping it to one of the values Template:Math, Template:Math or Template:Math which can then be used in mathematical expressions or further calculations.
For example: <math display="block">\begin{array}{lcr} \sgn(2) &=& +1\,, \\ \sgn(\pi) &=& +1\,, \\ \sgn(-8) &=& -1\,, \\ \sgn(-\frac{1}{2}) &=& -1\,, \\ \sgn(0) &=& 0\,. \end{array}</math>
Basic propertiesEdit
Any real number can be expressed as the product of its absolute value and its sign: <math display="block"> x = |x| \sgn x\,.</math>
It follows that whenever <math>x</math> is not equal to 0 we have <math display="block"> \sgn x = \frac{x}{|x|} = \frac{|x|}{x}\,.</math>
Similarly, for any real number <math>x</math>, <math display="block"> |x| = x\sgn x\,. </math> We can also be certain that: <math display="block">\sgn (xy)=(\sgn x)(\sgn y)\,,</math> and so <math display="block">\sgn (x^n)=(\sgn x)^n\,.</math>
Some algebraic identitiesEdit
The signum can also be written using the Iverson bracket notation: <math display="block">\sgn x = -[x < 0] + [x > 0] \,.</math>
The signum can also be written using the floor and the absolute value functions: <math display="block">\sgn x = \Biggl\lfloor \frac{x}{|x|+1} \Biggr\rfloor - \Biggl\lfloor \frac{-x}{|x|+1} \Biggr\rfloor \,.</math> If <math>0^0</math> is accepted to be equal to 1, the signum can also be written for all real numbers as <math display="block">\sgn x = 0^ \left ( - x + \left\vert x \right\vert \right ) - 0^ \left ( x + \left\vert x \right\vert \right ) \,.</math>
Properties in mathematical analysisEdit
Discontinuity at zeroEdit
Although the sign function takes the value Template:Math when <math>x</math> is negative, the ringed point Template:Math in the plot of <math>\sgn x</math> indicates that this is not the case when <math>x=0</math>. Instead, the value jumps abruptly to the solid point at Template:Math where <math>\sgn(0)=0</math>. There is then a similar jump to <math>\sgn(x)=+1</math> when <math>x</math> is positive. Either jump demonstrates visually that the sign function <math>\sgn x</math> is discontinuous at zero, even though it is continuous at any point where <math>x</math> is either positive or negative.
These observations are confirmed by any of the various equivalent formal definitions of continuity in mathematical analysis. A function <math>f(x)</math>, such as <math>\sgn(x),</math> is continuous at a point <math>x=a</math> if the value <math>f(a)</math> can be approximated arbitrarily closely by the sequence of values <math>f(a_1),f(a_2),f(a_3),\dots,</math> where the <math>a_n</math> make up any infinite sequence which becomes arbitrarily close to <math>a</math> as <math>n</math> becomes sufficiently large. In the notation of mathematical limits, continuity of <math>f</math> at <math>a</math> requires that <math>f(a_n) \to f(a)</math> as <math>n \to \infty</math> for any sequence <math>\left(a_n\right)_{n=1}^\infty</math> for which <math>a_n \to a.</math> The arrow symbol can be read to mean approaches, or tends to, and it applies to the sequence as a whole.
This criterion fails for the sign function at <math>a=0</math>. For example, we can choose <math>a_n</math> to be the sequence <math>1,\tfrac{1}{2},\tfrac{1}{3},\tfrac{1}{4},\dots,</math> which tends towards zero as <math>n</math> increases towards infinity. In this case, <math>a_n \to a</math> as required, but <math>\sgn(a)=0</math> and <math>\sgn(a_n)=+1</math> for each <math>n,</math> so that <math>\sgn(a_n) \to 1 \neq \sgn(a)</math>. This counterexample confirms more formally the discontinuity of <math>\sgn x</math> at zero that is visible in the plot.
Despite the sign function having a very simple form, the step change at zero causes difficulties for traditional calculus techniques, which are quite stringent in their requirements. Continuity is a frequent constraint. One solution can be to approximate the sign function by a smooth continuous function; others might involve less stringent approaches that build on classical methods to accommodate larger classes of function.
Smooth approximations and limitsEdit
The signum function can be given as a number of different (pointwise) limits: <math display="block">\begin{align} \sgn x &= \lim_{n\to\infty}\frac{1-2^{-nx}}{1+2^{-nx}}\\
&= \lim_{n\to\infty}\frac{2}{\pi}\operatorname{arctan}(nx)\\ &= \lim_{n\to\infty}\tanh(nx)\\ &= \lim_{\varepsilon\to 0} \frac{x}{\sqrt{x^2 + \varepsilon^2}}.
\end{align}</math> Here, <math>\tanh</math> is the hyperbolic tangent, and <math>\operatorname{arctan}</math> is the inverse tangent. The last of these is the derivative of <math>\sqrt{x^2+\varepsilon ^2}</math>. This is inspired from the fact that the above is exactly equal for all nonzero <math>x</math> if <math>\varepsilon=0</math>, and has the advantage of simple generalization to higher-dimensional analogues of the sign function (for example, the partial derivatives of <math>\sqrt{x^2+y^2}</math>).
DifferentiationEdit
The signum function <math>\sgn x</math> is differentiable everywhere except when <math>x=0.</math> Its derivative is zero when <math>x</math> is non-zero: <math display="block"> \frac{\text{d}\, (\sgn x)}{\text{d}x} = 0 \qquad \text{for } x \ne 0\,.</math>
This follows from the differentiability of any constant function, for which the derivative is always zero on its domain of definition. The signum <math>\sgn x</math> acts as a constant function when it is restricted to the negative open region <math>x<0,</math> where it equals Template:Math. It can similarly be regarded as a constant function within the positive open region <math>x>0,</math> where the corresponding constant is Template:Math. Although these are two different constant functions, their derivative is equal to zero in each case.
It is not possible to define a classical derivative at <math>x=0</math>, because there is a discontinuity there.
Although it is not differentiable at <math>x=0</math> in the ordinary sense, under the generalized notion of differentiation in distribution theory, the derivative of the signum function is two times the Dirac delta function. This can be demonstrated using the identity <ref>{{#invoke:Template wrapper|{{#if:|list|wrap}}|_template=cite web |_exclude=urlname, _debug, id |url = https://mathworld.wolfram.com/{{#if:Sign%7CSign.html}} |title = Sign |author = Weisstein, Eric W. |website = MathWorld |access-date = |ref = Template:SfnRef }}</ref> <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:<ref>{{#invoke:Template wrapper|{{#if:|list|wrap}}|_template=cite web |_exclude=urlname, _debug, id |url = https://mathworld.wolfram.com/{{#if:HeavisideStepFunction%7CHeavisideStepFunction.html}} |title = Heaviside Step Function |author = Weisstein, Eric W. |website = MathWorld |access-date = |ref = Template:SfnRef }}</ref> <math display="block"> \frac{\text{d}\sgn x}{\text{d}x} = 2 \frac{\text{d} H(x)}{\text{d}x} = 2\delta(x) \,.</math>
IntegrationEdit
The signum function has a definite integral between any pair of finite values Template:Mvar and Template:Mvar, even when the interval of integration includes zero. The resulting integral for Template:Mvar and Template:Mvar 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 Template:Math, 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 Template:Math 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.
Fourier transformEdit
The Fourier transform of the signum function is<ref>Template:Cite journal</ref> <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.
GeneralizationsEdit
Complex signumEdit
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>,<ref>Maple V documentation. May 21, 1998</ref> 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>z\ne 0</math>): <math display="block">\operatorname{csgn} z = \frac{z}{\sqrt{z^2}} = \frac{\sqrt{z^2}}{z}. </math>
Polar decomposition of matricesEdit
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 functionEdit
At real values of <math>x</math>, it is possible to define a generalized function–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<ref name="Algebra"> Template:Cite journal</ref> <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 alsoEdit
- 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
NotesEdit
<references/>