# How to get numerical results from HeavisideTheta?

I have defined a table tab = {7.52521, 17.0083, 22.5678, 11.8707, 8.27799} and a function F[x_] := tab[]*HeavisideTheta[x] + (tab[] - tab[])* HeavisideTheta[x - 20] + (tab[] - tab[])* HeavisideTheta[x - 40] + (tab[] - tab[])* HeavisideTheta[x - 60] + (tab[] - tab[])* HeavisideTheta[x - 80].

If I now try to look at the value at 20:

In:= F

Out= 7.52521 + 9.48311 HeavisideTheta


But the problem is that I need this result to be numerical, because I want to do some more calculations with it. And it is not numerical, because it is at the border of two Heaviside functions. How do I change my definition of function F in order to get pass that problem? Or maybe is there a different way to get F? It is not very important value of which Heaviside function it takes (to the left or to the right of 20).

• Try replacing HeavisideTheta[] with UnitStep[] for numerical evaluations. – J. M.'s torpor Jul 20 '15 at 13:07

## 1 Answer

You can do the whole thing numerically by replacing the Heaviside function with a numerical version. For example:

nHeaviside[x_] := If[x < 0, 0, 1]


will work. You can choose which value it will assume at zero by changing the condition to x <= 0. Alterantively, the function Unitstep does a similar task:

nHeaviside2[x_] := UnitStep[x]


(Guess who it is suggested this in a comment.)