/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:10 */
/*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_dfmin s=dbov str=l x=f - prototypes */
#include <math.h>
#include "fcrt.h"
#include <stdio.h>
#include <stdlib.h>
#include "p_dfmin.h"
/*     program DRDFMIN
 *>> 1996-05-28 DRDFMIN Krogh  Moved format up.
 *>> 1994-10-19 DRDFMIN Krogh  Changes to use M77CON
 *>> 1994-07-15 DRDFMIN CLL
 *>> 1993-03-01 CLL Changed "zero" to "minimum".
 *>> 1992-03-24 CLL Added missing comma in format statement.
 *>> 1987-12-09 DRDFMIN  Lawson  Initial Code.
 *     Demo driver for DFMIN.  Finds minimum of a univariate function.
 *     C. L. Lawson & S. Y. Chiu, JPL, Aug 1987, Oct 1987
 *     F. T. Krogh, Oct. 1987.
 *     ------------------------------------------------------------------
 *--D replaces "?": DR?FMIN, ?FMIN
 *     ------------------------------------------------------------------ */
		/* PARAMETER translations */
#define	A	(-1.0e0)
#define	B	1.0e0
#define	TWO	2.0e0
#define	XTOL	1.0e-7
		/* end of PARAMETER translations */
 
 
int main( )
{
	long int mode;
	double tol, x, xorf;
 
	/*     ------------------------------------------------------------------ */
	printf(" DRDFMIN.. Demo driver for DFMIN, univariate minimum finder.\n "
	   "Problem:      Find minimum of 2**X + 2**(-2*X).\n Exact result: X = 1/3\n "
	   "Min value: 1.5 * 2**(1/3) = 1.88988157...\n");
	x = A;
	xorf = B;
	tol = XTOL;
	mode = 0;
L_10:
	dfmin( &x, &xorf, &mode, tol );
	if (mode != 1)
		goto L_20;
	xorf = pow(TWO,x) + pow(TWO,-TWO*x);
	goto L_10;
L_20:
	;
	printf(" Results returned by DFMIN:\n    MODE = %3ld\n    Solution:     X = %16.8f\n               f(X) = %16.8f\n",
	   mode, x, xorf);
	exit(0);
} /* end of function */