1
$\begingroup$

Well known and conventional defintion of Heaviside function is

 H(x) = 0, x < 0 H(x) = 1/2, x = 0 H(x) = 1, x > 0 

Mathematica uses instead unconventional "unit step" for its $HeavisideTheta[x] $ function

 S(x) = 0, x < 0 S(x) = 1, x > 0 

How to use in Mathematica proper Heaviside function with normal definiton $H(x)$?

$\endgroup$
1
  • 2
    $\begingroup$ Actually, UnitStep is a separate function, and the link you provided states that HeavisideTheta can be defined in different ways. $\endgroup$ Commented May 16, 2017 at 19:35

2 Answers 2

2
$\begingroup$
myHeaviside[x_] := Which[x < 0, 0, x == 0, 1/2, x > 0, 1] 

Note that the derivative, computed as a limit, is properly a representation of a DiracDelta function (though its integral and higher derivatives might not be appropriately represented):

Limit[(myHeaviside[x + ε] - myHeaviside[x])/ε, ε -> 0] 

$\begin{cases} \infty & x=0 \\ 0 & \text{True} \end{cases}$

$\endgroup$
1
  • 3
    $\begingroup$ What do you mean by ``the derivative is properly calculated''? The derivative should yield DiracDelta, I believe. $\endgroup$ Commented May 16, 2017 at 18:09
7
$\begingroup$

As the link in the question states, you can get the desired definition as follows:

heaviside[x_] := 1/2 (1 + Sign[x]) 

Here is a test:

heaviside /@ {-1, 0, 1} 

{0, 1/2, 1}

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.