## `heaviside` -- the Heaviside step function

#### Introduction

`heaviside``(x)` represents the Heaviside step function.

#### Call(s)

`heaviside(x)`

#### Parameters

`x` | - | an arithmetical expression

#### Returns

an arithmetical expression.

### Overloadable:

`x`

#### Related Functions

`dirac`

#### Details

- 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 a complex number of domain type `DOM_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.

- The derivative of `heaviside` is the delta distribution `dirac`.

#### Example 1

`heaviside` 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 2

`heaviside` reacts to assumptions set by `assume`:

    >> assume(x > 0): heaviside(x)

                                         1

    >> unassume(x):

#### Example 3

The 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:

#### Changes

- Properties of identifiers set via `assume` are now taken into account.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000