/* nag_zero_cont_func_bd_1 (c05sdc) Example Program. * * Copyright 1998 Numerical Algorithms Group. * * Mark 5, 1998. * Mark 7 revised, 2001. */ #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static double NAG_CALL f(double x, Nag_User *comm); #ifdef __cplusplus } #endif int main(void) { Integer exit_status = 0; double a, b; double x, ftol, xtol; NagError fail; Nag_User comm; INIT_FAIL(fail); printf("nag_zero_cont_func_bd_1 (c05sdc) Example Program Results\n"); a = 0.0; b = 1.0; xtol = 1e-05; ftol = 0.0; /* nag_zero_cont_func_bd_1 (c05sdc). * Zero of a continuous function of one variable, * thread-safe */ nag_zero_cont_func_bd_1(a, b, &x, f, xtol, ftol, &comm, &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, Nag_User *comm) { return exp(-x)-x; }