Find a value of x which minimizes the function fun.
The search begins at the point x0 and iterates using the
Nelder & Mead Simplex algorithm (a derivative-free method). This
algorithm is better-suited to functions which have discontinuities or for
which a gradient-based search such as fminunc
fails.
Options for the search are provided in the parameter options using the
function optimset
. Currently, fminsearch
accepts the options:
"TolX"
, "MaxFunEvals"
, "MaxIter"
, "Display"
.
For a description of these options, see optimset
.
On exit, the function returns x, the minimum point, and fval, the function value thereof.
Example usages:
fminsearch (@(x) (x(1)-5).^2+(x(2)-8).^4, [0;0]) fminsearch (inline ("(x(1)-5).^2+(x(2)-8).^4", "x"), [0;0])
See also: fminbnd, fminunc, optimset.
The following code
fcn = @(x) (x(1)-5).^2 + (x(2)-8).^4 x0 = [0;0]; [xmin, fval] = fminsearch (fcn, x0)
Produces the following output
fcn = @(x) (x (1) - 5) .^ 2 + (x (2) - 8) .^ 4 xmin = 5.0000 7.9992 fval = 1.8423e-11
Package: octave