/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:13 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_dzero s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include #include #include "p_dzero.h" /* program DRDZERO *>> 1995-05-28 DRDZERO Krogh Changes to use M77CON *>> 1993-05-05 DRDZERO Krogh Adjusted to simplify conversion to C. *>> 1992-03-24 DRDZERO Krogh Added "," to format statmement. *>> 1991-11-25 DRDZERO Krogh Cleaned up Fortran version. *>> 1987-12-09 DRDZERO Krogh Initial Code. *--D replaces "?": DR?ZERO, ?ZERO * Demo driver for DZERO. Univariate zero finder. * F. T. Krogh, Sept. 1987. * ------------------------------------------------------------------ */ /* PARAMETER translations */ #define A 0.0e0 #define B 4.0e0 #define EIGHT 8.0e0 #define TOL 0.0e0 #define TWO 2.0e0 /* end of PARAMETER translations */ int main( ) { long int mode; double f1, f2, x1, x2; /* ------------------------------------------------------------------ */ printf(" DRDZERO.. Demo driver for DZERO, univariate zero finder.\n " "Problem: Find zero of 2**X - 8. Exact result: X = 3.\n"); x2 = B; f2 = pow(TWO,x2) - EIGHT; mode = 0; x1 = A; L_20: f1 = pow(TWO,x1) - EIGHT; dzero( &x1, &f1, &x2, &f2, &mode, TOL ); if (mode == 1) goto L_20; printf(" Results from subroutine DZERO:\n MODE = %3ld\n Solution: X1 = %11.8f\n f(X1) = %11.3g\n Accuracy: X1 - X2 = %11.3g\n f(X2) = %11.3g\n", mode, x1, f1, x1 - x2, f2); exit(0); } /* end of function */