heaviside
The Heaviside step function
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
heaviside(x
)
heaviside(x)
represents the Heaviside step
function.
If the argument represents a positive real number, then 1 is
returned. If the argument represents a negative real number, then 0 is
returned. If the argument is zero, is
returned. If the argument is a complex number of domain type DOM_COMPLEX
,
then undefined
is
returned. For all other arguments, an unevaluated function call is
returned.
The derivative of heaviside
is the delta
distribution dirac
.
To change the value of heaviside
at the
origin, use Pref::heavisideAtOrigin
.
See Example 4. Common choices for
this value are 0
, 1
, and 1/2
.
heaviside
returns 1 or 0 for
arguments representing positive or negative real numbers, respectively:
heaviside(3), heaviside(sqrt(3)), heaviside(2.1), heaviside(PI  exp(1)), heaviside(sqrt(3))
heaviside
returns if
the argument is zero:
heaviside(0), heaviside(0.0)
Arguments of domain type DOM_COMPLEX
yield undefined
:
heaviside(1 + I), heaviside(2/3 + 7*I), heaviside(0.1*I)
An unevaluated call is returned for other arguments:
heaviside(x), heaviside(ln(5)), heaviside(x + I)
The derivative of heaviside
is the delta
distribution dirac
:
diff(heaviside(x  4), x)
The integrator int
handles heaviside
:
int(exp(x)*heaviside(x), x = infinity..infinity)
We do not recommend to use heaviside
in numerical
integration. It is much more efficient to split the quadrature into
pieces, each of which having a smooth integrand:
DIGITS := 3: numeric::int(exp(x)*heaviside(x^2  2), x=3..10)
numeric::int(exp(x), x = 3..2^(1/2)) + numeric::int(exp(x), x = 2^(1/2)..10)
delete DIGITS:
heaviside
assumes that the value of the Heaviside
function at the origin is 1/2
.
heaviside(0)
Other common values for the Heaviside function at the origin
are 0
and 1
. To change the value
of heaviside
at the origin, use Pref::heavisideAtOrigin
.
Store the previous value, so that you can restore it later.
oldval := Pref::heavisideAtOrigin(1):
Check the new value of heaviside
at 0
.
heaviside(0)
Restore the previous value of heavisideAtOrigin
using oldval
.
Pref::heavisideAtOrigin(oldval):
Also, you can restore the default value of heavisideAtOrigin
by
specifying the input as NIL
.
Pref::heavisideAtOrigin(NIL):

Arithmetical expression.
x