nag_multid_quad_adapt_1 (d01wcc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_multid_quad_adapt_1 (d01wcc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_multid_quad_adapt_1 (d01wcc) attempts to evaluate a multidimensional integral (up to 15 dimensions), with constant and finite limits,
a 1 b 1 a 2 b 2 a n b n f x 1 , x 2 , , x n dxn dx2 dx1
to a specified relative accuracy, using an adaptive subdivision strategy.

2  Specification

#include <nag.h>
#include <nagd01.h>
void  nag_multid_quad_adapt_1 (Integer ndim,
double (*f)(Integer ndim, const double x[], Nag_User *comm),
const double a[], const double b[], Integer *minpts, Integer maxpts, double eps, double *finval, double *acc, Nag_User *comm, NagError *fail)

3  Description

nag_multid_quad_adapt_1 (d01wcc) evaluates an estimate of a multidimensional integral over a hyper-rectangle (i.e., with constant limits), and also an estimate of the relative error. You will need to set the relative accuracy required, supply the integrand as a function f, and also set the minimum and maximum acceptable number of calls to f (in minpts and maxpts).
The function operates by repeated subdivision of the hyper-rectangular region into smaller hyper-rectangles. In each subregion, the integral is estimated using a seventh-degree rule, and an error estimate is obtained by comparison with a fifth-degree rule which uses a subset of the same points. The fourth differences of the integrand along each coordinate axis are evaluated, and the subregion is marked for possible future subdivision in half along that coordinate axis which has the largest absolute fourth difference.
If the estimated errors, totalled over the subregions, exceed the requested relative error (or if fewer than minpts calls to f have been made), further subdivision is necessary, and is performed on the subregion with the largest estimated error, that subregion being halved along the appropriate coordinate axis.
The function will fail if the requested relative error level has not been attained by the time maxpts calls to f have been made.
This function is based on the HALF subroutine developed by van Dooren and de Ridder (1976). It uses a different basic rule, described by Genz and Malik (1980).

4  References

Genz A C and Malik A A (1980) An adaptive algorithm for numerical integration over an N-dimensional rectangular region J. Comput. Appl. Math. 6 295–302
van Dooren P and de Ridder L (1976) An adaptive algorithm for numerical integration over an N-dimensional cube J. Comput. Appl. Math. 2 207–217

5  Arguments

1:     ndimIntegerInput
On entry: the number of dimensions of the integral, n .
Constraint: 2 ndim 15 .
2:     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 (Integer ndim, const double x[], Nag_User *comm)
1:     ndimIntegerInput
On entry: the number of dimensions of the integral.
2:     x[ndim]const doubleInput
On entry: the coordinates of the point at which the integrand must be evaluated.
3:     commNag_User *
Pointer to a structure of type Nag_User with the following member:
pPointer 
On entry/exit: the pointer commp  should be cast to the required type, e.g., struct user *s = (struct user *)comm → p, to obtain the original object's address with appropriate type. (See the argument comm below.)
3:     a[ndim]const doubleInput
On entry: the lower limits of integration, a i , for i=1,2,,n.
4:     b[ndim]const doubleInput
On entry: the upper limits of integration, b i , for i=1,2,,n.
5:     minptsInteger *Input/Output
On entry: minpts must be set to the minimum number of integrand evaluations to be allowed.
On exit: minpts contains the actual number of integrand evaluations used by this function.
6:     maxptsIntegerInput
On entry: the maximum number of integrand evaluations to be allowed.
Constraints:
  • maxptsminpts ;
  • maxpts 2 ndim + 2 × ndim 2 + 2 × ndim + 1 .
7:     epsdoubleInput
On entry: the relative error acceptable. When the solution is zero or very small relative accuracy may not be achievable but you may still set eps to a reasonable value and check fail for NE_QUAD_MAX_INTEGRAND_EVAL.
Constraint: eps>0.0 .
8:     finvaldouble *Output
On exit: the best estimate obtained for the integral.
9:     accdouble *Output
On exit: the estimated relative error in finval.
10:   commNag_User *
Pointer to a structure of type Nag_User with the following member:
pPointer 
On entry/exit: the pointer commp, of type Pointer, allows you to communicate information to and from f(). An object of the required type should be declared, e.g., a structure, and its address assigned to the pointer commp by means of a cast to Pointer in the calling program, e.g., comm.p = (Pointer)&s. The type pointer will be void * with a C compiler that defines void * and char * otherwise.
11:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, maxpts=value  while minpts=value . These arguments must satisfy maxptsminpts .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_INVALID_INT_RANGE_2
Value value given to ndim not valid. Correct range is 2 ndim 15 .
NE_QUAD_MAX_INTEGRAND_CONS
maxpts<value . Constraint: maxpts 2 ndim + 2 × ndim 2 + 2 × ndim + 1 .
NE_QUAD_MAX_INTEGRAND_EVAL
maxpts was too small to obtain the required accuracy. On return, finval and acc contain estimates of the integral and the relative error, but acc will be greater than eps.
NE_REAL_ARG_LE
On entry, eps must not be less than or equal to 0.0: eps=value .

7  Accuracy

A relative error estimate is output through the argument acc.

8  Parallelism and Performance

Not applicable.

9  Further Comments

Execution time will usually be dominated by the time taken to evaluate the integrand f, and hence the maximum time that could be taken will be proportional to maxpts.

10  Example

This example estimates the integral
0 1 0 1 0 1 0 1 4 z 1 z 3 2 exp 2 z 1 z 3 1 + z 2 + z 4 2 dz4 dz3 dz2 dz1 = 0.575364 .
The accuracy requested is one part in 10,000.

10.1  Program Text

Program Text (d01wcce.c)

10.2  Program Data

None.

10.3  Program Results

Program Results (d01wcce.r)


nag_multid_quad_adapt_1 (d01wcc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG Library Manual

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