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
D01ATF,
D01AUF and
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 particularly efficient when the evaluation can be performed in vector mode on a vector-processing machine.
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: A – REAL (KIND=nag_wp)Input
On entry: , the lower limit of integration.
- 2: B – 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: F – 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: X(NX) – REAL (KIND=nag_wp) arrayInput
On entry: the abscissae,
, for , at which function values are required.
- 2: NX – INTEGERInput
On entry: the number of abscissae at which a function value is required.
- 3: FV(NX) – REAL (KIND=nag_wp) arrayOutput
On exit:
FV must contain the values of the integrand
.
for all
.
- 4: IFLAG – INTEGERInput/Output
On entry: .
On exit: set to force an immediate exit with .
- 5: IUSER() – INTEGER arrayUser Workspace
- 6: RUSER() – 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: EPSABS – 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: EPSREL – 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: DINEST – REAL (KIND=nag_wp)Output
On exit: the estimate of the definite integral
F.
- 7: ERREST – REAL (KIND=nag_wp)Output
On exit: the error estimate of the definite integral
F.
- 8: NEVALS – INTEGEROutput
On exit: the number of function evaluations.
- 9: IUSER() – INTEGER arrayUser Workspace
- 10: RUSER() – 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: IFAIL – 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
.
-
Dynamic memory allocation failed.
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
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.
9 Example
9.1 Program Text
Program Text (d01rgfe.f90)
9.2 Program Data
None.
9.3 Program Results
Program Results (d01rgfe.r)