idlastro / Math and Statistics: MINF_PARABOL_D

[Source code]

NAME
MINF_PARABOL_D
PURPOSE
Minimize a function using a modified  Brent's method with derivatives
EXPLANATION
Based on the procedure DBRENT in Numerical Recipes by Press et al.
Finds a local minimum of a 1-D function up to specified tolerance,
using the first derivative of function in the algorithm.
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_parabol_D, xa,xb,xc, xmin, fmin, FUNC_NAME="name"  ;for 1-D func.

minF_parabol_D, 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.
KEYWORDS
FUNC_NAME = function name (string)
        Calling mechanism should be:  F = func_name( px, gradient )
        where:
                px = scalar or vector of independent variables, input.
                F = scalar value of function at px.
                gradient = derivative of function, a scalar if 1-D,
                        a gradient vector if N-D,
                        (should only be computed if arg. is present).
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
and using first derivative of function,
from Numerical Recipes (by Press, et al.), sec.10.3 (p.287),
MODIFICATION HISTORY
Written, Frank Varosi NASA/GSFC 1992.