# 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\left(t\right)\right)$ satisfies the following condition: If T* is the point in time when is $f\left(q\left(t\right)\right)$ maximum, then $f\left(q\left(T*\right)\right)\le f\left(q\left(t\right)\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:

(1)
The parameter $a>0$ is used to control the accuracy of the calculations.
Note: $\text{M}\text{a}\text{x}\left(\text{x}\right)=\underset{⍺\to \infty }{\mathrm{lim}}Maxval\left(x\right)$ .

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))