Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Find minimum of unconstrained multivariable function using derivative-free method

Nonlinear programming solver. Searches for the minimum of a problem specified by

$$\underset{x}{\mathrm{min}}f(x)$$

*f*(*x*) is a function that returns a scalar, and
*x* is a vector or a matrix; see Matrix Arguments.

`x = fminsearch(fun,x0)`

`x = fminsearch(fun,x0,options)`

`x = fminsearch(problem)`

```
[x,fval]
= fminsearch(___)
```

```
[x,fval,exitflag]
= fminsearch(___)
```

```
[x,fval,exitflag,output]
= fminsearch(___)
```

finds
the minimum for `x`

= fminsearch(`problem`

)`problem`

, where `problem`

is
a structure. Create `problem`

by exporting a problem
from Optimization app, as described in Exporting Your Work.

`fminsearch`

only minimizes over the real numbers, that is,*x*must only consist of real numbers and*f*(*x*) must only return real numbers. When*x*has complex values, split*x*into real and imaginary parts.Use

`fminsearch`

to solve nondifferentiable problems or problems with discontinuities, particularly if no discontinuity occurs near the solution.`fminsearch`

is generally less efficient than`fminunc`

, especially for problems of dimension greater than two. However, when the problem is discontinuous,`fminsearch`

can be more robust than`fminunc`

.`fminsearch`

is not the preferred solver for problems that are sums of squares, that is, of the form$$\underset{x}{\mathrm{min}}{\Vert f(x)\Vert}_{2}^{2}=\underset{x}{\mathrm{min}}\left({f}_{1}{(x)}^{2}+{f}_{2}{(x)}^{2}+\mathrm{...}+{f}_{n}{(x)}^{2}\right)$$

Instead, use the

`lsqnonlin`

function, which has been optimized for problems of this form.

`fminsearch`

uses the simplex search method
of Lagarias et al. [1]. This is a direct search method that does not use numerical
or analytic gradients as in `fminunc`

.
The algorithm is described in detail in fminsearch Algorithm. The algorithm is not guaranteed to
converge to a local minimum.

[1] Lagarias, J. C., J. A. Reeds, M. H. Wright,
and P. E. Wright. “Convergence Properties of the Nelder-Mead
Simplex Method in Low Dimensions.” *SIAM Journal
of Optimization*. Vol. 9, Number 1, 1998, pp. 112–147.

`fminbnd`

| `fminunc`

| `optimset`

| `optimtool`

- Create Function Handle (MATLAB)
- Anonymous Functions (MATLAB)