### 5.17.3 Maximum and minimum of an expression: fMax fMin

fMax and fMin take one or two arguments : an expression of a variable and the name of this variable (by default x).
fMax returns the abscissa of a maximum of the expression.
fMin returns the abscissa of a minimum of the expression.
Input :

fMax(sin(x),x)

Or :

fMax(sin(x))

Or :

fMax(sin(y),y)

Output :

pi/2

Input :

fMin(sin(x),x)

Or :

fMin(sin(x))

Or :

fMin(sin(y),y)

Output :

-pi/2

Input :

fMin(sin(x)`^`2,x)

Output :

0

fMax and fMin can also compute the maximum resp. minimum of a nonlinear multivariate expression subject to a set of nonlinear equality and/or inequality constraints. Both functions in such cases take four to six arguments:

- objective function (an expression)
- list of constraints (equalities and inequalities)
- list of problem variables
- initial guess (must be a list of nonzero reals representing a feasible point)
- precision (optional), if not given the default epsilon value is used
- maximum number of iterations (optional)

The objective function does not need to be differentiable. Both fMin and fMax return the optimal solution as a vector. Note that the actual optimal value of the objective is not returned.

Although the initial point is required to be feasible, the algorithm will sometimes succeed even if it is infeasible. Note that the initial value of a variable must not be zero.

For example, input :

fMin((x-5)`^`2+y`^`2-25,[y>=x`^`2],[x,y],[1,1])

Output :

[1.2347728624961,1.5246640219568]

Input :

fMax((x-2)`^`2+(y-1)`^`2,[-.25x`^`2-y`^`2+1>=0,x-2y+1=0], [x,y],[.5,.75])

Output :

[-1.82287565553,-0.411437827766]