NAG Library Routine Document
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.
|SUBROUTINE D01RGF (
||A, B, F, EPSABS, EPSREL, DINEST, ERREST, NEVALS, IUSER, RUSER, IFAIL)
||NEVALS, IUSER(*), IFAIL
||A, B, EPSABS, EPSREL, DINEST, ERREST, RUSER(*)
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
) 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.
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
- 1: A – REAL (KIND=nag_wp)Input
On entry: , the lower limit of integration.
- 2: B – REAL (KIND=nag_wp)Input
, 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
must return the value of the integrand
at a set of points.
The specification of F
||NX, IFLAG, IUSER(*)
||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
must contain the values of the integrand
- 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
is called with the parameters IUSER
as supplied to D01RGF. You are free to use the arrays IUSER
to supply information to F
as an alternative to using COMMON global variables.
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
be changed by this procedure.
- 4: EPSABS – REAL (KIND=nag_wp)Input
: the absolute accuracy required.
is used. See Section 7
If , only the relative error will be used.
- 5: EPSREL – REAL (KIND=nag_wp)Input
: the relative accuracy required.
is used. See Section 7
, only the absolute error will be used otherwise the actual value of EPSREL
used by D01RGF is
at least one of EPSABS
must be nonzero.
- 6: DINEST – REAL (KIND=nag_wp)Output
: the estimate of the definite integral F
- 7: ERREST – REAL (KIND=nag_wp)Output
: 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
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
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.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, 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
The integral is probably divergent or slowly convergent.
Both and .
Exit requested from F
Dynamic memory allocation failed.
D01RGF cannot guarantee, but in practice usually achieves, the following accuracy:
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.
This example computes
9.1 Program Text
Program Text (d01rgfe.f90)
9.2 Program Data
9.3 Program Results
Program Results (d01rgfe.r)