({{, (RefLink[UnitStep, paclet:ref/UnitStep])[x]
represents the unit step function, equal to 0 for x<0 and 1 for x≥0. }, {, (RefLink[UnitStep, paclet:ref/UnitStep])[(Subscript[x, 1]),(Subscript[x, 2]),…]
represents the multidimensional unit step function which is 1 only if none of the (Subscript[x, i]) are negative. }})

OpenersNotesSection(Spacer1)Details

Some transformations are done automatically when (RefLink[UnitStep, paclet:ref/UnitStep]) appears in a product of terms.

(RefLink[UnitStep, paclet:ref/UnitStep]) provides a convenient way to represent piecewise continuous functions.

(RefLink[UnitStep, paclet:ref/UnitStep]) has attribute (RefLink[Orderless, paclet:ref/Orderless]).

For exact numeric quantities, (RefLink[UnitStep, paclet:ref/UnitStep]) internally uses numerical approximations to establish its result. This process can be affected by the setting of the global variable (RefLink[$MaxExtraPrecision, paclet:ref/$MaxExtraPrecision]).

(RefLink[UnitStep, paclet:ref/UnitStep])[] is 1.

OpenersPrimaryExamplesSection(Spacer1)Examples  (32)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Evaluate numerically:

UnitStep[1]

Plot[UnitStep[x],{x,-3,3},PlotStyle->Thick]

Plot3D[UnitStep[x,y],{x,-3,3},{y,-3,3},Mesh->5]

Use (RefLink[UnitStep, paclet:ref/UnitStep]) to construct piecewise functions:

PiecewiseExpand[x^2+(x-x^2) UnitStep[x]]

OpenersExampleSection1(Spacer1)Scope  (16)

OpenersExampleSubsection0(Spacer1)Numerical Evaluation  (3)

Evaluate numerically:

UnitStep[57]

UnitStep[-.8]

The precision of the output does not track the precision of the input:

UnitStep[{1.6,1.6000000000000000000000000}]

Evaluate efficiently at high precision:

UnitStep[1/7`100]//Timing

UnitStep[5/9`100000000];//Timing

OpenersExampleSubsection1(Spacer1)Specific Values   (4)

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]]]

Value at zero:

UnitStep[0]

Value at infinity:

UnitStep[Infinity]

(RefLink[UnitStep, paclet:ref/UnitStep]) can deal with real-valued intervals:

UnitStep[Interval[{-1, 2}]]

OpenersExampleSubsection2(Spacer1)Visualization  (2)

Plot the (RefLink[UnitStep, paclet:ref/UnitStep]) function:

Plot[UnitStep[x],{x,-5,5}]

Plot (RefLink[UnitStep, paclet:ref/UnitStep]) in three dimensions:

Plot3D[UnitStep[x,y],{x,-4,4},{y,-4,4},ColorFunction->"BlueGreenYellow"]

OpenersExampleSubsection3(Spacer1)Function Properties  (4)

Function domain of (RefLink[UnitStep, paclet:ref/UnitStep]):

FunctionDomain[UnitStep[x],x]

Function range of (RefLink[UnitStep, paclet:ref/UnitStep]):

FunctionRange[UnitStep[x],x,y]

Function range for complex values:

FunctionRange[UnitStep[x],x,y,Complexes]

(RefLink[UnitStep, paclet:ref/UnitStep]) threads elementwise over lists:

UnitStep[{-1,0,1}]

(RefLink[TraditionalForm, paclet:ref/TraditionalForm]) formatting:

UnitStep[x]//TraditionalForm

OpenersExampleSubsection4(Spacer1)Differentiation and Integration  (3)

First derivative with respect to x:

D[UnitStep[x],x]

Compute the indefinite integral using (RefLink[Integrate, paclet:ref/Integrate]):

Integrate[UnitStep[x],x]

Verify the anti-derivative:

FullSimplify[D[%,x]]

Definite integral:

Integrate[UnitStep[x],{x,0,10}]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (1)

Multidimensional (RefLink[UnitStep, paclet:ref/UnitStep]):

UnitStep[1,2,3]

OpenersExampleSection3(Spacer1)Applications  (6)

Generate a square wave:

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}]

Using transform methods:

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]

Using transform methods:

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 [X,Y]:

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 (WebLink[Walsh function, http://mathworld.wolfram.com/WalshFunction.html]):

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}]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

Expand into (RefLink[UnitStep, paclet:ref/UnitStep]) of linear factors:

UnitStep[x^15-1]//FunctionExpand

UnitStep[x^2-11x+1]//FunctionExpand

Convert into (RefLink[Piecewise, paclet:ref/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}]

OpenersExampleSection5(Spacer1)Possible Issues  (3)

Symbolic preprocessing of functions containing (RefLink[UnitStep, paclet:ref/UnitStep]) can be time-consuming:

NIntegrate[UnitStep[x Sin[x]+Exp[x]],{x,0,20}]//Timing

NIntegrate[UnitStep[x Sin[x]+Exp[x]],{x,0,20},Method->{Automatic,"SymbolicProcessing"->0}]// Timing

(RefLink[Limit, paclet:ref/Limit]) does not give (RefLink[UnitStep, paclet:ref/UnitStep]) as a limit of smooth functions:

Assuming[x∈Reals,((1 )/π)Limit[ArcTan[(x/ε)],ε->+0,Direction->-1]+(1/2)]

FullSimplify[%, x∈Reals]

Differentiating (RefLink[Abs, paclet:ref/Abs]) does not yield (RefLink[UnitStep, paclet:ref/UnitStep]):

D[Abs[t], t]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[UnitBox, paclet:ref/UnitBox])  ▪  (RefLink[RealSign, paclet:ref/RealSign])  ▪  (RefLink[Positive, paclet:ref/Positive])  ▪  (RefLink[HeavisideTheta, paclet:ref/HeavisideTheta])  ▪  (RefLink[DiscreteDelta, paclet:ref/DiscreteDelta])  ▪  (RefLink[KroneckerDelta, paclet:ref/KroneckerDelta])  ▪  (RefLink[Unitize, paclet:ref/Unitize])  ▪  (RefLink[Boole, paclet:ref/Boole])  ▪  (RefLink[Piecewise, paclet:ref/Piecewise])  ▪  (RefLink[LogisticSigmoid, paclet:ref/LogisticSigmoid])  ▪  (RefLink[Ramp, paclet:ref/Ramp])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Numerical Functions, paclet:tutorial/NumericalFunctions])}, {▪(RefLinkPlain[Generalized Functions and Related Objects, paclet:tutorial/GeneralizedFunctionsAndRelatedObjects])}, {▪(RefLinkPlain[Piecewise Functions, paclet:tutorial/PiecewiseFunctions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Numerical Functions, paclet:guide/NumericalFunctions])}, {▪(RefLinkPlain[Conditionals, paclet:guide/Conditionals])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-MathWorld.png(Spacer1)MathWorld, http://mathworld.wolfram.com/HeavisideStepFunction.html])}, {DocumentationFooterIconsRelatedLinks-Functions.png(Spacer1)The Wolfram Functions Site}})}})