/* nag_multid_quad_adapt_1(d01wcc) 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 f(Integer n, double z[], Nag_User *comm); #ifdef __cplusplus } #endif #define NDIM 4 #define MAXPTS 1000*NDIM int main(void) { Integer ndim = NDIM; Integer maxpts = MAXPTS; double a[4], b[4]; Integer k; static NagError fail; double finval; Integer minpts; double acc, eps; Nag_User comm; Vprintf("d01wcc Example Program Results\n"); for (k=0; k < 4; ++k) { a[k] = 0.0; b[k] = 1.0; } eps = 0.0001; minpts = 0; d01wcc(ndim, f, a, b, &minpts, maxpts, eps, &finval, &acc, &comm, &fail); if (fail.code != NE_NOERROR) Vprintf("%s\n",fail.message); if (fail.code == NE_NOERROR || fail.code == NE_QUAD_MAX_INTEGRAND_EVAL) { Vprintf("Requested accuracy =%12.2e\n", eps); Vprintf("Estimated value =%12.4f\n", finval); Vprintf("Estimated accuracy =%12.2e\n", acc); return EXIT_SUCCESS; } else return EXIT_FAILURE; } static double f(Integer n, double z[], Nag_User *comm) { double tmp_pwr; tmp_pwr = z[1]+1.0+z[3]; return z[0]*4.0*z[2]*z[2]*exp(z[0]*2.0*z[2])/(tmp_pwr*tmp_pwr); }