RealSign[x]
gives -1, 0 or 1 depending on whether x is negative, zero or positive.
RealSign
RealSign[x]
gives -1, 0 or 1 depending on whether x is negative, zero or positive.
Details
- RealSign is also known as sgn or signum.
- Mathematical function, suitable for both symbolic and numerical manipulation.
- RealSign[x] is equivalent to Piecewise[{{-1,x<0},{1,x>0}}].
- RealSign is piecewise constant and differentiable everywhere except at the origin.
- RealSign tries various transformations in trying to determine the sign of symbolic expressions.
- For exact numeric quantities, RealSign internally uses numerical approximations to establish its result. This process can be affected by the setting of the global variable $MaxExtraPrecision.
- RealSign automatically threads over lists. »
- RealSign can be used with Interval and CenteredInterval objects. »
Examples
open all close allBasic Examples (4)
Scope (28)
Numerical Evaluation (5)
RealSign[0.7]RealSign remains unevaluated for imaginary numbers:
RealSign[3 + 5I]RealSign always returns an infinite-precision result:
RealSign[1.5]%//PrecisionRealSign[0``200]%//PrecisionCompute the elementwise values of an array using automatic threading:
**RealSign**[{{1 / 2, -1}, {0, -1 / 2}}]Or compute the matrix RealSign function using MatrixFunction:
MatrixFunction[RealSign, {{1 / 2, -1}, {0, -1 / 2}}]Compute worst-case guaranteed intervals using Interval and CenteredInterval objects:
RealSign[Interval[{2, 3}]]RealSign[CenteredInterval[2, 1]]Or compute average-case statistical intervals using Around:
RealSign[ Around[2, 0.01]]Specific Values (5)
Values of RealSign at fixed points:
Table[RealSign[n ], {n, {1, 7 / 3, -7 / 5}}]RealSign[0]RealSign[Infinity]RealSign[-Infinity]PiecewiseExpand[RealSign[ x]]Find a value of
for which the
:
xval = x /. First@Solve[RealSign[x] == 0, x]Plot[RealSign[x], {x, -3, 3}, Epilog -> Style[Point[{xval, RealSign[xval]}], PointSize[Large], Red]]Visualization (3)
Plot[RealSign[1 + x], {x, -3, 3}, ExclusionsStyle -> Dashed]Plot RealSign along with its first derivative:
Plot[{RealSign[x], D[RealSign[x], x]}//Evaluate, {x, -3, 3}, ExclusionsStyle -> Dashed]Plot RealSign in three dimensions:
Plot3D[RealSign[x + y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> "BlueGreenYellow"]Function Properties (10)
RealSign is only defined for real inputs:
FunctionDomain[RealSign[x], x]FunctionDomain[RealSign[x], x, Complexes]Function range of RealSign:
FunctionRange[RealSign[x], x, y]RealSign is an odd function:
RealSign[-z]RealSign is not an analytic function:
FunctionAnalytic[RealSign[x], x]It has both a singularity and a discontinuity:
FunctionSingularities[RealSign[x], x]FunctionDiscontinuities[RealSign[x], x]RealSign is nondecreasing:
FunctionMonotonicity[RealSign[x], x]RealSign is not injective:
FunctionInjective[RealSign[x], x]Plot[{RealSign[x], 1}, {x, -4, 4}]RealSign is not surjective:
FunctionSurjective[RealSign[x], x]Plot[{RealSign[x], -2.5}, {x, -4, 4}]RealSign is neither non-negative nor non-positive:
FunctionSign[RealSign[x], x]RealSign is neither convex nor concave:
FunctionConvexity[RealSign[x], x]TraditionalForm formatting:
RealSign[x]//TraditionalFormDifferentiation and Integration (5)
First derivative with respect to
:
D[RealSign[x], x]Obtain an equivalent expression using the definition of derivative:
Underscript[, h -> 0]DifferenceQuotient[RealSign[z], {z, h}]The function Sign of complex variables is not differentiable:
Underscript[, hUnderscript[ -> , ℂ]0]DifferenceQuotient[Sign[z], {z, h}]Its higher derivatives are equal to its first derivative:
Table[D[RealSign[x], {x, k}], {k, 3}]Compute the indefinite integral using Integrate:
Integrate[RealSign[x], x]Integrate[RealSign[x], {x, -2, 5}]Integrate[RealAbs[x]RealSign[x], x]Integrate[ x RealSign[x^2], {x, 0, 3}]//FullSimplifyApplications (6)
Solve a differential equation with RealSign:
DSolveValue[{y'[x] + a y[x] == RealSign[x - 2], y[0] == 1}, y[x], x]Plot[Table[% /. {a -> m}, {m, 1, 4}]//Evaluate, {x, -1, 10}]Compute the Fourier cosine series of RealSign:
FourierSinSeries[RealSign[x], x, 7]Plot[Evaluate[{%, RealSign[x]}], {x, -Pi, Pi}]Solve an equation involving RealSign:
Reduce[RealSign[x + 3] + RealSign[x - 2] == 0, x]Prove an inequality containing RealSign:
Reduce[RealSign[z1 z2] == RealSign[z1]RealSign[z2], {z1, z2}, Reals]Simplify expressions containing RealSign:
{x + RealSign[x], RealSign[2x - 11]}Simplify[%, x > 10]r[n_, x_] := RealSign[Sin[2 ^ n Pi x]]Plot (vertically shifted) Rademacher functions:
Plot[Evaluate[Table[r[n, x] + n / 5, {n, 5}]], {x, -Pi, Pi}, Exclusions -> Sin[2 ^ 5 Pi x] == 0]Check orthogonality over the unit interval:
Table[Integrate[r[n1, x]r[n2, x], {x, 0, 1}], {n1, 3}, {n2, 3}]//FullSimplifyProperties & Relations (9)
RealSign is defined only for real numbers:
RealSign[{3, -5, 2 + 5I}]Sign is defined for complex numbers:
Sign[{3, -5, 2 + 5I}]RealSign is a differentiable function:
RealSign'[x]Sign is not differentiable:
Sign'[x]RealSign is an integrable function:
Integrate[RealSign[x], x]Sign is integrable only for real arguments:
Integrate[Sign[x], x]Assuming[x∈Reals, Integrate[Sign[x], x]]RealSign is idempotent:
RealSign[RealSign[z]]Use FullSimplify to simplify expressions involving RealSign:
FullSimplify[RealSign[a b] - RealSign[a] RealSign[b] + RealSign[a] - RealAbs[a] / a, Im[a] == 0 && Im[b] == 0]Integrate[RealSign[x], {x, -2, Pi}]Integrate[RealSign[x Sin[x]], {x, -2, Pi}]FourierTransform[RealSign[y], y, x]LaplaceTransform[RealSign[y], y, x]Convert into Piecewise:
PiecewiseExpand[RealSign[x]RealSign[1 - x]]PiecewiseExpand[RealSign[x + RealSign[1 - x]]]Possible Issues (4)
For purely real arguments, RealSign returns exact answers:
RealSign[1.3]RealSign can stay unevaluated for numeric arguments:
RealSign[(-1 - 2 E - E ^ 2 + (1 + E) ^ 2)]Use Simplify to obtain the sign of the expression:
Simplify[%]Machine‐precision numerical evaluation of RealSign can give wrong results:
RealSign[(-1 - 2 E - E ^ 2 + (1 + E) ^ 2) + 10 ^ -100]
N[%]Arbitrary‐precision evaluation gives the correct result:
N[%%, 20]
A larger setting for $MaxExtraPrecision can be necessary:
Block[{$MaxExtraPrecision = 102}, N[RealSign[(-1 - 2 E - E ^ 2 + (1 + E) ^ 2) + 10 ^ -100], 20]]RealSign applied to a matrix does not give the matrix sign function:
RealSign[{{1, 2}, {-2, 1}}]Neat Examples (3)
Form repeated convolution integrals starting with a symmetric product of three sign functions:
Convolution[f_, g_, x_] := Module[{y}, Simplify[Integrate[(f /. x -> x - y)(g /. x -> y), {y, -1, 1}, Assumptions -> x∈Reals], x∈Reals]]NestList[Convolution[#, RealSign[x]RealSign[x + 1]RealSign[1 - x], x]&, RealSign[x]RealSign[x + 1]RealSign[1 - x], 3]Plot[Evaluate[%], {x, -3, 3}]Approximate RealSign through a generalized Fourier series:
sign[n_, x_] := 2 Sum[(-1) ^ k HermiteH[2k + 1, x] / (2 ^ (2k)(2k + 1)k!), {k, 0, n}] / PiPlot[Evaluate[Flatten[{Table[sign[n, x], {n, 10}], RealSign[x]}]], {x, -2, 2}]Calculate rational approximations of RealSign:
Table[Tanh[2 n ArcTanh[1 / x]], {n, 4}]//FunctionExpand//Together//FactorPlot[Evaluate[%], {x, -10, 10}]Related Guides
Text
Wolfram Research (2017), RealSign, Wolfram Language function, https://reference.wolfram.com/language/ref/RealSign.html (updated 2021).
CMS
Wolfram Language. 2017. "RealSign." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/RealSign.html.
APA
Wolfram Language. (2017). RealSign. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RealSign.html
BibTeX
@misc{reference.wolfram_2026_realsign, author="Wolfram Research", title="{RealSign}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/RealSign.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_realsign, organization={Wolfram Research}, title={RealSign}, year={2021}, url={https://reference.wolfram.com/language/ref/RealSign.html}, note=[Accessed: 13-June-2026]}