Derivative-free constrained optimization

### 15.3.2 Derivative-free constrained optimization

The fMax and fMin commands find where maxima and minima occur by using the COBYLA algorithm. They can do this for expressions of one variable or for expressions of several variables subject to a set of constraints, either equalities or inequalities.

- To maximize/minimize univariate functions, fMax and fMin take two arguments:
  - expr, an expression involving one variable.
  - Optionally, x, the name of the variable (by default x=x).
- fMax(expr ⟨,x ⟩) returns the value of x that maximizes the expression.
- fMin(expr ⟨,x ⟩) returns the value of x that minimizes the expression.
- To maximize/minimize a function of several variables subject to constraints, 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 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 isn’t given, the default epsilon value is used (see Section 2.5.7, item 2.5.7).
  - Optionally, N, the maximum number of iterations.
- fMax(expr,constr,vars,init ⟨,ε,N ⟩) returns the vector of values that maximizes expr subject to the constraints constr.
- fMin(expr,constr,vars,init ⟨,ε,N ⟩) returns the vector of values that minimizes expr subject to the constraints constr.

#### Examples

fMax(sin(x),x)

or:

fMax(sin(x))

or:

fMax(sin(y),y)

π
2

fMin(sin(x),x)

or:

fMin(sin(x))

or:

fMin(sin(y),y)

− |
π
2

fMax((x-2)^2+(y-1)^2,[-.25x^2-y^2+1>=0,x-2y+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 | ⎤ ⎦