/* C05AJF Example Program C Version. NAG Copyright 1997. */ #include #include #include "nagmk20.h" main() { double eps, eta, x; int ifail, k, nfmax; double __stdcall f(double *); printf("C05AJF Example Program Results\n\n"); for (k=1; k<=2; k++) { eps = k==1 ? 0.1e-3 : 0.1e-4; x = 1.0; eta = 0.0; nfmax = 200; ifail = 1; C05AJF(&x,&eps,&eta,f,&nfmax,&ifail); if (ifail==0) printf("With eps = %e root = %f\n",eps,x); else { printf("ifail = %d\n",ifail); if (ifail==3 | ifail==4) printf("With eps = %e final value = %f\n",eps,x); } } return 0; } double __stdcall f(double *x) { return exp(-*x) - *x; }