d01rjc requires the user-supplied function
f to calculate a vector of abscissae at once
for greater efficiency and returns additional
information on the computation (in the arrays rinfo and iinfo
rather than previously).
The function may be called by the names: d01sjc, nag_quad_dim1_fin_gen or nag_1d_quad_gen_1.
3Description
d01sjc is based upon the QUADPACK routine QAGS (Piessens et al. (1983)). It is an adaptive function, using the Gauss 10-point and Kronrod 21-point rules. The algorithm, described by de Doncker (1978), incorporates a global acceptance criterion (as defined by Malcolm and Simpson (1976)) together with the -algorithm (Wynn (1956)) to perform extrapolation. The local error estimation is described by Piessens et al. (1983).
This function is suitable as a general purpose integrator, and can be used when the integrand has singularities, especially when these are of algebraic or logarithmic type.
This function requires you to supply a function to evaluate the integrand at a single point.
4References
de Doncker E (1978) An adaptive extrapolation algorithm for automatic integration ACM SIGNUM Newsl.13(2) 12–18
Malcolm M A and Simpson R B (1976) Local versus global strategies for adaptive quadrature ACM Trans. Math. Software1 129–146
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag
Wynn P (1956) On a device for computing the transformation Math. Tables Aids Comput.10 91–96
5Arguments
1: – function, supplied by the userExternal Function
f must return the value of the integrand at a given point.
On entry: the point at which the integrand must be evaluated.
2: – Nag_User *
Pointer to a structure of type Nag_User with the following member:
p – Pointer
On entry/exit: the pointer should be cast to the required type, e.g.,
struct user *s = (struct user *)comm → p, to obtain the original object's address with appropriate type. (See the argument comm below.)
Note:f should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d01sjc. If your code inadvertently does return any NaNs or infinities, d01sjc is likely to produce unexpected results.
2: – doubleInput
On entry: the lower limit of integration, .
3: – doubleInput
On entry: the upper limit of integration, . It is not necessary that .
4: – doubleInput
On entry: the absolute accuracy required. If epsabs is negative, the absolute value is used. See Section 7.
5: – doubleInput
On entry: the relative accuracy required. If epsrel is negative, the absolute value is used. See Section 7.
6: – IntegerInput
On entry: the upper bound on the number of sub-intervals into which the interval of integration may be divided by the function. The more difficult the integrand, the larger max_num_subint should be.
Constraint:
.
7: – double *Output
On exit: the approximation to the integral .
8: – double *Output
On exit: an estimate of the modulus of the absolute error, which should be an upper bound for .
9: – Nag_QuadProgress *
Pointer to structure of type Nag_QuadProgress with the following members:
num_subint – IntegerOutput
On exit: the actual number of sub-intervals used.
fun_count – IntegerOutput
On exit: the number of function evaluations performed by d01sjc.
sub_int_beg_pts – double *Output
sub_int_end_pts – double *Output
sub_int_result – double *Output
sub_int_error – double *Output
On exit: these pointers are allocated memory internally with max_num_subint elements. If an error exit other than NE_INT_ARG_LT or NE_ALLOC_FAIL occurs, these arrays will contain information which may be useful. For details, see Section 9.
Before a subsequent call to d01sjc is made, or when the information contained in these arrays is no longer useful, you should free the storage allocated by these pointers using the NAG macro NAG_FREE.
10: – Nag_User *
Pointer to a structure of type Nag_User with the following member:
p – Pointer
On entry/exit: the pointer , of type Pointer, allows you to communicate information to and from f(). An object of the required type should be declared, e.g., a structure, and its address assigned to the pointer by means of a cast to Pointer in the calling program, e.g., comm.p = (Pointer)&s. The type Pointer is void *.
11: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
Extremely bad integrand behaviour occurs around the sub-interval .
The same advice applies as in the case of NE_QUAD_MAX_SUBDIV.
NE_QUAD_MAX_SUBDIV
The maximum number of subdivisions has been reached: .
The maximum number of subdivisions has been reached without the accuracy requirements being achieved. Look at the integrand in order to determine the integration difficulties. If the position of a local difficulty within the interval can be determined (e.g., a singularity of the integrand or its derivative, a peak, a discontinuity, etc.) you will probably gain from splitting up the interval at this point and calling the integrator on the sub-intervals. If necessary, another integrator, which is designed for handling the type of difficulty involved, must be used. Alternatively, consider relaxing the accuracy requirements specified by epsabs and epsrel, or increasing the value of max_num_subint.
NE_QUAD_NO_CONV
The integral is probably divergent or slowly convergent.
Please note that divergence can occur with any error exit other than NE_INT_ARG_LT and NE_ALLOC_FAIL.
NE_QUAD_ROUNDOFF_EXTRAPL
Round-off error is detected during extrapolation.
The requested tolerance cannot be achieved, because the extrapolation does not increase the accuracy satisfactorily; the returned result is the best that can be obtained.
The same advice applies as in the case of NE_QUAD_MAX_SUBDIV.
NE_QUAD_ROUNDOFF_TOL
Round-off error prevents the requested tolerance from being achieved: , .
The error may be underestimated. Consider relaxing the accuracy requirements specified by epsabs and epsrel.
7Accuracy
d01sjc 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 abserr which, in normal circumstances, satisfies
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
d01sjc is not threaded in any implementation.
9Further Comments
The time taken by d01sjc depends on the integrand and the accuracy required.
If the function fails with an error exit other than NE_INT_ARG_LT or NE_ALLOC_FAIL, then you may wish to examine the contents of the structure qp. These contain the end-points of the sub-intervals used by d01sjc along with the integral contributions and error estimates over the sub-intervals.
Specifically, for , let denote the approximation to the value of the integral over the sub-interval in the partition of and be the corresponding absolute error estimate.
Then, and unless the function terminates while testing for divergence of the integral (see Section 3.4.3 of Piessens et al. (1983)). In this case, result (and abserr) are taken to be the values returned from the extrapolation process. The value of is returned in , and the values , , and are stored in the structure qp as