BRACKET Purpose
This procedure attempts to bracket the minimum of a one dimensional
function. A minimum is bracketed by three points ax, bx, cx, if:
1) bx is between ax and cx
2) f(b) < f(a) and f(b) < f(c)
In this situation, provided the function is continuous, there is
guaranteed to be a local minimum in between a and c.
The procedure is fairly robust in finding _some_ minimum, provided
one exists. However, there is no guarantee that it will find the
minimum closest to the starting location.
The algorithm is lifted from Numerical Recipes, with some attempt
to make the base cases a bit clearer
Category
Numerical Recipes
Calling Sequence
bracket, func, a, b, ax, bx, cx, fa, fb, fc, /verbose, _extra =
extra, struct = struct Inputs
func: A string giving the name of the 1D function to bracket. The
function must have the following calling sequence:
function func, x, _extra = extra
it may declare extra keywords, which can be supplied to
bracket and passed along to the function
a: The first trial abscissa
b: The second trial abscissa. The search for the minimum starts at
a and b, and proceeds downhill. Note that (a-b) should be
scaled, if possible, to match the scale of the wiggles in the
function. This will help in finding the nearest minimum
Optional Outputs
ax: Named variable to hold the first abscissa of the bracket
bx: Named variable to hold the second abscissa of the bracket
cx: Named variable to hold the final abscissa of the bracket
fa: Named variable to hold f(ax)
fb: Named variable to hold f(bx)
fc: Named variable to hold f(cx)
Keyword Parameters
_extra: Any extra keywords will be passed to FUNC
verbose: Set to an integer to control the amount of textual output
to produce (see VERBIAGE procedure for details)
struct: Set to a variable to receive the result in a structure.
Procedure
The procedure is adapted from Numerical Recipes, 3rd ed., page
491. It always keeps track of three x values (abc). It repeatedly
steps downhill. At each iteration, it approximates the 3 most
recent points as a parabola, and extrapolates to the parabola's min
(if it exists). If parabolic extrapolation doesn't work (because
the points are nearly co-linear or concave down), it just takes a
moderately larger step than last time. It stops when the function
starts increasing again.
Modification History
June 2009: Written by Chris Beaumont
August 2010: Added struct keyword. cnb.