Learn R Programming

pracma (version 1.4.5)

fminbnd: Finding Function Minimum

Description

Find minimum of single-variable function on fixed interval.

Usage

fminbnd(f, a, b, ..., maxiter = 1000, maximum = FALSE,
        tol = .Machine$double.eps^(2/3))

Arguments

f
function whose minimum or maximum is to be found.
a, b
endpoints of the interval to be searched.
maxiter
maximal number of iterations.
maximum
logical; shall maximum or minimum be found; default FALSE.
tol
relative tolerance.
...
additional variables to be passed to the function.

Value

  • List with
  • xminlocation of the minimum resp. maximum.
  • fminfunction value at the optimum.
  • niternumber of iterations used.
  • estim.precestimated precision.

Details

fminbnd finds the minimum of a function of one variable within a fixed interval. It applies Brent's algorithm, based on golden section search and parabolic interpolation.

fminbnd may only give local solutions. fminbnd never evaluates f at the endpoints.

References

R. P. Brent (1973). Algorithms for Minimization Without Derivatives. Dover Publications, reprinted 2002.

See Also

fibsearch, golden_ratio

Examples

Run this code
fminbnd(cos, 3, 4)          # x = 3.141593  , fval = -1
f <- function(x) x^3-2*x-5
fminbnd(f, 0, 2)            # x = 0.8164966 , fval = -6.088662

Run the code above in your browser using DataLab