idlastro / Math and Statistics: MINF_PARABOLIC

[Source code]

NAME
MINF_PARABOLIC
PURPOSE
Minimize a function using Brent's method with parabolic interpolation
EXPLANATION
Find a local minimum of a 1-D function up to specified tolerance.
This routine assumes that the function has a minimum nearby.
(recommend first calling minF_bracket, xa,xb,xc, to bracket minimum).
Routine can also be applied to a scalar function of many variables,
for such case the local minimum in a specified direction is found,
This routine is called by minF_conj_grad, to locate minimum in the 
direction of the conjugate gradient of function of many variables.
CALLING EXAMPLES
minF_parabolic, xa,xb,xc, xmin, fmin, FUNC_NAME="name"  ;for 1-D func.

minF_parabolic, xa,xb,xc, xmin, fmin, FUNC="name", $
                                  POINT=[0,1,1],   $
                                  DIRECTION=[2,1,1]     ;for 3-D func.
INPUTS
xa,xb,xc = scalars, 3 points which bracket location of minimum,
        that is, f(xb) < f(xa) and f(xb) < f(xc), so minimum exists.
        When working with function of N variables
        (xa,xb,xc) are then relative distances from POINT_NDIM,
        in the direction specified by keyword DIRECTION,
        with scale factor given by magnitude of DIRECTION.
INPUT KEYWORDS
FUNC_NAME = function name (string)
         Calling mechanism should be:  F = func_name( px )
         where:
                 px = scalar or vector of independent variables, input.
                 F = scalar value of function at px.
POINT_NDIM = when working with function of N variables,
         use this keyword to specify the starting point in N-dim space.
         Default = 0, which assumes function is 1-D.
DIRECTION = when working with function of N variables,
         use this keyword to specify the direction in N-dim space
         along which to bracket the local minimum, (default=1 for 1-D).
         (xa, xb, xc, x_min are then relative distances from POINT_NDIM)
MAX_ITER = maximum allowed number iterations, default=100.
TOLERANCE = desired accuracy of minimum location, default=sqrt(1.e-7).
OUTPUTS
xmin = estimated location of minimum.
        When working with function of N variables,
        xmin is the relative distance from POINT_NDIM,
        in the direction specified by keyword DIRECTION,
        with scale factor given by magnitude of DIRECTION,
        so that min. Loc. Pmin = Point_Ndim + xmin * Direction.
fmin = value of function at xmin (or Pmin).
PROCEDURE
Brent's method to minimize a function by using parabolic interpolation.
Based on function BRENT in Numerical Recipes in FORTRAN (Press et al. 
1992),  sec.10.2 (p. 397).
MODIFICATION HISTORY
Written, Frank Varosi NASA/GSFC 1992.
Converted to IDL V5.0   W. Landsman   September 1997