# MaxVal

Computes the maximum value of a user specified function, which could be a MotionSolve expression or a user subroutine.

The maximum value of a signal $f\left(q(t)\right)$ satisfies the following condition: If T* is the point in time when is $f\left(q(t)\right)$ maximum, then $f\left(q(T*)\right)\le f\left(q(t)\right)$ when t ≠T*. If the expression has no maximum value, the initial value will be returned as the maximum value.

A smooth approximation to the MAX function is implemented in MotionSolve, so that its sensitivities are analytically computed. The smooth approximation, known as the alpha soft approximation, is:

The default value of $a$ is +10 and it should work for most of use cases.

## Example

Assume that you are designing a suspension system and there is an upper limit on the maximum acceleration of the chassis.

Here is a code snippet that shows how the response should be defined with MaxVal:

```
>>> # Define the maximum of acceleration
>>> maxAcc = MaxVal(function = "ACCZ({})".format(p.cm.id))
```