NAG Library Routine Document
D01RGF
1 Purpose
D01RGF is a general purpose integrator which calculates an approximation to the integral of a function
over a finite interval
:
The routine is suitable as a general purpose integrator, and can be used when the integrand has singularities and infinities. In particular, the routine can continue if the subroutine
F explicitly returns a quiet or signalling NaN or a signed infinity.
2 Specification
SUBROUTINE D01RGF ( |
A, B, F, EPSABS, EPSREL, DINEST, ERREST, NEVALS, IUSER, RUSER, IFAIL) |
INTEGER |
NEVALS, IUSER(*), IFAIL |
REAL (KIND=nag_wp) |
A, B, EPSABS, EPSREL, DINEST, ERREST, RUSER(*) |
EXTERNAL |
F |
|
3 Description
D01RGF uses the algorithm described in
Gonnet (2010). It is an adaptive algorithm, similar to the QUADPACK routine QAGS (see
Piessens et al. (1983), see also
D01RAF) but includes significant differences regarding how the integrand is represented, how the integration error is estimated and how singularities and divergent integrals are treated. The local error estimation is described in
Gonnet (2010).
D01RGF requires a subroutine to evaluate the integrand at an array of different points and is therefore amenable to parallel execution.
4 References
Gonnet P (2010) Increasing the reliability of adaptive quadrature using explicit interpolants ACM Trans. Math. software 37 26
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag
5 Parameters
- 1: – REAL (KIND=nag_wp)Input
-
On entry: , the lower limit of integration.
- 2: – REAL (KIND=nag_wp)Input
-
On entry:
, the upper limit of integration. It is not necessary that
.
Note: if , the routine will immediately return , and .
- 3: – SUBROUTINE, supplied by the user.External Procedure
-
F must return the value of the integrand
at a set of points.
The specification of
F is:
INTEGER |
NX, IFLAG, IUSER(*) |
REAL (KIND=nag_wp) |
X(NX), FV(NX), RUSER(*) |
|
- 1: – REAL (KIND=nag_wp) arrayInput
-
On entry: the abscissae,
, for , at which function values are required.
- 2: – INTEGERInput
-
On entry: the number of abscissae at which a function value is required.
- 3: – REAL (KIND=nag_wp) arrayOutput
-
On exit:
FV must contain the values of the integrand
.
for all
.
- 4: – INTEGERInput/Output
-
On entry: .
On exit: set to force an immediate exit with .
- 5: – INTEGER arrayUser Workspace
- 6: – REAL (KIND=nag_wp) arrayUser Workspace
-
F is called with the parameters
IUSER and
RUSER as supplied to D01RGF. You are free to use the arrays
IUSER and
RUSER to supply information to
F as an alternative to using COMMON global variables.
F must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D01RGF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 4: – REAL (KIND=nag_wp)Input
-
On entry: the absolute accuracy required.
If
EPSABS is negative,
is used. See
Section 7.
If , only the relative error will be used.
- 5: – REAL (KIND=nag_wp)Input
-
On entry: the relative accuracy required.
If
EPSREL is negative,
is used. See
Section 7.
If
, only the absolute error will be used otherwise the actual value of
EPSREL used by D01RGF is
.
Constraint:
at least one of
EPSABS and
EPSREL must be nonzero.
- 6: – REAL (KIND=nag_wp)Output
-
On exit: the estimate of the definite integral
F.
- 7: – REAL (KIND=nag_wp)Output
-
On exit: the error estimate of the definite integral
F.
- 8: – INTEGEROutput
-
On exit: the total number of points at which the integrand, , has been evaluated.
- 9: – INTEGER arrayUser Workspace
- 10: – REAL (KIND=nag_wp) arrayUser Workspace
-
IUSER and
RUSER are not used by D01RGF, but are passed directly to
F and may be used to pass information to this routine as an alternative to using COMMON global variables.
- 11: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction 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 parameters 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: D01RGF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
-
The requested accuracy was not achieved. Consider using larger values of
EPSABS and
EPSREL.
-
The integral is probably divergent or slowly convergent.
-
Both and .
-
Exit requested from
F with
.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
D01RGF cannot guarantee, but in practice usually achieves, the following accuracy:
where
and
EPSABS and
EPSREL are user-specified absolute and relative error tolerances. Moreover, it returns the quantity
ERREST which, in normal circumstances, satisfies
8 Parallelism and Performance
D01RGF is currently neither directly nor indirectly threaded. In particular, the user-supplied subroutine
F is not called from within a parallel region initialized inside D01RGF.
The user-supplied subroutine
F uses a vectorized interface, allowing for the required vector of function values to be evaluated in parallel; for example by placing appropriate OpenMP directives in the code for the user-supplied subroutine
F.
The time taken by D01RGF depends on the integrand and the accuracy required.
D01RGF is suitable for evaluating integrals that have singularities within the requested interval.
In particular, D01RGF accepts non-finite values on return from the user-supplied subroutine
F, and will adapt the integration rule accordingly to eliminate such points. Non-finite values include NaNs and infinities.
10 Example
10.1 Program Text
Program Text (d01rgfe.f90)
10.2 Program Data
None.
10.3 Program Results
Program Results (d01rgfe.r)