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.
The routine may be called by the names d01rgf or nagf_quad_dim1_fin_gonnet_vec.
3Description
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.
4References
Gonnet P (2010) Increasing the reliability of adaptive quadrature using explicit interpolants ACM Trans. Math. software37 26
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag
5Arguments
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 with , and .
3: – Subroutine, supplied by the user.External Procedure
f must return the value of the integrand at a set of points.
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. nx will be of size equal to the number of Kronrod points in the quadrature rule used.
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 arguments iuser and ruser as supplied to d01rgf. You should use the arrays iuser and ruser to supply information to f.
f must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d01rgf is called. Arguments denoted as Input must not be changed by this procedure.
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.
11: – 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 d01rgf may return useful information.
The requested accuracy was not achieved. Consider using larger values of epsabs and epsrel.
The integral is probably divergent or slowly convergent.
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
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
8Parallelism 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.
9Further Comments
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.