### 16.3.3 Derivative-free constrained optimization

The fMin and fMax commands find local minima and maxima of a multivariate function, possibly subject to constraints (either equalities or inequalities), by using the COBYLA algorithm.

- fMax and fMin take four mandatory and two optional arguments:
  - expr, an expression with several variables, which does not need to be differentiable.
  - constr, a list of constraints (equalities and/or inequalities).
  - vars, a list of the variables.
  - init, an initial guess, which must be a list of nonzero reals representing a starting point (not necessarily feasible).
  - Optionally, ε, the precision. If this is not given, the default epsilon value is used (see Section 2.5.7, item 2.5.7).
  - Optionally, N, the maximum number of iterations.
- fMin(expr,constr,vars,init ⟨,ε,N ⟩) (and analogously with fMax) returns a point that minimizes (maximizes) expr subject to constr.
- If there are several feasible local minima/maxima, then the return value depends on the initial point.

#### Examples

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

| ⎡ ⎣ | −1.82287565553,−0.411437827766 | ⎤ ⎦

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

| ⎡ ⎣ | 1.2347728625,1.52466402196 | ⎤ ⎦