fminbnd

Find the minimum of a univariate real function within an interval.

Syntax

x = fminbnd(@func,interval)

x = fminbnd(@func,interval,options)

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

Inputs

func
The function to minimize.
interval
A two-element vector containing the interval on which to minimize.
Type: double
Dimension: vector
options
A struct containing option settings.
See optimset for details.

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 function values of the interval end points at each iteration.
fvaliter
The interval end points at each iteration.

Example

function y = func(x)
    y = -log(x) / x;
end

interval = [1, 6];
[x,fval] = fminbnd(@func, interval)
x = 2.71828183
fval = -0.367879441

Comments

fminbnd implements Brent's method for minimization without derivatives.

Options for convergence tolerance controls are specified with optimset.

To pass additional parameters to a function argument, use an anonymous function.

The optimset options and defaults are as follows:
  • MaxIter: 100
  • MaxFunEvals: 400
  • TolX: 1.0e-7