# fminsearch

Find the unconstrained minimum of a real function using the Nelder-Mead simplex algorithm.

## Syntax

x = fminsearch(@func,x0)

x = fminsearch(@func,x0,options)

[x,fval,info,output] = fminsearch(...)

## Inputs

`func`- The function to minimize.
`x0`- An estimate of the location of the minimum.
`options`- A struct containing option settings.

## Outputs

- x
- The location of the function minimum.
- fval
- The minimum of the function.
- info
- The convergence status flag.
- info = 1
- Function value converged to within tolX.
- info = 0
- Reached maximum number of iterations or function calls.

- output
- A struct containing iteration details. The members are as follows:
- iterations
- The number of iterations.
- nfev
- The number of function evaluations.
- xiter
- The candidate solution at each iteration.
- fvaliter
- The objective function value at each iteration.

## Example

Minimize the Rosenbrock function.

```
function obj = Rosenbrock(x)
obj = (1 - x(1))^2 + 100 * (x(2) - x(1)^2)^2;
end
x0 = [-1.2, 1.0];
[x,fval] = fminsearch(@Rosenbrock, x0)
```

```
x = [Matrix] 1 x 2
1.00000 1.00000
fval = 5.29978e-14
```

## Comments

fminsearch uses the Nelder-Mead simplex algorithm, which does not require the objective function to be differentiable. When the objective function is differentiable, fminunc is generally prefereble.

The optimset options and defaults are as follows:

- MaxIter: 100
- MaxFunEvals: 400
- TolX: 1.0e-7