/* 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 g(double x); #ifdef __cplusplus } #endif int main(void) { double a; double omega; double epsabs, abserr; Nag_TrigTransform wt_func; double result; Nag_QuadSubProgress qpsub; Integer maxintervals, maxsubint_per_int; static NagError fail; Vprintf("d01asc Example Program Results\n"); epsabs = 0.001; a = 0.0; omega = X01AAC * 0.5; wt_func = Nag_Cosine; maxintervals = 50; maxsubint_per_int = 500; d01asc(g, a, omega, wt_func, maxintervals, maxsubint_per_int, epsabs, &result, &abserr, &qpsub, &fail); Vprintf("a - lower limit of integration = %10.4f\n", a); Vprintf("b - upper limit of integration = infinity\n"); Vprintf("epsabs - absolute accuracy requested = %9.2e\n\n", epsabs); if (fail.code != NE_NOERROR) Vprintf("%s\n", fail.message); if (fail.code != NE_INT_ARG_LT && fail.code != NE_BAD_PARAM && fail.code != NE_ALLOC_FAIL) { Vprintf("result - approximation to the integral = %9.5f\n", result); Vprintf("abserr - estimate of the absolute error = %9.2e\n", abserr); Vprintf("qpsub.fun_count - number of function evaluations = %4ld\n", qpsub.fun_count); Vprintf("qpsub.intervals - number of intervals used = %4ld\n", qpsub.intervals); Vprintf("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); return EXIT_SUCCESS; } else return EXIT_FAILURE; } static double g(double x) { return (x > 0.0) ? 1.0/sqrt(x) : 0.0; }