UnitStep
Details
- Some transformations are done automatically when UnitStep appears in a product of terms.
- UnitStep provides a convenient way to represent piecewise continuous functions.
- UnitStep has attribute Orderless.
- For exact numeric quantities, UnitStep internally uses numerical approximations to establish its result. This process can be affected by the setting of the global variable $MaxExtraPrecision.
- UnitStep[] is 1.
- UnitStep automatically threads over lists. »
Examples
open all close allBasic Examples (4)
UnitStep[.8]Plot[UnitStep[x], {x, -3, 3}]Plot3D[UnitStep[x, y], {x, -3, 3}, {y, -3, 3}, Mesh -> 5]UnitStep is a piecewise function:
PiecewiseExpand[UnitStep[x]]Scope (34)
Numerical Evaluation (6)
UnitStep[-1]UnitStep[1 / 2]UnitStep[1, Pi, 5.3]UnitStep always returns an exact result:
UnitStep[{-1.6, 3.200000000000}]Evaluate efficiently at high precision:
UnitStep[1 / 7`100]//TimingUnitStep[5 / 9`100000000];//TimingUnitStep can deal with real‐valued intervals:
UnitStep[Interval[{-1, 2}]]Compute the elementwise values of an array using automatic threading:
UnitStep[{{1 / 2, -1}, {0, 1 / 2}}, 1 / 2]Or compute the matrix UnitStep function using MatrixFunction:
MatrixFunction[UnitStep[#, 1 / 2]&, {{1 / 2, -1}, {0, 1 / 2}}]//FullSimplifyCompute average-case statistical intervals using Around:
UnitStep[ Around[1 / 2, 0.01], 1 / 2]Specific Values (4)
UnitStep[0]UnitStep[Infinity]Evaluate for symbolic parameters:
Assuming[a > 0, Refine[UnitStep[a, a, a, a]]]Assuming[a < 0, Refine[UnitStep[a, a, a, a]]]Assuming[a < 0 && b > 0, Refine[UnitStep[b, b, a]]]Find a value of x for which the UnitStep[x]=1:
xval = x /. FindRoot[UnitStep[x] == 1, {x, 1}]Plot[UnitStep[x], {x, -2, 2}, Epilog -> Style[Point[{xval, UnitStep[xval]}], PointSize[Large], Red], ExclusionsStyle -> Dotted]Visualization (4)
Plot the UnitStep function:
Plot[UnitStep[x], {x, -5, 5}, PlotStyle -> Thick, ExclusionsStyle -> Directive[Thick, Red]]Visualize shifted UnitStep functions:
Plot[{UnitStep[x + 1], UnitStep[x], UnitStep[x - 1]}, {x, -1.5, 1.5}, PlotLegends -> "Expressions", Exclusions -> None]Visualize the composition of UnitStep with a periodic function:
Plot[UnitStep[Sin[x]], {x, -2Pi, 2Pi}]Plot UnitStep in three dimensions:
Plot3D[UnitStep[x, y], {x, -4, 4}, {y, -4, 4}, ColorFunction -> "SouthwestColors"]Function Properties (10)
Function domain of UnitStep:
FunctionDomain[UnitStep[x], x]It is restricted to real inputs:
FunctionDomain[UnitStep[x], x, Complexes]Function range of UnitStep:
FunctionRange[UnitStep[x], x, y]UnitStep has a jump discontinuity at the point
:
{Underscript[, x -> 0^ - ]UnitStep[x], Underscript[, x -> 0^ + ]UnitStep[x]}UnitStep is not an analytic function:
FunctionAnalytic[UnitStep[x], x]It has both singularities and discontinuities:
FunctionSingularities[UnitStep[x], x]FunctionDiscontinuities[UnitStep[x], x]UnitStep is nondecreasing:
FunctionMonotonicity[UnitStep[x], x]UnitStep is not injective:
FunctionInjective[UnitStep[x], x]Plot[{UnitStep[x], 1}, {x, -7, 7}, PlotStyle -> {Thick}]UnitStep is not surjective:
FunctionSurjective[UnitStep[x], x]Plot[{UnitStep[x], -1}, {x, -5, 5}, PlotStyle -> {Thick}]UnitStep is non-negative:
FunctionSign[UnitStep[x], x]UnitStep is neither convex nor concave:
FunctionConvexity[UnitStep[x], x]TraditionalForm formatting:
UnitStep[x]//TraditionalFormDifferentiation and Integration (6)
First derivative with respect to x:
D[UnitStep[x], x]All higher-order derivatives the same:
UnitStep'[x] === UnitStep''[x]First derivative with respect to z:
D[UnitStep[x, y, z], z]Compute the indefinite integral using Integrate:
Integrate[UnitStep[x], x]Verify the anti-derivative away from the singular point:
FullSimplify[D[%, x], x ≠ 0]Integrate[UnitStep[x], {x, 0, 10}]Integral over an infinite domain:
Integrate[Exp[-x]UnitStep[x], {x, -∞, ∞}]Integral Transforms (4)
FourierTransform[UnitStep[x], x, t]FourierSeries[UnitStep[x], x, 4]// FullSimplifyPlot[{%, UnitStep[x]}, {x, -2, 2}, Exclusions -> None]Find the LaplaceTransform of UnitStep:
LaplaceTransform[UnitStep[x], x, t]//QuietPlot[%, {t, -5, 5}]The convolution of UnitStep with itself:
Convolve[UnitStep[x], UnitStep[x], x, y]Plot[%, {y, -1.2, 1.2}]Applications (8)
Plot[UnitStep[Sin[Pi x]], {x, 0, 10}, Exclusions -> None, PlotStyle -> Thick]Compute a step response for a continuous-time system:
DSolve[{y''[t] + y'[t] + y[t] == UnitStep[t], y[0] == y'[0] == 0}, y, t]Plot[Evaluate[y[t] /. %], {t, 0, 10}]InverseLaplaceTransform[1 / (s ^ 2 + s + 1)LaplaceTransform[UnitStep[t], t, s], s, t]Plot[%, {t, 0, 10}]Compute a step response for a discrete-time system:
RSolve[{y[k + 2] - 8 / 5y[k + 1] + 16 / 25y[k] == UnitStep[k], y[0] == y[1] == 0}, y, k]ListPlot[Table[y[k] /. First[%], {k, 0, 50}], Filling -> Axis, PlotRange -> All]InverseZTransform[(1 / (z ^ 2 - 8 / 5z + 16 / 25))ZTransform[UnitStep[k], k, z], z, k]ListPlot[Table[%, {k, 0, 50}], Filling -> Axis, PlotRange -> All]Solve the time‐independent Schrödinger equation with piecewise analytic potential:
DSolve[{-ψ''[z] + UnitStep[z]ψ[z] == ε ψ[z], ψ[0] == ψ0, ψ'[0] == ψ1}, ψ[z], z]This gives the probability of the random variable being in the interval
:
Integrate[PDF[NormalDistribution[μ, σ], x]UnitStep[x - X]UnitStep[Y - x], {x, -∞, ∞}, Assumptions -> μ∈Reals && σ > 0 && {X, Y}∈Reals]Here is the resulting probability plotted:
Plot3D[% /. {μ -> 0, σ -> 1}, {X, -3, 3}, {Y, -3, 3}]Construct the Walsh function:
Walsh[{n_, k_}, y_] := Module[{li = Split[Extract[Nest[Sequence@@@{Join[Riffle[#, #]& /@ #], Join[Riffle[#, -#]& /@ Reverse[#]]}&, {{1}}, n], {k}]]}, -1 - 2Total[MapIndexed[(-1) ^ #2 UnitStep[Mod[y, 2 ^ n] - #1]&, Most[FoldList[Plus, 0, Length /@ li]]], Infinity]]Table[Plot[Walsh[{2, k}, x], {x, 0, 4}], {k, 4}]Define a Bose–Einstein and a Maxwell–Boltzmann distribution function with UnitStep and Exp:
be[ℰ_, μ_, kBT_] := UnitStep[ℰ - μ](1/E^(ℰ - μ/kBT) - 1)mb[ℰ_, μ_, kBT_] := E^-(ℰ - μ/kBT)Plot[{be[ℰ, 1, 1 / 10], mb[ℰ, 1, 1 / 10]}, {ℰ, 0.3, 2}]Find the representation of a mathematical expression with UnitStep in terms of FoxH:
FoxHReduce[E^-x UnitStep[1 + Abs[x]], x]Properties & Relations (5)
UnitStep accepts any number of arguments, including zero:
UnitStep[]The derivative of UnitStep is a piecewise function:
D[UnitStep[x], x]The derivative of HeavisideTheta is a distribution:
D[HeavisideTheta[x], x]Expand into UnitStep of linear factors:
UnitStep[x ^ 15 - 1]//FunctionExpandUnitStep[x ^ 2 - 11x + 1]//FunctionExpandConvert into Piecewise:
PiecewiseExpand[UnitStep[x]UnitStep[1 - x]]PiecewiseExpand[Exp[x UnitStep[x]UnitStep[1 - UnitStep[x]]]]Integrate over finite and infinite domains:
Integrate[UnitStep[x - a] Sinc[x], {x, -Infinity, Infinity}]Integrate[UnitStep[x Cos[x]], {x, -5, 5}]Possible Issues (3)
Symbolic preprocessing of functions containing UnitStep can be time‐consuming:
NIntegrate[UnitStep[x Sin[x] + Exp[x]], {x, 0, 20}]//TimingNIntegrate[UnitStep[x Sin[x] + Exp[x]], {x, 0, 20}, Method -> {Automatic, "SymbolicProcessing" -> 0}]// TimingLimit does not give UnitStep as a limit of smooth functions:
Assuming[x∈Reals, (1 /π)Limit[ArcTan[(x/ε)], ε -> +0, Direction -> -1] + (1/2)]FullSimplify[%, x∈Reals]Differentiating Abs does not yield UnitStep:
D[Abs[t], t]Use RealAbs to get a derivative of absolute value on the reals:
D[RealAbs[t], t]But for the origin, where the derivative does not exist, this is equivalent to an expression in UnitStep:
FullSimplify[% == UnitStep[t] - UnitStep[-t]]See Also
UnitBox RealSign Positive HeavisideTheta DiscreteDelta KroneckerDelta Unitize Boole Piecewise LogisticSigmoid Ramp
Function Repository: SmoothStep SmootherStep RationalSmoothStep
Related Guides
Related Links
History
Introduced in 1999 (4.0) | Updated in 2007 (6.0)
Text
Wolfram Research (1999), UnitStep, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitStep.html (updated 2007).
CMS
Wolfram Language. 1999. "UnitStep." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/UnitStep.html.
APA
Wolfram Language. (1999). UnitStep. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnitStep.html
BibTeX
@misc{reference.wolfram_2026_unitstep, author="Wolfram Research", title="{UnitStep}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/UnitStep.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_unitstep, organization={Wolfram Research}, title={UnitStep}, year={2007}, url={https://reference.wolfram.com/language/ref/UnitStep.html}, note=[Accessed: 13-June-2026]}