D01 Chapter Contents
D01 Chapter Introduction (PDF version)
NAG Library Manual

NAG Library Chapter Introduction

D01 – Quadrature

 Contents

1  Scope of the Chapter

This chapter provides routines for the numerical evaluation of definite integrals in one or more dimensions and for evaluating weights and abscissae of integration rules.

2  Background to the Problems

The routines in this chapter are designed to estimate:
(a) the value of a one-dimensional definite integral of the form
abfxdx (1)
where fx is defined by you, either at a set of points xi,fxi, for i=1,2,,n, where a=x1<x2<<xn=b, or in the form of a function; and the limits of integration a,b may be finite or infinite.
Some methods are specially designed for integrands of the form
fx=wxgx (2)
which contain a factor wx, called the weight-function, of a specific form. These methods take full account of any peculiar behaviour attributable to the wx factor.
(b) the values of the one-dimensional indefinite integrals arising from (1) where the ranges of integration are interior to the interval a,b.
(c) the value of a multidimensional definite integral of the form
Rnfx1,x2,,xndxndx2dx1 (3)
where fx1,x2,,xn is a function defined by you and Rn is some region of n-dimensional space.
The simplest form of Rn is the n-rectangle defined by
aixibi,  i=1,2,,n (4)
where ai and bi are constants. When ai and bi are functions of xj (j<i), the region can easily be transformed to the rectangular form (see page 266 of Davis and Rabinowitz (1975)). Some of the methods described incorporate the transformation procedure.

2.1  One-dimensional Integrals

To estimate the value of a one-dimensional integral, a quadrature rule uses an approximation in the form of a weighted sum of integrand values, i.e.,
abfxdxi=1Nwifxi. (5)
The points xi within the interval a,b are known as the abscissae, and the wi are known as the weights.
More generally, if the integrand has the form (2), the corresponding formula is
abwxgxdxi=1Nwigxi. (6)
If the integrand is known only at a fixed set of points, these points must be used as the abscissae, and the weighted sum is calculated using finite difference methods. However, if the functional form of the integrand is known, so that its value at any abscissa is easily obtained, then a wide variety of quadrature rules are available, each characterised by its choice of abscissae and the corresponding weights.
The appropriate rule to use will depend on the interval a,b – whether finite or otherwise – and on the form of any wx factor in the integrand. A suitable value of N depends on the general behaviour of fx; or of gx, if there is a wx factor present.
Among possible rules, we mention particularly the Gaussian formulae, which employ a distribution of abscissae which is optimal for fx or gx of polynomial form.
The choice of basic rules constitutes one of the principles on which methods for one-dimensional integrals may be classified. The other major basis of classification is the implementation strategy, of which some types are now presented.
(a) Single rule evaluation procedures
A fixed number of abscissae, N, is used. This number and the particular rule chosen uniquely determine the weights and abscissae. No estimate is made of the accuracy of the result.
(b) Automatic procedures
The number of abscissae, N, within a,b is gradually increased until consistency is achieved to within a level of accuracy (absolute or relative) you requested. There are essentially two ways of doing this; hybrid forms of these two methods are also possible:
(i) whole interval procedures (non-adaptive)
A series of rules using increasing values of N are successively applied over the whole interval a,b. It is clearly more economical if abscissae already used for a lower value of N can be used again as part of a higher-order formula. This principle is known as optimal extension. There is no overlap between the abscissae used in Gaussian formulae of different orders. However, the Kronrod formulae are designed to give an optimal 2N+1-point formula by adding N+1 points to an N-point Gauss formula. Further extensions have been developed by Patterson.
(ii) adaptive procedures
The interval a,b is repeatedly divided into a number of sub-intervals, and integration rules are applied separately to each sub-interval. Typically, the subdivision process will be carried further in the neighbourhood of a sharp peak in the integrand than where the curve is smooth. Thus, the distribution of abscissae is adapted to the shape of the integrand.
Subdivision raises the problem of what constitutes an acceptable accuracy in each sub-interval. The usual global acceptability criterion demands that the sum of the absolute values of the error estimates in the sub-intervals should meet the conditions required of the error over the whole interval. Automatic extrapolation over several levels of subdivision may eliminate the effects of some types of singularities.
An ideal general-purpose method would be an automatic method which could be used for a wide variety of integrands, was efficient (i.e., required the use of as few abscissae as possible), and was reliable (i.e., always gave results to within the requested accuracy). Complete reliability is unobtainable, and generally higher reliability is obtained at the expense of efficiency, and vice versa. It must therefore be emphasized that the automatic routines in this chapter cannot be assumed to be 100% reliable. In general, however, the reliability is very high.

2.2  Multidimensional Integrals

A distinction must be made between cases of moderately low dimensionality (say, up to 4 or 5 dimensions), and those of higher dimensionality. Where the number of dimensions is limited, a one-dimensional method may be applied to each dimension, according to some suitable strategy, and high accuracy may be obtainable (using product rules). However, the number of integrand evaluations rises very rapidly with the number of dimensions, so that the accuracy obtainable with an acceptable amount of computational labour is limited; for example a product of 3-point rules in 20 dimensions would require more than 109 integrand evaluations. Special techniques such as the Monte–Carlo methods can be used to deal with high dimensions.
(a) Products of one-dimensional rules
Using a two-dimensional integral as an example, we have
a1b1a2b2fx,ydy dxi=1Nwi a2b2fxi,ydy (7)
a1b1a2b2fx,ydy dxi=1Nj=1Nwivjfxi,yj (8)
where wi,xi and vi,yi are the weights and abscissae of the rules used in the respective dimensions.
A different one-dimensional rule may be used for each dimension, as appropriate to the range and any weight function present, and a different strategy may be used, as appropriate to the integrand behaviour as a function of each independent variable.
For a rule-evaluation strategy in all dimensions, the formula (8) is applied in a straightforward manner. For automatic strategies (i.e., attempting to attain a requested accuracy), there is a problem in deciding what accuracy must be requested in the inner integral(s). Reference to formula (7) shows that the presence of a limited but random error in the y-integration for different values of xi can produce a ‘jagged’ function of x, which may be difficult to integrate to the desired accuracy and for this reason products of automatic one-dimensional routines should be used with caution (see Lyness (1983)).
(b) Monte–Carlo methods
These are based on estimating the mean value of the integrand sampled at points chosen from an appropriate statistical distribution function. Usually a variance reducing procedure is incorporated to combat the fundamentally slow rate of convergence of the rudimentary form of the technique. These methods can be effective by comparison with alternative methods when the integrand contains singularities or is erratic in some way, but they are of quite limited accuracy.
(c) Number theoretic methods
These are based on the work of Korobov and Conroy and operate by exploiting implicitly the properties of the Fourier expansion of the integrand. Special rules, constructed from so-called optimal coefficients, give a particularly uniform distribution of the points throughout n-dimensional space and from their number theoretic properties minimize the error on a prescribed class of integrals. The method can be combined with the Monte–Carlo procedure.
(d) Sag–Szekeres method
By transformation this method seeks to induce properties into the integrand which make it accurately integrable by the trapezoidal rule. The transformation also allows effective control over the number of integrand evaluations.
(e) Sparse grid methods
Given a set of one-dimensional quadrature rules of increasing levels of accuracy, the sparse grid method constructs an approximation to a multidimensional integral using d dimensional tensor products of the differences between rules of adjacent levels. This provides a lower theoretical accuracy than the methods in (a), the full grid approach, which is nonetheless still sufficient for various classes of sufficiently smooth integrands. Furthermore, it requries substantially fewer evaluations than the full grid approach. Specifically, if a one-dimensional quadrature rule has NO2 points, the full grid will require O2ld function evaluations, whereas the sparse grid of level  will require O2d-1. Hence a sparse grid approach is computationally feasible even for integrals over dO100.
Sparse grid methods are deterministic, and may be viewed as automatic whole domain procedures if their level  is allowed to increase.
(f) Automatic adaptive procedures
An automatic adaptive strategy in several dimensions normally involves division of the region into subregions, concentrating the divisions in those parts of the region where the integrand is worst behaved. It is difficult to arrange with any generality for variable limits in the inner integral(s). For this reason, some methods use a region where all the limits are constants; this is called a hyper-rectangle. Integrals over regions defined by variable or infinite limits may be handled by transformation to a hyper-rectangle. Integrals over regions so irregular that such a transformation is not feasible may be handled by surrounding the region by an appropriate hyper-rectangle and defining the integrand to be zero outside the desired region. Such a technique should always be followed by a Monte–Carlo method for integration.
The method used locally in each subregion produced by the adaptive subdivision process is usually one of three types: Monte–Carlo, number theoretic or deterministic. Deterministic methods are usually the most rapidly convergent but are often expensive to use for high dimensionality and not as robust as the other techniques.

3  Recommendations on Choice and Use of Available Routines

This section is divided into five subsections. The first subsection illustrates the difference between direct and reverse communication routines. The second subsection highlights the different levels of vectorization provided by different interfaces.
Sections 3.3, 3.4 and 3.5 consider in turn routines for: one-dimensional integrals over a finite interval, and over a semi-infinite or an infinite interval; and multidimensional integrals. Within each sub-section, routines are classified by the type of method, which ranges from simple rule evaluation to automatic adaptive algorithms. The recommendations apply particularly when the primary objective is simply to compute the value of one or more integrals, and in these cases the automatic adaptive routines are generally the most convenient and reliable, although also the most expensive in computing time.
Note however that in some circumstances it may be counter-productive to use an automatic routine. If the results of the quadrature are to be used in turn as input to a further computation (e.g., an ‘outer’ quadrature or an optimization problem), then this further computation may be adversely affected by the ‘jagged performance profile’ of an automatic routine; a simple rule-evaluation routine may provide much better overall performance. For further guidance, the article by Lyness (1983) is recommended.

3.1  Direct and Reverse Communication

Routines in this chapter which evaluate an integral value may be classified as either direct communication or reverse communication. See Section 3.2.3 in the Essential Introduction for a description of these terms.
Currently in this chapter the only routine explicitly using reverse communication is D01RAF.

3.2  Choice of Interface

This section concerns the design of the interface for the provision of abscissae, and the subsequent collection of calculated information, typically integrand evaluations. Vectorized interfaces typically allow for more efficient operation.
(a) Single abscissa interfaces
The algorithm will provide a single abscissa at which information is required. These are typically the most simple to use, although they may be significantly less efficient than a vectorized equivalent. Most of the algorithms in this chapter are of this type.
Examples of this include D01AJF and D01FBF.
(b) Vectorized abscissae interfaces
The algorithm will return a set of abscissae, at all of which information is required. While these are more complicated to use, they are typically more efficient than a non-vectorized equivalent. They reduce the overhead of function calls, allow the avoidance of repetition of computations common to each of the integrand evaluations, and offer greater scope for vectorization and parallelization of your code.
Examples include D01RGF, D01UAF, and the routines D01ATF and D01AUF, which are vectorized equivalents of D01AJF and D01AKF.
(c) Multiple integral interfaces
These are routines which allow for multiple integrals to be estimated simultaneously. As with (b) above, these are more complicated to use than single integral routines, however they can provide higher efficiency, particularly if several integrals require the same subcalculations at the same abscissae. They are most efficient if integrals which are supplied together are expected to have similar behaviour over the domain, particularly when the algorithm is adaptive.
Examples include D01EAF and D01RAF.

3.3  One-dimensional Integrals over a Finite Interval

(a) Integrand defined at a set of points
If fx is defined numerically at four or more points, then the Gill–Miller finite difference method (D01GAF) should be used. The interval of integration is taken to coincide with the range of x values of the points supplied. It is in the nature of this problem that any routine may be unreliable. In order to check results independently and so as to provide an alternative technique you may fit the integrand by Chebyshev series using E02ADF and then use routine E02AJF to evaluate its integral (which need not be restricted to the range of the integration points, as is the case for D01GAF). A further alternative is to fit a cubic spline to the data using E02BAF and then to evaluate its integral using E02BDF.
(b) Integrand defined as a function
If the functional form of fx is known, then one of the following approaches should be taken. They are arranged in the order from most specific to most general, hence the first applicable procedure in the list will be the most efficient. However, if you do not wish to make any assumptions about the integrand, the most reliable routines to use will be D01ATF (or D01AJF), D01AUF (or D01AKF), D01ALF, D01RGF or D01RAF, although these will in general be less efficient for simple integrals.
(i) Rule-evaluation routines
If fx is known to be sufficiently well behaved (more precisely, can be closely approximated by a polynomial of moderate degree), a Gaussian routine with a suitable number of abscissae may be used.
D01BCF or D01TBF with D01FBF may be used if it is required to examine the weights and abscissae.
D01TBF is faster and more accurate, whereas D01BCF is more general. D01UAF uses the same quadrature rules as D01TBF, and may be used if you do not explicitly require the weights and abscissae.
If fx is well behaved, apart from a weight-function of the form
x-a+b2 c  or  b-xcx-ad,  
D01BCF with D01FBF may be used.
(ii) Automatic whole-interval routines
If fx is reasonably smooth, and the required accuracy is not too high, the automatic whole interval routines D01ARF and D01BDF may be used. Additionally, D01ESF with d=1 may be used with an appropriate transformation from the unit interval.
D01BDF uses the Gauss 10-point rule, with the 21 point Kronrod extension, and the subsequent 43 and 87 point Patterson extensions if required.
D01ESF supports multiple simultaneous integrals, and has a vectorized interface. Either high order Gauss–Patterson rules (of size 2-1, for =1,,9), or high order Clenshaw-Curtis rules (of size 2-1+1, for =2,,12). Gauss–Patterson rules possess greater polynomial accuracy, whereas Clenshaw–Curtis rules are often well suited to oscillatory integrals.
D01ARF incorporates the same high order Gauss–Patterson rules as D01ESF, and is the only routine that may be used for indefinite integration.
(iii) Automatic adaptive routines
Firstly, several routines are available for integrands of the form wxgx where gx is a ‘smooth’ function (i.e., has no singularities, sharp peaks or violent oscillations in the interval of integration) and wx is a weight function of one of the following forms.
1. if wx= b-x α x-a β logb-xklogx-al, where k,l=0​ or ​1, α,β>-1: use D01APF;
2. if wx=1x-c : use D01AQF (this integral is called the Hilbert transform of g);
3. if wx=cosωx or sinωx: use D01ANF (this routine can also handle certain types of singularities in gx).
Secondly, there are multiple routines for general fx, using different strategies.
D01ATF (and D01AJF), and D01AUF (and D01AKF) use the strategy of Piessens et al. (1983), using repeated bisection of the interval, and in the first case the ε-algorithm (Wynn (1956)), to improve the integral estimate. This can cope with singularities away from the end points, provided singular points do not occur as abscissae, D01AUF tends to perform better than D01ATF on more oscillatory integrals.
D01ALF uses the same subdivision strategy as D01ATF over a set of initial interval segments determined by supplied break-points. It is hence suitable for integrals with discontinuities (including switches in definition) or sharp peaks occuring at known points. Such integrals may also be approximated using other routines which do not allow break-points, although such integrals should be evaluated over each of the sub-intervals seperately.
D01RAF again uses the strategy of Piessens et al. (1983), and provides the functionality of D01ALF, D01ATF and D01AUF in a reverse communication framework. It also supports multiple integrals and uses a vectorized interface for the abscissae. Hence it is likely to be more efficient if several similar integrals are required to be evaluated over the same domain. Furthermore, its behaviour can be tailored through the use of optional parameters.
D01AHF uses the strategy of Patterson (1968) and the ε-algorithm to adaptively evaluate the integral in question. It tends to be more efficient than the bisection based algorithms, although these tend to be more robust when singularities occur away from the end points.
D01RGF uses another adaptive scheme due to Gonnet (2010). This attempts to match the quadrature rule to the underlying integrand as well as subdividing the domain. Further, it can explicitly deal with singular points at abscissae, should NaN's or ∞ be returned by the user-supplied (sub)routine, provided the generation of these does not cause the program to halt (see Chapter X07).

3.4  One-dimensional Integrals over a Semi-infinite or Infinite Interval

(a) Integrand defined at a set of points
If fx is defined numerically at four or more points, and the portion of the integral lying outside the range of the points supplied may be neglected, then the Gill–Miller finite difference method, D01GAF, should be used.
(b) Integrand defined as a function
(i) Rule evaluation routines
If fx behaves approximately like a polynomial in x, apart from a weight function of the form:
1. e-βx,β>0 (semi-infinite interval, lower limit finite); or
2. e-βx,β<0 (semi-infinite interval, upper limit finite); or
3. e-β x-α 2,β>0 (infinite interval),
or if fx behaves approximately like a polynomial in x+b-1 (semi-infinite range), then the Gaussian routines may be used.
D01UAF may be used if it is not required to examine the weights and abscissae.
D01BCF or D01TBF with D01FBF may be used if it is required to examine the weights and abscissae.
D01TBF is faster and more accurate, whereas D01BCF is more general.
(ii) Automatic adaptive routines
D01AMF may be used, except for integrands which decay slowly towards an infinite end point, and oscillate in sign over the entire range. For this class, it may be possible to calculate the integral by integrating between the zeros and invoking some extrapolation process (see C06BAF).
D01ASF may be used for integrals involving weight functions of the form cosωx and sinωx over a semi-infinite interval (lower limit finite).
The following alternative procedures are mentioned for completeness, though their use will rarely be necessary.
1. If the integrand decays rapidly towards an infinite end point, a finite cut-off may be chosen, and the finite range methods applied.
2. If the only irregularities occur in the finite part (apart from a singularity at the finite limit, with which D01AMF can cope), the range may be divided, with D01AMF used on the infinite part.
3. A transformation to finite range may be employed, e.g.,
x= 1-tt   or   x=- loget  
will transform 0, to 1,0 while for infinite ranges we have
-fxdx=0fx+f-xdx.  
If the integrand behaves badly on -,0 and well on 0, or vice versa it is better to compute it as -0fxdx+0fxdx. This saves computing unnecessary function values in the semi-infinite range where the function is well behaved.

3.5  Multidimensional Integrals

A number of techniques are available in this area and the choice depends to a large extent on the dimension and the required accuracy. It can be advantageous to use more than one technique as a confirmation of accuracy, particularly for high-dimensional integrations. Several routines include a transformation procedure, using a user-supplied subroutine, which allows general product regions to be easily dealt with in terms of conversion to the standard n-cube region.
(a) Products of one-dimensional rules (suitable for up to about 5 dimensions)
If fx1,x2,,xn is known to be a sufficiently well behaved function of each variable xi, apart possibly from weight functions of the types provided, a product of Gaussian rules may be used. These are provided by D01BCF or D01TBF with D01FBF. Rules for finite, semi-infinite and infinite ranges are included.
For two-dimensional integrals only, unless the integrand is very badly behaved, the automatic whole-interval product procedure of D01DAF may be used. The limits of the inner integral may be user-specified functions of the outer variable. Infinite limits may be handled by transformation (see Section 3.4); end point singularities introduced by transformation should not be troublesome, as the integrand value will not be required on the boundary of the region.
If none of these routines proves suitable and convenient, the one-dimensional routines may be used recursively. For example, the two-dimensional integral
I=a1b1a2b2fx,ydy dx  
may be expressed as
I=a1b1 Fxdx,   where   Fx=a2b2 fx,ydy.  
The user-supplied code to evaluate Fx will call the integration routine for the y-integration, which will call more user-supplied code for fx,y as a function of y (x being effectively a constant).
From Mark 24 onwards, all direct communication routines may be called recursively. As such, you may use any routine, including the same routine, for each dimension. Note however, in previous releases, direct communication routines were not defined as recursive, and thus a different library integration routine must be used for each dimension if you are using an older product. Apart from this restriction, the following combinations were not permitted: D01AJF and D01ALF, D01ANF and D01APF, D01APF and D01AQF, D01ANF and D01AQF, D01ANF and D01ASF, D01AMF and D01ASF, D01ATF and D01AUF. Otherwise the full range of one-dimensional routines are available, for finite/infinite intervals, constant/variable limits, rule evaluation/automatic strategies etc.
The reverse communication routine D01RAF may be used by itself in a pseudo-recursive manner, in that it may be called to evaluate an inner integral for the integrand value of an outer integral also being calculated by D01RAF.
(b) Sag–Szekeres method
Two routines are based on this method.
D01FDF is particularly suitable for integrals of very large dimension although the accuracy is generally not high. It allows integration over either the general product region (with built-in transformation to the n-cube) or the n-sphere. Although no error estimate is provided, two adjustable parameters may be varied for checking purposes or may be used to tune the algorithm to particular integrals.
D01JAF is also based on the Sag–Szekeres method and integrates over the n-sphere. It uses improved transformations which may be varied according to the behaviour of the integrand. Although it can yield very accurate results it can only practically be employed for dimensions not exceeding 4.
(c) Number Theoretic method
Two subroutines are based on this method, D01GCF and a vectorized equivalent D01GDF.
Algorithms of this type carry out multidimensional integration using the Korobov–Conroy method over a product region with built-in transformation to the n-cube. A stochastic modification of this method is incorporated into the routines in this library, hybridising the technique with the Monte–Carlo procedure. An error estimate is provided in terms of the statistical standard error. A number of pre-computed optimal coefficient rules for up to 20 dimensions are provided; others can be computed using D01GYF and D01GZF. Like the Sag–Szekeres method it is suitable for large dimensional integrals although the accuracy is not high.
D01GCF requires a function to be provided to evaluate the value of the integrand at a single abscissa, and a subroutine to return the upper and lower limits of integration in a given dimension.
D01GDF has a vectorized interface which can result in faster execution, especially on vector-processing machines. You are required to provide two subroutines, the first to return an array of values of the integrand at each of an array of points, and the second to evaluate the limits of integration at each of an array of points. This reduces the overhead of function calls, avoids repetitions of computations common to each of the evaluations of the integral and limits of integration, and offers greater scope for vectorization of your code.
(d) A combinatorial extrapolation method
D01PAF computes a sequence of approximations and an error estimate to the integral of a function over a multidimensional simplex using a combinatorial method with extrapolation.
(e) Sparse Grid method
D01ESF implements a sparse grid quadrature scheme for the integration of a vector of multidimensional integrals over the unit hypercube,
F 0,1 d fx dx .  
The routine uses a vectorized interface, which returns a set of points at which the integrands must be evaluated in a sparse storage format for efficiency.
Other domains can be readily integrated over by using an appropriate mapping inside the provided subroutine for evaluating the integrands. It is suitable for d up to O100, although no upper bound on the number of dimensions is enforced. It will also evaluate one-dimensional integrals, although in this case the sparse grid used is in fact the full grid.
The routine uses optional parameters, set and queried using the routines D01ZKF and D01ZLF respectively. Amongst other options, these allow the parallelization of the routine to be controlled.
(f) Automatic routines (D01FCF and D01GBF)
Both routines are for integrals of the form
a1b1 a2b2 anbn fx1,x2,,xndxndxn-1dx1.  
D01GBF is an adaptive Monte–Carlo routine. This routine is usually slow and not recommended for high-accuracy work. It is a robust routine that can often be used for low-accuracy results with highly irregular integrands or when n is large.
D01FCF is an adaptive deterministic routine. Convergence is fast for well behaved integrands. Highly accurate results can often be obtained for n between 2 and 5, using significantly fewer integrand evaluations than would be required by D01GBF. The routine will usually work when the integrand is mildly singular and for n10 should be used before D01GBF. If it is known in advance that the integrand is highly irregular, it is best to compare results from at least two different routines.
There are many problems for which one or both of the routines will require large amounts of computing time to obtain even moderately accurate results. The amount of computing time is controlled by the number of integrand evaluations you have allowed, and you should set this parameter carefully, with reference to the time available and the accuracy desired.
D01EAF extends the technique of D01FCF to integrate adaptively more than one integrand, that is to calculate the set of integrals
a1b1 a2b2 anbn f1,f2,,fm dxndxn-1dx1 
for a set of similar integrands f1,f2,,fm where fi=fix1,x2,,xn.

4  Decision Trees

Tree 1: One-dimensional integrals over a finite interval

Is the functional form of the integrand known?   Is indefinite integration required?   D01ARF
yesyes
  no   no
Do you require reverse communication?   D01RAF
yes
  no
Are you concerned with efficiency for simple integrals?   Is the integrand smooth (polynomial-like) apart from weight function x-a+b/2c or b-x c x-a d?   D01ARF, D01UAF, D01TBF or D01BCF and D01FBF, or D01GCF
yesyes
  no   no
Is the integrand reasonably smooth and the required accuracy not too great?   D01ARF, D01BDF, D01ESF or D01UAF
yes
  no
Are multiple integrands to be integrated simultaneously?   D01ESF or D01RAF
yes
  no
Has the integrand discontinuities, sharp peaks or singularities at known points other than the end points?   Split the range and begin again; or use D01ALF or D01RGF
yes
  no
Is the integrand free of singularities, sharp peaks and violent oscillations apart from weight function b-x α x-a β logb-x k logx-a l ?   D01APF
yes
  no
Is the integrand free of singularities, sharp peaks and violent oscillations apart from weight function x-c-1 ?   D01AQF
yes
  no
Is the integrand free of violent oscillations apart from weight function cosωx or sinωx?   D01ANF
yes
  no
Is the integrand free of singularities?   D01AJF, D01AKF, D01AUF or D01ESF
yes
  no
Is the integrand free of discontinuities and of singularities except possibly at the end points?   D01AHF
yes
  no
D01AJF, D01ATF, D01RAF or D01RGF
D01AHF, D01AJF, D01ATF, D01RAF or D01RGF
D01GAF
Note: D01ATF, D01AUF, D01RAF and D01RGF are likely to be more efficient due to their vectorized interfaces than D01AJF and D01AKF, which use a more conventional user-interface, consistent with other routines in the chapter.

Tree 2: One-dimensional integrals over a semi-infinite or infinite interval

Is the functional form of the integrand known?   Are you concerned with efficiency for simple integrands?   Is the integrand smooth (polynomial-like) with no exceptions?   D01UAF, D01BDF, D01ARF or D01ESF with transformation. See Section 3.4 (b)(ii).
yesyesyes
  no   no   no
Is the integrand smooth (polynomial-like) apart from weight function e-β x  (semi-infinite range) or e-β x-a 2 (infinite range) or is the integrand polynomial-like in 1x+b? (semi-infinite range)?   D01UAF, D01TBF and D01FBF or D01BCF and D01FBF
yes
  no
Has integrand discontinuities, sharp peaks or singularities at known points other than a finite limit?   Split range; begin again using finite or infinite range trees
yes
  no
Does the integrand oscillate over the entire range?   Does the integrand decay rapidly towards an infinite limit?   Use D01AMF; or set cutoff and use finite range tree
yesyes
  no   no
Is the integrand free of violent oscillations apart from weight function cosωx or sinωx (semi-infinite range)?   D01ASF
yes
  no
Use finite-range integration between the zeros and extrapolate (see C06BAF)
D01AMF
D01AMF
D01GAF (integrates over the range of the points supplied)

Tree 3: Multidimensional integrals

Is dimension =2 and product region?   D01DAF
yes
  no
Is dimension 4   Is region an n-sphere?   D01FBF with user transformation or D01JAF
yesyes
  no   no
Is region a Simplex?   D01FBF with user transformation or D01PAF
yes
  no
Is the integrand smooth (polynomial-like) in each dimension apart from weight function?   D01TBF or D01BCF with D01FBF
yes
  no
Is integrand free of extremely bad behaviour?   D01ESF, D01FCF, D01FDF or D01GCF
yes
  no
Is bad behaviour on the boundary?   D01FCF or D01FDF
yes
  no
Compare results from at least two of D01FCF, D01FDF, D01GBF and D01GCF, D01ESF and one-dimensional recursive application
Is region an n-sphere?   D01FDF
yes
  no
Is region a Simplex?   D01PAF
yes
  no
Is high accuracy required?   D01FDF with parameter tuning
yes
  no
Is dimension high?   D01FDF, D01GCF or D01GDF, D01ESF
yes
  no
D01FCF
Note: in the case where there are many integrals to be evaluated D01EAF should be preferred to D01FCF.
D01GDF is likely to be more efficient than D01GCF, which uses a more conventional user-interface, consistent with other routines in the chapter.

5  Functionality Index

Korobov optimal coefficients for use in D01GCF and D01GDF: 
    when number of points is a product of 2 primes D01GZF
    when number of points is prime D01GYF
Multidimensional quadrature, 
    over a finite two-dimensional region D01DAF
    over a general product region, 
        Korobov–Conroy number-theoretic method D01GCF
        Sag–Szekeres method (also over n-sphere) D01FDF
        variant of D01GCF especially efficient on vector machines D01GDF
    over a hyper-rectangle, 
        adaptive method D01FCF
        adaptive method, 
            multiple integrands D01EAF
        Gaussian quadrature rule-evaluation D01FBF
        Monte–Carlo method D01GBF
        sparse grid method (with user transformation), 
            muliple integrands, vectorized interface D01ESF
    over an n-simplex D01PAF
    over an n-sphere (n  ≤  4), 
        allowing for badly behaved integrands D01JAF
One-dimensional quadrature, 
    adaptive integration of a function over a finite interval, 
        strategy due to Gonnet, 
            suitable for badly behaved integrals, 
                vectorized interface D01RGF
        strategy due to Patterson, 
            suitable for well-behaved integrands, except possibly at end-points D01AHF
        strategy due to Piessens and de Doncker, 
            allowing for singularities at user-specified break-points D01ALF
            suitable for badly behaved integrands, 
                single abscissa interface D01AJF
                vectorized interface D01ATF
            suitable for highly oscillatory integrals, 
                single abscissa interface D01AKF
                vectorized interface D01AUF
        weight function 1 / (x − c) Cauchy principal value (Hilbert transform) D01AQF
        weight function cos(ωx) or sin(ωx) D01ANF
        weight function with end-point singularities of algebraico-logarithmic type D01APF
    adaptive integration of a function over an infinite interval or semi-infinite interval, 
        no weight function D01AMF
        weight function cos(ωx) or sin(ωx) D01ASF
    integration of a function defined by data values only, 
        Gill–Miller method D01GAF
    non-adaptive integration over a finite, semi-infinite or infinite interval, 
        using pre-computed weights and abscissae 
            vectorized interface D01UAF
    non-adaptive integration over a finite interval D01BDF
    non-adaptive integration over a finite interval, 
        with provision for indefinite integrals also D01ARF
    reverse communication, 
        adaptive integration over a finite interval, 
            multiple integrands, 
                efficient on vector machines D01RAF
Service routines, 
    array size query for D01RAF D01RCF
    general option getting D01ZLF
    general option setting and initialization D01ZKF
Weights and abscissae for Gaussian quadrature rules, 
    more general choice of rule, 
        calculating the weights and abscissae D01BCF
    restricted choice of rule, 
        using pre-computed weights and abscissae D01TBF

6  Auxiliary Routines Associated with Library Routine Parameters

D01BAWnagf_quad_1d_gauss_hermite
See the description of the parameter D01XXX in D01BAF and D01BBF.
D01BAXnagf_quad_1d_gauss_laguerre
See the description of the parameter D01XXX in D01BAF and D01BBF.
D01BAYnagf_quad_1d_gauss_rational
See the description of the parameter D01XXX in D01BAF and D01BBF.
D01BAZnagf_quad_1d_gauss_legendre
See the description of the parameter D01XXX in D01BAF and D01BBF.
D01FDVnagf_quad_md_sphere_dummy_region
See the description of the parameter REGION in D01FDF.
D01RBMnagf_quad_d01rb_dummy
See the description of the parameter MONIT in D01RBF.

7  Routines Withdrawn or Scheduled for Withdrawal

The following lists all those routines that have been withdrawn since Mark 18 of the Library or are scheduled for withdrawal at one of the next two marks.
Withdrawn
Routine
Mark of
Withdrawal

Replacement Routine(s)
D01BAF26D01UAF
D01BBF26D01TBF
D01RBF27No replacement required

8  References

Davis P J and Rabinowitz P (1975) Methods of Numerical Integration Academic Press
Gonnet P (2010) Increasing the reliability of adaptive quadrature using explicit interpolants ACM Trans. Math. software 37 26
Lyness J N (1983) When not to use an automatic quadrature routine SIAM Rev. 25 63–87
Patterson T N L (1968) The Optimum addition of points to quadrature formulae Math. Comput. 22 847–856
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag
Sobol I M (1974) The Monte Carlo Method The University of Chicago Press
Stroud A H (1971) Approximate Calculation of Multiple Integrals Prentice–Hall
Wynn P (1956) On a device for computing the emSn transformation Math. Tables Aids Comput. 10 91–96

D01 Chapter Contents
D01 Chapter Introduction (PDF version)
NAG Library Manual

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