Computes the maximum value of a signal during a simulation.

The maximum value of a signal f(q(t)) satisfies the following conditions:
  1. If T* is the point in time when f(q(t)) is a maximum, then f(q(T*)) < f(q(t)) when t ≠ T*
  2. f'(q(T*)) = 0
  3. f”(q(T*)) < 0

If the expression has no maximum value, the initial value will be returned as the maximum value.