d01gac integrates a function which is specified numerically at four or more points, over the whole of its specified range, using third-order finite difference formulae with error estimates, according to a method due to Gill and Miller (1972).
The function may be called by the names: d01gac, nag_quad_dim1_data or nag_1d_quad_vals.
d01gac evaluates the definite integral
where the function is specified at the -points , which should be all distinct, and in either ascending or descending order. The integral between successive points is calculated by a four-point finite difference formula centred on the interval concerned, except in the case of the first and last intervals, where four-point forward and backward difference formulae respectively are employed. If is less than , the function fails. An approximation to the truncation error is integrated and added to the result. It is also returned separately to give an estimate of the uncertainty in the result. The method is due to Gill and Miller (1972).
Gill P E and Miller G F (1972) An algorithm for the integration of unequally spaced data Comput. J.15 80–83
1: – IntegerInput
On entry: , the number of points.
2: – const doubleInput
On entry: the values of the independent variable, i.e., the .
either or .
3: – const doubleInput
On entry: the values of the dependent variable
at the points , for .
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument had an illegal value.
On entry, .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL 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 CL Interface for further information.
The time taken by d01gac depends on the number of points supplied, .
In their paper, Gill and Miller (1972) do not add the quantity er to ans before return. However, extensive tests have shown that a dramatic reduction in the error often results from such addition. In other cases, it does not make an improvement, but these tend to be cases of low accuracy in which the modified answer is not significantly inferior to the unmodified one. You have the option of recovering the Gill–Miller answer by subtracting er from ans on return from the function.
This example evaluates the integral
reading in the function values at unequally spaced points.