heaviside -- the Heaviside
step function
Introductionheaviside(x) represents the Heaviside step
function.
Call(s)heaviside(x)
Parametersx |
- | an arithmetical expression |
Returnsan arithmetical expression.
x
Related
Functions
DetailsDOM_COMPLEX, then undefined is returned. For all
other arguments, an unevaluated function call is returned.heaviside does not have a pre-defined value at the
origin. Use
sysassign(heaviside(0),myValue)
and
sysassign(heaviside(float(0)),myFloatValue)
to assign your favorite values.
heaviside is the delta distribution
dirac.
Example
1heaviside returns 1 or
0 for arguments representing positive or negative real
numbers, respectively:
>> heaviside(-3), heaviside(-sqrt(3)), heaviside(-2.1), heaviside(PI - E), heaviside(sqrt(3))
0, 0, 0, 1, 1
Arguments of domain type DOM_COMPLEX yield undefined:
>> heaviside(1 + I), heaviside(2/3 + 7*I), heaviside(0.1*I)
undefined, undefined, undefined
An unevaluated call is returned for other arguments:
>> heaviside(0), heaviside(x), heaviside(ln(-5)), heaviside(x + I)
heaviside(0), heaviside(x), heaviside(I PI + ln(5)),
heaviside(x + I)
Natural values at the origin are 0, 1/2, or 1:
>> prev_protection:= unprotect(heaviside): heaviside(0) := 1/2: heaviside(0)
1/2
>> delete heaviside(0): protect(heaviside, prev_protection): delete prev_protection:
>> heaviside(0)
heaviside(0)
Example
2heaviside reacts to assumptions set by
assume:
>> assume(x > 0): heaviside(x)
1
>> unassume(x):
Example
3The derivative of heaviside is the delta
distribution dirac:
>> diff(heaviside(x - 4), x)
dirac(x - 4)
The integrator int handles heaviside:
>> int(exp(-x)*heaviside(x), x = -infinity..infinity)
1
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)
16.2
>> numeric::int(exp(-x), x = -3..-2^(1/2)) + numeric::int(exp(-x), x = 2^(1/2)..10)
16.2
>> delete DIGITS:
assume are now
taken into account.