/* nag_zero_cont_func_bd (c05adc) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * Mark 7 revised, 2001. */ #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static double NAG_CALL f(double x); #ifdef __cplusplus } #endif int main(void) { Integer exit_status = 0; double a, b; double x, ftol, xtol; NagError fail; INIT_FAIL(fail); printf("nag_zero_cont_func_bd (c05adc) Example Program Results\n"); a = 0.0; b = 1.0; xtol = 1e-05; ftol = 0.0; /* nag_zero_cont_func_bd (c05adc). * Zero of a continuous function of one variable */ nag_zero_cont_func_bd(a, b, &x, f, xtol, ftol, &fail); if (fail.code == NE_NOERROR) { printf("Zero = %12.5f\n", x); } else { printf("%s\n", fail.message); if (fail.code == NE_XTOL_TOO_SMALL || fail.code == NE_PROBABLE_POLE) printf("Final point = %12.5f\n", x); exit_status = 1; goto END; } END: return exit_status; } static double NAG_CALL f(double x) { return exp(-x)-x; }