Optimization Toolbox
  Go to function:
    Search    Help Desk 
fminsearch    Examples   See Also

Find the minimum of an unconstrained multivariable function

where x is a vector and f(x) is a function that returns a scalar.

Syntax

Description

fminsearch finds the minimum of a scalar function of several variables, starting at an initial estimate. This is generally referred to as unconstrained nonlinear optimization.

x = fminsearch(fun,x0) starts at the point x0 and finds a local minimum x of the function described in fun. x0 can be a scalar, vector, or matrix.

x = fminsearch(fun,x0,options) minimizes with the optimization parameters specified in the structure options.

x = fminsearch(fun,x0,options,P1,P2,...) passes the problem-dependent parameters P1, P2, etc., directly to the function fun. Pass an empty matrix for options to use the default values for options.

[x,fval] = fminsearch(...) returns in fval the value of the objective function fun at the solution x.

[x,fval,exitflag] = fminsearch(...) returns a value exitflag that describes the exit condition of fminsearch.

[x,fval,exitflag,output] = fminsearch(...) returns a structure output that contains information about the optimization.

Arguments

The arguments passed into the function are described in Table 1-1. The arguments returned by the function are described in Table 1-2. Details relevant to fminsearch are included below for fun, options, exitflag, and output.

fun
The function to be minimized. fun takes a vector x and returns a scalar value f of the objective function evaluated at x. You can specify fun to be an inline object. For example,

    x = fminsearch(inline('sin(x''*x)'),x0)
    
Alternatively, fun can be a string containing the name of a function (an M-file, a built-in function, or a MEX-file). If fun='myfun' then the M-file function myfun.m would have the form

    function f = myfun(x)
    f = ...            % Compute function value at x
    
options
Optimization parameter options. You can set or change the values of these parameters using the optimset function.fminsearch uses these options parameters:

exitflag
Describes the exit condition:

output
A structure whose fields contain information about the optimization:

Examples

Minimize the one-dimensional function f(x) = sin(x) + 3.

To use an M-file, i.e., fun = 'myfun', create a file myfun.m:

Then call fminsearch to find a minimum of fun near 2:

To minimize the function f(x) = sin(x) + 3 using an inline object:

Algorithms

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

If n is the length of x, a simplex in n-dimensional space is characterized by the n+1 distinct vectors that are its vertices. In two-space, a simplex is a triangle; in three-space, it is a pyramid. At each step of the search, a new point in or near the current simplex is generated. The function value at the new point is compared with the function's values at the vertices of the simplex and, usually, one of the vertices is replaced by the new point, giving a new simplex. This step is repeated until the diameter of the simplex is less than the specified tolerance.

fminsearch is generally less efficient than fminunc for problems of order greater than two. However, when the problem is highly discontinuous, fminsearch may be more robust.

Limitations

fminsearch can often handle discontinuity, particularly if it does not occur near the solution. fminsearch may only give local solutions.

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 variables, they must be split into real and imaginary parts.

Note:
fminsearch is not the preferred choice for solving problems that are sums-of-squares, that is, of the form:. Instead use the lsqnonlin function, which has been optimized for problems of this form.

See Also

fminbnd, fminunc, optimset, inline

References

[1] Lagarias, J.C., J.A. Reeds, M.H. Wright, P.E. Wright, "Convergence Properties of the Nelder-Mead Simplex Algorithm in Low Dimensions," to appear in the SIAM Journal of Optimization.



[ Previous | Help Desk | Next ]