/* nag_1d_quad_inf_wt_trig (d01asc) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * Mark 6 revised, 2000. * Mark 7, revised, 2001. * */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static double NAG_CALL g(double x); #ifdef __cplusplus } #endif int main(void) { Integer exit_status = 0; double a; double omega; double epsabs, abserr; Nag_TrigTransform wt_func; double result; Nag_QuadSubProgress qpsub; Integer maxintervals, maxsubint_per_int; NagError fail; INIT_FAIL(fail); printf("nag_1d_quad_inf_wt_trig (d01asc) Example Program Results\n"); epsabs = 0.001; a = 0.0; /* nag_pi (x01aac). * pi */ omega = nag_pi * 0.5; wt_func = Nag_Cosine; maxintervals = 50; maxsubint_per_int = 500; /* nag_1d_quad_inf_wt_trig (d01asc). * One-dimensional adaptive quadrature, semi-infinite * interval, sine or cosine weight function */ nag_1d_quad_inf_wt_trig(g, a, omega, wt_func, maxintervals, maxsubint_per_int, epsabs, &result, &abserr, &qpsub, &fail); printf("a - lower limit of integration = %10.4f\n", a); printf("b - upper limit of integration = infinity\n"); printf("epsabs - absolute accuracy requested = %11.2e\n\n", epsabs); if (fail.code != NE_NOERROR) printf("Error from nag_1d_quad_inf_wt_trig (d01asc) %s\n", fail.message); if (fail.code != NE_INT_ARG_LT && fail.code != NE_BAD_PARAM && fail.code != NE_ALLOC_FAIL && fail.code != NE_NO_LICENCE) { printf("result - approximation to the integral = %9.5f\n", result); printf("abserr - estimate of the absolute error = %11.2e\n", abserr); printf("qpsub.fun_count - number of function evaluations =" " %4ld\n", qpsub.fun_count); printf("qpsub.intervals - number of intervals used = %4ld\n", qpsub.intervals); printf("qpsub.subints_per_interval - \n" "maximum number of subintervals used in any one interval =" " %4ld\n", qpsub.subints_per_interval); /* Free memory used by qpsub */ NAG_FREE(qpsub.interval_error); NAG_FREE(qpsub.interval_result); NAG_FREE(qpsub.interval_flag); } else { exit_status = 1; goto END; } END: return exit_status; } static double NAG_CALL g(double x) { return (x > 0.0)?1.0/sqrt(x):0.0; }