nag_1d_quad_inf (d01amc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_1d_quad_inf (d01amc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_1d_quad_inf (d01amc) calculates an approximation to the integral of a function f x  over an infinite or semi-infinite interval a,b :
I = a b f x dx .

2  Specification

#include <nag.h>
#include <nagd01.h>
void  nag_1d_quad_inf (
double (*f)(double x),
Nag_BoundInterval boundinf, double bound, double epsabs, double epsrel, Integer max_num_subint, double *result, double *abserr, Nag_QuadProgress *qp, NagError *fail)

3  Description

nag_1d_quad_inf (d01amc) is based on the QUADPACK routine QAGI (Piessens et al. (1983)). The entire infinite integration range is first transformed to 0,1  using one of the identities
- a f x dx = 0 1 f a - 1-t t 1 t 2 dt
a f x dx = 0 1 f a + 1-t t 1 t 2 dt
- f x dx = 0 f x + f -x dx = 0 1 f 1-t t + f - 1 + t t 1 t 2 dt
where a  represents a finite integration limit. An adaptive procedure, based on the Gauss 7-point and Kronrod 15-point rules, is then employed on the transformed integral. The algorithm, described by de Doncker (1978), incorporates a global acceptance criterion (as defined by Malcolm and Simpson (1976)) together with the ε -algorithm (Wynn (1956)) to perform extrapolation. The local error estimation is described by Piessens et al. (1983).

4  References

de Doncker E (1978) An adaptive extrapolation algorithm for automatic integration ACM SIGNUM Newsl. 13(2) 12–18
Malcolm M A and Simpson R B (1976) Local versus global strategies for adaptive quadrature ACM Trans. Math. Software 1 129–146
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag
Wynn P (1956) On a device for computing the emSn transformation Math. Tables Aids Comput. 10 91–96

5  Arguments

1:     ffunction, supplied by the userExternal Function
f must return the value of the integrand f  at a given point.
The specification of f is:
double  f (double x)
1:     xdoubleInput
On entry: the point at which the integrand f  must be evaluated.
2:     boundinfNag_BoundIntervalInput
On entry: indicates the kind of integration interval:
  • if boundinf=Nag_UpperSemiInfinite, the interval is bound,+ ;
  • if boundinf=Nag_LowerSemiInfinite, the interval is -,bound ;
  • if boundinf=Nag_Infinite, the interval is -,+ .
Constraint: boundinf=Nag_UpperSemiInfinite, Nag_LowerSemiInfinite or Nag_Infinite.
3:     bounddoubleInput
On entry: the finite limit of the integration interval (if present). bound is not used if boundinf=Nag_Infinite.
4:     epsabsdoubleInput
On entry: the absolute accuracy required. If epsabs is negative, the absolute value is used. See Section 7.
5:     epsreldoubleInput
On entry: the relative accuracy required. If epsrel is negative, the absolute value is used. See Section 7.
6:     max_num_subintIntegerInput
On entry: the upper bound on the number of sub-intervals into which the interval of integration may be divided by the function. The more difficult the integrand, the larger max_num_subint should be.
Constraint: max_num_subint1 .
7:     resultdouble *Output
On exit: the approximation to the integral I .
8:     abserrdouble *Output
On exit: an estimate of the modulus of the absolute error, which should be an upper bound for I - result .
9:     qpNag_QuadProgress *
Pointer to structure of type Nag_QuadProgress with the following members:
On exit: the actual number of sub-intervals used.
On exit: the number of function evaluations performed by nag_1d_quad_inf (d01amc).
sub_int_beg_ptsdouble *Output
sub_int_end_ptsdouble *Output
sub_int_resultdouble *Output
sub_int_errordouble *Output
On exit: these pointers are allocated memory internally with max_num_subint elements. If an error exit other than NE_INT_ARG_LT, NE_BAD_PARAM or NE_ALLOC_FAIL occurs, these arrays will contain information which may be useful. For details, see Section 8.
Before a subsequent call to nag_1d_quad_inf (d01amc) is made, or when the information contained in these arrays is no longer useful, you should free the storage allocated by these pointers using the NAG macro NAG_FREE.
10:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

Dynamic memory allocation failed.
On entry, argument boundinf had an illegal value.
On entry, max_num_subint must not be less than 1: max_num_subint=value .
Extremely bad integrand behaviour occurs around the sub-interval value,value .
The same advice applies as in the case of NE_QUAD_MAX_SUBDIV.
Extremely bad integrand behaviour occurs around one of the sub-intervals value,value  or value,value .
The same advice applies as in the case of NE_QUAD_MAX_SUBDIV.
The maximum number of subdivisions has been reached: max_num_subint=value .
The maximum number of subdivisions has been reached without the accuracy requirements being achieved. Look at the integrand in order to determine the integration difficulties. If the position of a local difficulty within the interval can be determined (e.g., a singularity of the integrand or its derivative, a peak, a discontinuity, etc.) you will probably gain from splitting up the interval at this point and calling the integrator on the sub-intervals. If necessary, another integrator, which is designed for handling the type of difficulty involved, must be used. Alternatively, consider relaxing the accuracy requirements specified by epsabs and epsrel, or increasing the value of max_num_subint.
The integral is probably divergent or slowly convergent.
Please note that divergence can also occur with any error exit other than NE_INT_ARG_LT, NE_BAD_PARAM or NE_ALLOC_FAIL.
Round-off error is detected during extrapolation.
The requested tolerance cannot be achieved, because the extrapolation does not increase the accuracy satisfactorily; the returned result is the best that can be obtained.
The same advice applies as in the case of NE_QUAD_MAX_SUBDIV.
Round-off error prevents the requested tolerance from being achieved: epsabs=value , epsrel=value .
The error may be underestimated. Consider relaxing the accuracy requirements specified by epsabs and epsrel.

7  Accuracy

nag_1d_quad_inf (d01amc) cannot guarantee, but in practice usually achieves, the following accuracy:
I - result tol
tol = max epsabs , epsrel × I
and epsabs and epsrel are user-specified absolute and relative error tolerances. Moreover it returns the quantity abserr which, in normal circumstances, satisfies
I - result abserr tol .

8  Further Comments

The time taken by nag_1d_quad_inf (d01amc) depends on the integrand and the accuracy required.
If the function fails with an error exit other than NE_INT_ARG_LT, NE_BAD_PARAM or NE_ALLOC_FAIL then you may wish to examine the contents of the structure qp. These contain the end-points of the sub-intervals used by nag_1d_quad_inf (d01amc) along with the integral contributions and error estimates over the sub-intervals.
Specifically, for i=1,2,,n, let r i  denote the approximation to the value of the integral over the sub-interval a i , b i  in the partition of a,b  and e i  be the corresponding absolute error estimate.
Then, a i b i f x dx r i  and result = i=1 n r i  unless the function terminates while testing for divergence of the integral (see Section 3.4.3 of Piessens et al. (1983)). In this case, result (and abserr) are taken to be the values returned from the extrapolation process. The value of n  is returned in qpnum_subint, and the values a i , b i , r i  and e i  are stored in the structure qp as

9  Example

This example computes
0 1 x+1 x dx .

9.1  Program Text

Program Text (d01amce.c)

9.2  Program Data


9.3  Program Results

Program Results (d01amce.r)

nag_1d_quad_inf (d01amc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012