d01eaf computes approximations to the integrals of a vector of similar functions, each defined over the same multidimensional hyper-rectangular region. The routine uses an adaptive subdivision strategy, and also computes absolute error estimates.
Upon entry, unless mincls has been set to a value less than or equal to , d01eaf divides the integration region into a number of subregions with randomly selected volumes. Inside each subregion the integrals and their errors are estimated. The initial number of subregions is chosen to be as large as possible without using more than mincls calls to funsub. The results are stored in a partially ordered list (a heap). The routine then proceeds in stages. At each stage the subregion with the largest error (measured using the maximum norm) is halved along the coordinate axis where the integrands have largest absolute fourth differences. The basic rule is applied to each half of this subregion and the results are stored in the list. The results from the two halves are used to update the global integral and error estimates (finest and absest) and the routine continues unless where the norm is the maximum norm, or further subdivision would use more than maxcls calls to funsub. If at some stage there is insufficient working storage to keep the results for the next subdivision, the routine switches to a less efficient mode; only if this mode of operation breaks down is insufficient storage reported.
4References
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
5Arguments
1: – IntegerInput
On entry: , the number of dimensions of the integrals.
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 either to the minimum number of funsub calls to be allowed, in which case or to a negative value. In this case, the routine continues the calculation started in a previous call with the same integrands and integration limits: no arguments other than mincls, maxcls, absreq, relreq or ifail must be changed between the calls.
On exit: gives the number of funsub calls actually used by d01eaf. For the continuation case ( on entry) this is the number of new funsub calls on the current call to d01eaf.
5: – IntegerInput
On entry: the maximum number of funsub calls to be allowed. In the continuation case this is the number of new funsub calls to be allowed.
Constraints:
;
;
.
6: – IntegerInput
On entry: , the number of integrands.
Constraint:
.
7: – Subroutine, supplied by the user.External Procedure
funsub must evaluate the integrands at a given point.
On entry: , the number of dimensions of the integrals.
2: – Real (Kind=nag_wp) arrayInput
On entry: the coordinates of the point at which the integrands must be evaluated.
3: – IntegerInput
On entry: , the number of integrands.
4: – Real (Kind=nag_wp) arrayOutput
On exit: the value of the th integrand at the given point.
funsub must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d01eaf is called. Arguments denoted as Input must not be changed by this procedure.
Note:funsub should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d01eaf. If your code inadvertently does return any NaNs or infinities, d01eaf is likely to produce unexpected results.
8: – Real (Kind=nag_wp)Input
On entry: the absolute accuracy required by you.
Constraint:
.
9: – Real (Kind=nag_wp)Input
On entry: the relative accuracy required by you.
Constraint:
.
10: – IntegerInput
On entry: the dimension of the array wrkstr as declared in the (sub)program from which d01eaf is called.
Suggested value:
, where is the value of maxcls and is defined under maxcls. If lenwrk is significantly smaller than this, the routine will not work as efficiently and may even fail.
Constraint:
.
11: – Real (Kind=nag_wp) arrayInput/Output
On entry: if , wrkstr must be unchanged from the previous call of d01eaf.
On exit: contains information about the current subdivision which could be used in a continuation call.
12: – Real (Kind=nag_wp) arrayOutput
On exit: specifies the best estimate obtained from the th integral, for .
13: – Real (Kind=nag_wp) arrayOutput
On exit: specifies the estimated absolute accuracy of , for .
14: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended since useful values can be provided in some output arguments even when on exit. When the value or 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).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
Note: in some cases d01eaf may return useful information.
On entry, lenwrk is too small. . Minimum possible dimension: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
An absolute error estimate for each integrand is output in the array absest. The routine exits with if
8Parallelism and Performance
d01eaf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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.
9Further Comments
Usually the running time for d01eaf will be dominated by the time in funsub, so the maximum time that could be used by d01eaf will be proportional to maxcls multiplied by the cost of a call to funsub.
On a normal call, you should set on entry.
For some integrands, particularly those that are poorly behaved in a small part of the integration region, d01eaf may terminate prematurely with values of absest that are significantly smaller than the actual absolute errors. This behaviour should be suspected if the returned value of mincls is small relative to the expected difficulty of the integrals. When this occurs d01eaf should be called again, but with an entry value of , (see specification of maxcls) and the results compared with those from the previous call.
If the routine is called with , the exact values of finest and absest on return will depend (within statistical limits) on the sequence of random numbers generated internally within d01eaf by calls to g05saf. Separate runs will produce identical answers unless the part of the program executed prior to calling d01eaf also calls (directly or indirectly) routines from Chapter G05, and, in addition, the series of such calls differs between runs.
Because of moderate instability in the application of the basic integration rule, approximately the last decimal digits may be inaccurate when using d01eaf for large values of .
10Example
This example computes
where , . The program is intended to show how to exploit the continuation facility provided with d01eaf: the routine exits with (printing an explanatory error message) and is re-entered with maxcls reset to a larger value. The program can be used with any values of ndim and nfun, except that the expression for must be changed if (see specification of maxcls).