# Difference between UnitStep and HeavisideTheta?

In Mathematica, UnitStep[0] == 1 and HeavisideTheta[0] remains unevaluated. In addition, D[UnitStep[x], x] is 0 if x != 0 and Indeterminate if x == 0, whereas D[HeavisideTheta[x],x] = DiracDelta[x].

It seems to me that UnitStep is the idealization of a leading edge of a perfect pulse, whereas HeavisideTheta[x] is like an ideal Fourier Transform of the ideal UnitStep[x] function. Is this a good way to distinguish between the two, and are there any other significant programming or mathematical distinctions between the two functions?

Thanks.

• As a rough rule of thumb: use HeavisideTheta[] for symbolic calculations, and UnitStep[] for numerical calculations. Sep 20, 2017 at 0:20
• Thanks @J.M. I'll keep that in mind. Kudos.
– user51904
Sep 20, 2017 at 0:22
• Just to expand on @J.M.'s "UnitStep for numeric" comment. Doing list = RandomReal[1, 10^6]; AbsoluteTiming[UnitStep[list];] AbsoluteTiming[HeavisideTheta[list];]. UnitStep comes out as two orders of magnitude faster. Sep 20, 2017 at 11:25
• That's an interesting consideration @aardvark2012, thanks for the addition.
– user51904
Sep 28, 2017 at 22:56

## 1 Answer

HeavisideTheta is a distribution. Distributions are the kernels of linear maps by complete definite integrals over a domain for a special class of functions to complex numbers.

As such, Theta is the primitive of Delta in the following sense

Integrate[f[x] HeavisideTheta'[x],x\[Element] domain]  ==
-     Integrate[f'[x] HeavisideTheta[x],x\[Element] domain]  ==
-f[+boundary] + f[0]


This is valid only if f, f' etc go to zero sufficently fast so that integration by parts has boundary values zero. Products of Theta and other functions, that do not decay at inifinity on the real line, make no sense. Especially, the product of distributions make no sense in general.

UnitStep on the contrary is only a piecewise continuous point-to-point function with no regard to any type of function spaces with an integrability condition, that yields the existence of Fourier transforms back and forth.

• See, for example, Wiki for a more or less accurate proof. The integrals written down by you are not OK . Mar 25, 2023 at 18:32