Method on @sym: heaviside (x)
Method on @sym: heaviside (x, zero_value)

Symbolic Heaviside step function.

Example:

syms x
y = heaviside (x)
  ⇒ y = (sym) θ(x)

There are various conventions for ’heaviside(sym(0))’; this function returns the midpoint by default on recent enough SymPy:

heaviside(sym(0))
  ⇒ (sym) 1/2

The optional second argument overrides the default. For example to make the function right-continuous,

heaviside(0, sym(1))
  ⇒ (sym) 1

or left-continuous.

heaviside(0, sym(0))
  ⇒ (sym) 0

If passed a matrix, the heaviside function is computed for each element.

heaviside([sym(-1) sym(0) sym(1) sym(x)])
  ⇒ (sym) [0  1/2  1  θ(x)]  (1×4 matrix)

See also: heaviside, @sym/dirac.

Package: symbolic