2
$\begingroup$

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

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

In[402]:= F[20]

Out[402]= 7.52521 + 9.48311 HeavisideTheta[0]

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[20]? It is not very important value of which Heaviside function it takes (to the left or to the right of 20).

$\endgroup$
1
  • 2
    $\begingroup$ Try replacing HeavisideTheta[] with UnitStep[] for numerical evaluations. $\endgroup$ Commented Jul 20, 2015 at 13:07

1 Answer 1

5
$\begingroup$

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.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.