fmin

Purpose

Minimize a function of one variable.

Synopsis

x = fmin('function',x1,x2)
x = fmin('function',x1,x2,options)
x = fmin('function',x1,x2,options,p1,p2, ...)
[x,options] = fmin(...)

Description

x = fmin('function',x1,x2) returns a value of x which is a local minimizer of function(x) in the interval x1 < x < x2. function is a string containing the name of the objective function to be minimized.

x = fmin('function',x1,x2,options) uses a vector of control parameters.

  • If options(1) is nonzero, intermediate steps in the solution are displayed. The default value of options(1) is 0.
  • options(2) is the termination tolerance. The default value is 1.e-4.
  • options(14) is the maximum number of steps. The default value is 500.
    Only three of the 18 components of options are referenced by fmin. Other functions in the Optimization Toolbox reference the other options.

    x = fmin('function',x1,x2,options,p1,p2,...) provides up to 10 additional arguments which are passed to the objective function, function(x,p1,p2,...).

    [x,options] = fmin(...) returns a count of the number of steps taken in options(10).

    Examples

    fmin('cos',3,4) computes pi to a few decimal places.

    fmin('cos',3,4,[1,1.e-12]) displays the steps taken to compute pi to 12 decimal places.

    To find the minimum of the function

    on the interval (0,2), write an M-file called f.m.

    function y = f(x)
    y = x.^3-2*x-5;
    
    Then invoke fmin with

    x = fmin('f', 0, 2)
    
    The result is

    x =
        0.8165
    
    The value of the function at the minimum is

    y = f(x)
              
    y =
        -6.0887
    

    Algorithm

    The algorithm is based on golden section search and parabolic interpolation. A FORTRAN program implementing the same algorithms is given in [1].

    See Also

    fmins, fzero
    foptions in the Optimization Toolbox
    

    References

    [1] G. E. Forsythe, M. A. Malcolm, and C. B. Moler, Computer Methods for Mathematical Computations, Prentice-Hall, 1976.

    (c) Copyright 1994 by The MathWorks, Inc.