DEFINITION MODULE GoldenM;

   (* EXPORT QUALIFIED Golden, MnBrak; *)

   FROM NRMath IMPORT RealFunction;

   PROCEDURE Golden(    ax, bx, cx: REAL;
                        func:       RealFunction;
                        tol:        REAL; 
                    VAR xmin:       REAL): REAL; 
   (*
     Given a function func, and given a bracketing triplet of abscissas ax,
     bx, cx (such that bx is between ax and cx, and func(bx) is less than both 
     func(ax) and func(cx)), this routine performs a golden section search for 
     the minimum, isolating it to a fractional precision of about tol.
     The abscissa of the minimum is returned as xmin, and the minimum
     function value is returned as the returned function value.
   *)

   PROCEDURE MnBrak(VAR ax, bx, cx, fa, fb, fc: REAL;
                        func: RealFunction); 
   (*
     Given a function func, and given distinct initial points ax and bx, 
     this routine searches in the downhill direction (defined by the function 
     as evaluated at the initial points) and returns new points ax, bx,
     cx which bracket a minimum of the function. Also returned are
     the function values at the three points, fa, fb, and fc.
   *)

END GoldenM.
