d01gaf 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 routine may be called by the names d01gaf or nagf_quad_dim1_data.
d01gaf 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 routine 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: – Real (Kind=nag_wp) arrayInput
On entry: the values of the independent variable, i.e., the .
either or .
2: – Real (Kind=nag_wp) arrayInput
On entry: the values of the dependent variable
at the points , for .
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. 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: no error is reported arising from the relative magnitudes of ans and er on return, due to the difficulty when the true answer is zero.
On entry, .
On entry, and , , and .
Constraint: either or .
On entry, , and .
An unexpected error has been triggered by this routine. Please
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.
No accuracy level is specified by you before calling d01gaf but on return the absolute value of er is an approximation to, but not necessarily a bound for, . If on exit , both ans and er are returned as zero.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
d01gaf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
The time taken by d01gaf 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 routine.
This example evaluates the integral
reading in the function values at unequally spaced points.