This function minimizes a function of one variable. The function
requires 3 input abscissas which bracket at least one local minimum
(see, e.g. bracket.pro)
The algorithm is adapted from Numerical Recipes, but is
substantially modified in an attempt to simplify the
procedure. This may make the program slower, but I don't
think it should be any less stable.
The program attempts to improve upon goldenmin by using parabolic
extrapolation in the vicinity of the minimum. If the function is
smooth, then this should quickly converge. If it seems that
parabolic extrapolation isn't behaving well, then it
defaults to a goldenmin style partitioning of (abc) into golden
sections. This ensures convergence.
The biggest change from the routine in Numerical Recipes is the
test for when to use parabolic extrapolation. The default state is
to use parabolic extrapolation if the extrapolated minimum is
interior to (a,c). However, if the range of (a,c) decreases by less
than a factor of 1.5 in any iteration, then the algorithm is
'punished', and parabolic extrapolation is not used for a
round. The value of 1.5 is used because the goldenmin style of
partitioning shrinks (a,c) by about 1.67 per iteration. For smooth
functions, typical shrinkages seem to be >2 per iteration. They can
be as high as several thousand for nearly parabolic functions.
result = brent(func, ax, bx, cx,
fax, fbx, fcx, [tol tol,
fmin = fmin, /verbose, _extra = extra, /plot,
golden = golden)
func: The name of a user written function to minimize. The function
must have a calling sequence like result = func(x, _extra =
extra). It may declare extra keywords, which are supplied to
brent. It must return a scalar.
ax: The first point bracketing the minimum
bx: The second point bracketing the minimum
cx: The third point bracketing the minimum
tol: The requested fractional precision of xmin. Defaults to 1d-3
verbose: Set to produce textual output
fmin: Set to a variable to hold f(xmin)
_extra: extra kewyords to pass along to calls of func
plot: Set to plot the points as it plugs along.
golden: If set, turn off parabolic interpolation (i.e. basically
xmin: The approximate location of a minimum within (abc)