NAG Library Routine Document
d01fcf (md_adapt)
1
Purpose
d01fcf attempts to evaluate a multidimensional integral (up to dimensions), with constant and finite limits, to a specified relative accuracy, using an adaptive subdivision strategy.
2
Specification
Fortran Interface
Subroutine d01fcf ( |
ndim, a, b, minpts, maxpts, functn, eps, acc, lenwrk, wrkstr, finval, ifail) |
Integer, Intent (In) | :: | ndim, maxpts, lenwrk | Integer, Intent (Inout) | :: | minpts, ifail | Real (Kind=nag_wp), External | :: | functn | Real (Kind=nag_wp), Intent (In) | :: | a(ndim), b(ndim), eps | Real (Kind=nag_wp), Intent (Out) | :: | acc, wrkstr(lenwrk), finval |
|
C Header Interface
#include <nagmk26.h>
void |
d01fcf_ (const Integer *ndim, const double a[], const double b[], Integer *minpts, const Integer *maxpts, double (NAG_CALL *functn)(const Integer *ndim, const double z[]), const double *eps, double *acc, const Integer *lenwrk, double wrkstr[], double *finval, Integer *ifail) |
|
3
Description
d01fcf 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 routine argument
functn, and also set the minimum and maximum acceptable number of calls to
functn (in
minpts and
maxpts).
The routine 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 routine 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 5. If a smaller value is used, and is exhausted in the course of execution, the routine switches to a less efficient mode of operation; only if this mode also breaks down is insufficient storage reported.
d01fcf is based on the HALF subroutine developed by
van Dooren and de Ridder (1976). It uses a different basic rule, described in
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: – IntegerInput
-
On entry: , the number of dimensions of the integral.
Constraint:
.
- 2: – Real (Kind=nag_wp) arrayInput
-
On entry: the lower limits of integration,
, for .
- 3: – Real (Kind=nag_wp) arrayInput
-
On entry: the upper limits of integration,
, for .
- 4: – IntegerInput/Output
-
On entry: must be set to the minimum number of integrand evaluations to be allowed.
On exit: contains the actual number of integrand evaluations used by d01fcf.
- 5: – IntegerInput
-
On entry: the maximum number of integrand evaluations to be allowed.
Constraints:
- ;
- , where .
- 6: – real (Kind=nag_wp) Function, supplied by the user.External Procedure
-
functn must return the value of the integrand
at a given point.
The specification of
functn is:
Fortran Interface
Function functn ( |
ndim, z) |
Real (Kind=nag_wp) | :: | functn | Integer, Intent (In) | :: | ndim | Real (Kind=nag_wp), Intent (In) | :: | z(ndim) |
|
C Header Interface
#include <nagmk26.h>
double |
functn (const Integer *ndim, const double z[]) |
|
- 1: – IntegerInput
-
On entry: , the number of dimensions of the integral.
- 2: – Real (Kind=nag_wp) arrayInput
-
On entry: the coordinates of the point at which the integrand must be evaluated.
functn must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
d01fcf is called. Arguments denoted as
Input must
not be changed by this procedure.
Note: functn should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by
d01fcf. If your code inadvertently
does return any NaNs or infinities,
d01fcf is likely to produce unexpected results.
- 7: – Real (Kind=nag_wp)Input
-
On entry: 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
.
Constraint:
.
- 8: – Real (Kind=nag_wp)Output
-
On exit: the estimated relative error in
finval.
- 9: – IntegerInput
-
On entry: the dimension of the array
wrkstr as declared in the (sub)program from which
d01fcf is called.
Suggested value:
for maximum efficiency,
(see argument
maxpts for
).
If
lenwrk is less than this,
d01fcf will usually run less efficiently and may fail.
Constraint:
.
- 10: – Real (Kind=nag_wp) arrayWorkspace
-
- 11: – Real (Kind=nag_wp)Output
-
On exit: the best estimate obtained for the integral.
- 12: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if
on exit, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Note: d01fcf may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry,
lenwrk is too small.
. Minimum possible dimension:
.
On entry,
maxpts is too small.
. Minimum possible dimension:
.
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
-
maxpts too small to obtain requested accuracy
eps:
and
.
-
lenwrk was too small to complete computation.
finval and
acc contain estimates of integral and relative error, but
acc is greater than
eps.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
A relative error estimate is output through the argument
acc.
8
Parallelism and Performance
d01fcf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
d01fcf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
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.
10
Example
This example estimates the integral
The accuracy requested is one part in .
10.1
Program Text
Program Text (d01fcfe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (d01fcfe.r)