/* nag_quad_1d_fin_smooth (d01bdc) Example Program. * * Copyright 2011, Numerical Algorithms Group. * * Mark 23, 2011. */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static double NAG_CALL f(double x, Nag_Comm *comm); #ifdef __cplusplus } #endif int main(void) { Integer exit_status = 0; double a, abserr, b, epsabs, epsrel, result; printf("nag_quad_1d_fin_smooth (d01bdc) Example Program Results\n"); /* Skip heading in data file */ scanf("%*[^\n] "); /* Input arguments */ scanf("%lf %lf", &epsabs, &epsrel); scanf("%lf %lf", &a, &b); /* nag_quad_1d_fin_smooth (d01bdc). * One-dimensional quadrature, non-adaptive, finite interval. */ nag_quad_1d_fin_smooth(f, a, b, epsabs, epsrel, &result, &abserr, NAGCOMM_NULL); printf("\na - lower limit of integration = %10.4f" "\nb - upper limit of integration = %10.4f" "\nepsabs - absolute accuracy requested = %9.2e" "\nepsrel - relative accuracy requested = %9.2e\n" "\nresult - approximation to the integral = %9.5f" "\nabserr - estimate to the absolute error = %9.2e\n\n", a, b, epsabs, epsrel, result, abserr); if (abserr > MAX(epsabs, epsrel * fabs(result))) printf("Warning - requested accuracy may not have been achieved.\n"); return exit_status; } static double NAG_CALL f(double x, Nag_Comm *comm) { return (pow(x, 2))*sin(10.0*nag_pi*x); }