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?


  • 6
    $\begingroup$ As a rough rule of thumb: use HeavisideTheta[] for symbolic calculations, and UnitStep[] for numerical calculations. $\endgroup$ – J. M. will be back soon Sep 20 '17 at 0:20
  • $\begingroup$ Thanks @J.M. I'll keep that in mind. Kudos. $\endgroup$ – user51904 Sep 20 '17 at 0:22
  • 3
    $\begingroup$ 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. $\endgroup$ – aardvark2012 Sep 20 '17 at 11:25
  • 1
    $\begingroup$ That's an interesting consideration @aardvark2012, thanks for the addition. $\endgroup$ – user51904 Sep 28 '17 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy