hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_quad_md_adapt (d01fc)

Purpose

nag_quad_md_adapt (d01fc) attempts to evaluate a multidimensional integral (up to 1515 dimensions), with constant and finite limits, to a specified relative accuracy, using an adaptive subdivision strategy.

Syntax

[minpts, acc, finval, ifail] = d01fc(a, b, minpts, maxpts, functn, eps, 'ndim', ndim)
[minpts, acc, finval, ifail] = nag_quad_md_adapt(a, b, minpts, maxpts, functn, eps, 'ndim', ndim)

Description

nag_quad_md_adapt (d01fc) returns an estimate of a multidimensional integral over a hyper-rectangle (i.e., with constant limits), and also an estimate of the relative error. You set the relative accuracy required, return values for the integrand via a function argument functn, and also set the minimum and maximum acceptable number of calls to functn (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 functn 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 functn have been made; or, if the amount lenwrk of working storage is insufficient. A formula for the recommended value of lenwrk is given in Section [Parameters]. If a smaller value is used, and is exhausted in the course of execution, the function switches to a less efficient mode of operation; only if this mode also breaks down is insufficient storage reported.
nag_quad_md_adapt (d01fc) is based on the HALF function developed by van Dooren and de Ridder (1976). It uses a different basic rule, described in Genz and Malik (1980).

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

Parameters

Compulsory Input Parameters

1:     a(ndim) – double array
ndim, the dimension of the array, must satisfy the constraint 2ndim152ndim15.
The lower limits of integration, aiai, for i = 1,2,,ni=1,2,,n.
2:     b(ndim) – double array
ndim, the dimension of the array, must satisfy the constraint 2ndim152ndim15.
The upper limits of integration, bibi, for i = 1,2,,ni=1,2,,n.
3:     minpts – int64int32nag_int scalar
Must be set to the minimum number of integrand evaluations to be allowed.
4:     maxpts – int64int32nag_int scalar
The maximum number of integrand evaluations to be allowed.
Constraints:
5:     functn – function handle or string containing name of m-file
functn must return the value of the integrand ff at a given point.
[result] = functn(ndim, z)

Input Parameters

1:     ndim – int64int32nag_int scalar
nn, the number of dimensions of the integral.
2:     z(ndim) – double array
The coordinates of the point at which the integrand ff must be evaluated.

Output Parameters

1:     result – double scalar
The result of the function.
6:     eps – double scalar
The relative error acceptable to you. 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 for the error exit ifail = 2ifail=2.
Constraint: eps > 0.0eps>0.0.

Optional Input Parameters

1:     ndim – int64int32nag_int scalar
Default: The dimension of the arrays a, b. (An error is raised if these dimensions are not equal.)
nn, the number of dimensions of the integral.
Constraint: 2ndim152ndim15.

Input Parameters Omitted from the MATLAB Interface

lenwrk wrkstr

Output Parameters

1:     minpts – int64int32nag_int scalar
Contains the actual number of integrand evaluations used by nag_quad_md_adapt (d01fc).
2:     acc – double scalar
The estimated relative error in finval.
3:     finval – double scalar
The best estimate obtained for the integral.
4:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_quad_md_adapt (d01fc) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,ndim < 2ndim<2,
orndim > 15ndim>15,
ormaxpts is too small,
orlenwrk < 2 × ndim + 4lenwrk<2×ndim+4,
oreps0.0eps0.0.
W ifail = 2ifail=2
maxpts was too small to obtain the required relative accuracy eps. On soft failure, finval and acc contain estimates of the integral and the relative error, but acc will be greater than eps.
W ifail = 3ifail=3
lenwrk was too small. On soft failure, finval and acc contain estimates of the integral and the relative error, but acc will be greater than eps.

Accuracy

A relative error estimate is output through the parameter acc.

Further Comments

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

Example

This example estimates the integral
1111
( 4 z1 z32 exp(2z1z3) )/((1 + z2 + z4)2)dz4dz3dz2dz1 = 0.575364.
0000
01 01 01 01 4 z1 z32 exp( 2 z1 z3 ) ( 1+ z2+ z4 ) 2 dz4 dz3 dz2 dz1 = 0.575364 .
The accuracy requested is one part in 1000010000.
function nag_quad_md_adapt_example
a = [0;
     0;
     0;
     0];
b = [1;
     1;
     1;
     1];
minpts = int64(0);
maxpts = int64(8000);
epsilon = 0.0001;
[minptsOut, acc, finval, ifail] = nag_quad_md_adapt(a, b, minpts, maxpts, @functn, epsilon)

function result = functn(ndim,z)
  result = 4.0*z(1)*z(3)*z(3)*exp(2.0*z(1)*z(3))/(1.0+z(2)+z(4))^2;
 

minptsOut =

                 2223


acc =

   9.8932e-05


finval =

    0.5754


ifail =

                    0


function d01fc_example
a = [0;
     0;
     0;
     0];
b = [1;
     1;
     1;
     1];
minpts = int64(0);
maxpts = int64(8000);
epsilon = 0.0001;
[minptsOut, acc, finval, ifail] = d01fc(a, b, minpts, maxpts, @functn, epsilon)

function result = functn(ndim,z)
  result = 4.0*z(1)*z(3)*z(3)*exp(2.0*z(1)*z(3))/(1.0+z(2)+z(4))^2;
 

minptsOut =

                 2223


acc =

   9.8932e-05


finval =

    0.5754


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013