represents the Heaviside theta function
, equal to 0 for
and 1 for
.
HeavisideTheta[x1,x2,…]
represents the multidimensional Heaviside theta function, which is 1 only if all of the xi are positive.
HeavisideTheta
represents the Heaviside theta function
, equal to 0 for
and 1 for
.
HeavisideTheta[x1,x2,…]
represents the multidimensional Heaviside theta function, which is 1 only if all of the xi are positive.
Details
- HeavisideTheta[x] returns 0 or 1 for all real numeric x other than 0.
- HeavisideTheta can be used in integrals, integral transforms, and differential equations.
- HeavisideTheta has attribute Orderless.
- For exact numeric quantities, HeavisideTheta internally uses numerical approximations to establish its result. This process can be affected by the setting of the global variable $MaxExtraPrecision.
Examples
open all close allBasic Examples (4)
HeavisideTheta[.8]Plot[HeavisideTheta[x], {x, -2, 2}]Plot3D[HeavisideTheta[x, y], {x, -1, 1}, {y, -1, 1}]Differentiate to obtain DiracDelta:
D[HeavisideTheta[x], x]Scope (37)
Numerical Evaluation (5)
HeavisideTheta[-1]UnitStep[1 / 2]UnitStep[1, Pi, 5.3]HeavisideTheta always returns an exact result:
HeavisideTheta[{-1.6, 3.200000000000}]Evaluate efficiently at high precision:
HeavisideTheta[4 / 7`100]//TimingHeavisideTheta[17 / 91`100000000];//TimingCompute average-case statistical intervals using Around:
HeavisideTheta[ Around[1 / 2, 0.01]]Compute the elementwise values of an array:
HeavisideTheta[{{-1, -1 / 2}, {-1 / 2, 1 / 2}}]Or compute the matrix HeavisideTheta function using MatrixFunction:
MatrixFunction[HeavisideTheta, {{-1, -1 / 2}, {-1 / 2, 1 / 2}}]Specific Values (4)
As a distribution, HeavisideTheta does not have a specific value at 0:
HeavisideTheta[0]HeavisideTheta[Infinity]Evaluate for symbolic parameters:
Assuming[a > 0, Refine[HeavisideTheta[a, a, a, a]]]Assuming[a < 0, Refine[HeavisideTheta[a, a, a, a]]]Assuming[a < 0 && b > 0, Refine[HeavisideTheta[b, b, a]]]Find a value of x for which the HeavisideTheta[x]=1:
xval = x /. FindRoot[HeavisideTheta[x] == 1, {x, 1}]Plot[HeavisideTheta[x], {x, -2, 2}, Epilog -> Style[Point[{xval, HeavisideTheta[xval]}], PointSize[Large], Red], ExclusionsStyle -> Dotted]Visualization (4)
Plot the HeavisideTheta function:
Plot[HeavisideTheta[x], {x, -2, 2}, PlotStyle -> Thick, ExclusionsStyle -> Directive[Thick, Red]]Visualize shifted HeavisideTheta functions:
Plot[{HeavisideTheta[x + 1], HeavisideTheta[x], HeavisideTheta[x - 1]}, {x, -1.5, 1.5}, PlotLegends -> "Expressions", Exclusions -> None]Visualize the composition of HeavisideTheta with a periodic function:
Plot[HeavisideTheta[Sin[x]], {x, -2Pi, 2Pi}]Plot HeavisideTheta in three dimensions:
Plot3D[HeavisideTheta[x, y], {x, -1.5, 1.5}, {y, -1.5, 1.5}, ColorFunction -> "SouthwestColors"]Function Properties (9)
Function domain of HeavisideTheta:
FunctionDomain[HeavisideTheta[x], x]It is restricted to real inputs:
FunctionDomain[HeavisideTheta[x], x, Complexes]Function range of HeavisideTheta:
FunctionRange[HeavisideTheta[x], x, y]HeavisideTheta has a jump discontinuity at the point
:
{Underscript[, x -> 0^ - ]HeavisideTheta[x], Underscript[, x -> 0^ + ]HeavisideTheta[x]}HeavisideTheta is not an analytic function:
FunctionAnalytic[HeavisideTheta[x], x]It has both singularities and discontinuities:
FunctionSingularities[HeavisideTheta[x], x]FunctionDiscontinuities[HeavisideTheta[x], x]HeavisideTheta is not injective:
FunctionInjective[HeavisideTheta[x], x]Plot[{HeavisideTheta[x], 1}, {x, -1, 1}, PlotStyle -> {Thick}]HeavisideTheta is not surjective:
FunctionSurjective[HeavisideTheta[x], x]Plot[{HeavisideTheta[x], -1}, {x, -1, 1}, PlotStyle -> {Thick}]HeavisideTheta is non-negative on its domain:
FunctionSign[{HeavisideTheta[x], x ≠ 0}, x]HeavisideTheta is neither convex nor concave:
FunctionConvexity[{HeavisideTheta[x], x ≠ 0}, x]TraditionalForm typesetting:
HeavisideTheta[x]//TraditionalFormDifferentiation (4)
Differentiate the univariate HeavisideTheta:
D[HeavisideTheta[x], x]Differentiate the multivariate HeavisideTheta:
D[HeavisideTheta[x, y, z], z]Differentiate a composition involving HeavisideTheta:
D[HeavisideTheta[x, f[y], z], y]Generate HeavisideTheta from an integral:
Integrate[DiracDelta[x - a], {x, -Infinity, b}]Verify the integral via differentiation:
D[%, b] /. b -> xIntegration (6)
Integrate[HeavisideTheta[x], x]Integrate over finite domains:
Integrate[HeavisideTheta[x - a], {x, 0, y}, Assumptions -> y > 0]Integrate[HeavisideTheta[x Cos[x]], {x, -5, 5}]Integrate over infinite domains:
Integrate[HeavisideTheta[x - a] Exp[-x ^ 2], {x, -Infinity, Infinity}]Integrate the multivariate HeavisideTheta:
Integrate[HeavisideTheta[x, y], {x, 0, a}, {y, 0, b}, Assumptions -> (a | b)∈Reals]NIntegrate[HeavisideTheta[x Cos[x]] Sin[x], {x, 0, Pi / 2, 3Pi / 2, 5}]Integrate expressions containing symbolic derivatives of HeavisideTheta:
Integrate[HeavisideTheta'''[x - a] f[x], {x, -Infinity, Infinity}, Assumptions -> a∈Reals]Integral Transforms (5)
FourierTransform of HeavisideTheta:
FourierTransform[HeavisideTheta[x], x, t]FourierSeries[HeavisideTheta[x], x, 4]// FullSimplifyPlot[{%, HeavisideTheta[x]}, {x, -2, 2}, Exclusions -> None]Find the LaplaceTransform of HeavisideTheta:
LaplaceTransform[HeavisideTheta[x], x, t]//QuietPlot[%, {t, -5, 5}]The convolution of HeavisideTheta with itself:
Convolve[HeavisideTheta[x], HeavisideTheta[x], x, y]Plot[%, {y, -1.2, 1.2}]The convolution of
with
is equal to
:s
Convolve[HeavisideTheta[x], DiracDelta[x + (1/2)] - DiracDelta[x - (1/2)], x, y]FullSimplify[% == HeavisidePi[y]]Applications (7)
Solve the time‐independent Schrödinger equation with piecewise analytic potential:
DSolve[{-ψ''[z] + HeavisideTheta[z]ψ[z] == ε ψ[z], ψ[0] == ψ0, ψ'[0] == ψ1}, ψ[z], z]Use DSolve with DiracDelta source term to find Green's function:
gf[z_] = w[z] /. DSolve[{w''[z] + k^2 w[z] == DiracDelta[z], w[0] == 0, w'[0] == 1}, w[z], z][[1]] /. {HeavisideTheta[0] -> 1}Solve the inhomogeneous ODE through convolution with Green's function:
Integrate[gf[z - ζ ] Exp[-ζ ], {ζ, 0, z}, Assumptions -> z > 0]Compare with the direct result from DSolve:
gf[z_] = w[z] /. First[DSolve[{w''[z] + k^2 w[z] == Exp[-z], w[0] == 0, w'[0] == 0}, w[z], z]]//SimplifyModel a uniform probability distribution:
p[x_] := HeavisideTheta[x]HeavisideTheta[1 - x]Plot[p[x], {x, -1, 2}]Calculate the probability distribution for the sum of two uniformly distributed variables:
Integrate[DiracDelta[z - (x + y)]p[x]p[y], {x, -∞, ∞}, {y, -∞, ∞}, Assumptions -> z∈Reals]Plot the distributions for the sum:
Plot[%, {z, -1, 3}]Fundamental solution (Green's function) of the 1D wave equation:
𝒢[x_, t_] := HeavisideTheta[t - Abs[x]]Solution for a given source term:
uG[f_, {x_, t_}] := Integrate[𝒢[t - τ, x - ξ]f[τ, ξ], {τ, 0, t}, {ξ, -Infinity, Infinity}, Assumptions -> x∈Reals && t > 0 && τ > 0]solG = uG[HeavisideTheta[1 - #2] HeavisideTheta[#2 + 1]&, {x, t}]Plot3D[solG, {x, -4Pi, 4Pi}, {t, 0, 4Pi}, PlotPoints -> 30]Fundamental solution of the Klein–Gordon
operator:
𝒟[t_, x_List] := (1/2π)HeavisideTheta[t]DiracDelta[t^2 - x.x] - (m/4π)HeavisideTheta[t - Sqrt[x.x]](BesselJ[1, mSqrt[t^2 - x.x]]/Sqrt[t^2 - x.x])Visualize the fundamental solution (it is nonvanishing only in the forward light cone):
Plot3D[-𝒟[t, {0, 0, z}] /. m -> 1, {z, -3, 3.02}, {t, -3, 3.01}, PlotStyle -> Opacity[0.3]]A cusp‐containing peakon solution of the Camassa–Holm equation:
chEq[x_, t_] := (Subscript[∂, t]# - Subscript[∂, x, x, t]# + 3 # Subscript[∂, x]# - 2 Subscript[∂, x]# Subscript[∂, x, x]# - # Subscript[∂, x, x, x]#)&u[x_, t_] := Exp[-(x - t)(HeavisideTheta[x - t] - HeavisideTheta[t - x])]chEq[x, t]@ u[x, t]//FullSimplify[#, x > 0 && t > x]&Plot3D[u[x, t], {x, -3, 3}, {t, 0, 3}]Differentiate and integrate a piecewise-defined function in a lossless manner:
pwF[x_] := 2HeavisideTheta[x - 1] - 2HeavisideTheta[-x - 1]Plot[pwF[x], {x, -3, 3}]Differentiating and integrating recovers the original function:
D[pwF[x], x]Integrate[%, x]Using Piecewise does not recover the original function:
pwF2[x_] = PiecewiseExpand[pwF[x] /. HeavisideTheta -> UnitStep]D[pwF2[x], x]Integrate[%, x]Properties & Relations (6)
The derivative of HeavisideTheta is a distribution:
D[HeavisideTheta[x], x]The derivative of UnitStep is a piecewise function:
D[UnitStep[x], x]Expand HeavisideTheta into HeavisideTheta with simpler arguments:
HeavisideTheta[x ^ 5 - x + 4]//FunctionExpandSimplify expressions containing HeavisideTheta:
Simplify[{x HeavisideTheta[x], HeavisideTheta[2x + 2]}, x > 3]Integrate[HeavisideTheta[Sin[x]], {x, 0, 10}]Integrate[HeavisideTheta[1 - x^2 - y], {x, -2, 2}, {y, -2, 2}]FourierTransform[HeavisideTheta[y], y, x]LaplaceTransform[HeavisideTheta[x], x, s]Possible Issues (10)
HeavisideTheta stays unevaluated for vanishing argument:
HeavisideTheta[0]PiecewiseExpand does not operate on HeavisideTheta because it is a distribution and not a piecewise‐defined function:
PiecewiseExpand[HeavisideTheta[x]]The precision of the output does not track the precision of the input:
HeavisideTheta[1.6]HeavisideTheta[1.60000000000000000000000]HeavisideTheta can stay unevaluated for numeric arguments:
HeavisideTheta[(1 + E) ^ 2 - 1 - 2 E - E ^ 2 + Exp[-Exp[E] ^ 2]]Simplify[%]Machine‐precision numericalization of HeavisideTheta can give wrong results:
HeavisideTheta[(1 + E) ^ 2 - 1 - 2 E - E ^ 2 + Exp[-Exp[E] ^ 2]]N[%]Use arbitrary‐precision arithmetic to obtain the correct result:
N[%%, 1000]A larger setting for $MaxExtraPrecision will not avoid the N::meprec message because the result is exact:
Block[{$MaxExtraPrecision = 1000}, N[%%%, 20]]The functions UnitStep and HeavisideTheta are not mathematically equivalent:
{HeavisideTheta[x], UnitStep[x]}Integrate[D[%, x], x]Products of distributions with coincident singular support cannot be defined (no Colombeau algebra interpretation):
Integrate[HeavisideTheta[x] DiracDelta[x], {x, -1, 1}]HeavisideTheta cannot be uniquely defined with complex arguments (no Sato hyperfunction interpretation):
HeavisideTheta[1 + 2I]Numerical routines can have problems with discontinuous functions:
FindRoot[HeavisideTheta[x], {x, 1, 2}]NIntegrate[HeavisideTheta[x], {x, -1, 2}]Limit does not give HeavisideTheta as a limit of smooth functions:
Assuming[x∈Reals, (1 /π)Limit[ArcTan[(x/ε)], ε -> +0, Direction -> -1] + (1/2)]{FullSimplify[%, x∈Reals && x < 0], FullSimplify[%, x∈Reals && x > 0]}Neat Examples (1)
Form repeated convolution integrals starting with a product:
conv[f_, g_, x_] := Block[{y}, Integrate[(f /. x -> x - y)(g /. x -> y), {y, -∞, ∞}, Assumptions -> x∈Reals]]NestList[conv[#, HeavisideTheta[x]HeavisideTheta[1 - x], x]&, HeavisideTheta[x]HeavisideTheta[1 - x], 2]//ShortPlot[Evaluate[%], {x, -3, 3}]Related Guides
Related Links
History
Text
Wolfram Research (2007), HeavisideTheta, Wolfram Language function, https://reference.wolfram.com/language/ref/HeavisideTheta.html.
CMS
Wolfram Language. 2007. "HeavisideTheta." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HeavisideTheta.html.
APA
Wolfram Language. (2007). HeavisideTheta. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HeavisideTheta.html
BibTeX
@misc{reference.wolfram_2026_heavisidetheta, author="Wolfram Research", title="{HeavisideTheta}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/HeavisideTheta.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_heavisidetheta, organization={Wolfram Research}, title={HeavisideTheta}, year={2007}, url={https://reference.wolfram.com/language/ref/HeavisideTheta.html}, note=[Accessed: 12-June-2026]}