d01ah computes a definite integral over a finite range to a specified relative accuracy using a method described by Patterson.

Syntax

C#
public static double d01ah(
	double a,
	double b,
	double epsr,
	out int npts,
	out double relerr,
	D01..::..D01AH_F f,
	int nlimit,
	out int ifail
)
Visual Basic
Public Shared Function d01ah ( _
	a As Double, _
	b As Double, _
	epsr As Double, _
	<OutAttribute> ByRef npts As Integer, _
	<OutAttribute> ByRef relerr As Double, _
	f As D01..::..D01AH_F, _
	nlimit As Integer, _
	<OutAttribute> ByRef ifail As Integer _
) As Double
Visual C++
public:
static double d01ah(
	double a, 
	double b, 
	double epsr, 
	[OutAttribute] int% npts, 
	[OutAttribute] double% relerr, 
	D01..::..D01AH_F^ f, 
	int nlimit, 
	[OutAttribute] int% ifail
)
F#
static member d01ah : 
        a : float * 
        b : float * 
        epsr : float * 
        npts : int byref * 
        relerr : float byref * 
        f : D01..::..D01AH_F * 
        nlimit : int * 
        ifail : int byref -> float 

Parameters

a
Type: System..::..Double
On entry: a, the lower limit of integration.
b
Type: System..::..Double
On entry: b, the upper limit of integration. It is not necessary that a<b.
epsr
Type: System..::..Double
On entry: the relative accuracy required.
Constraint: epsr>0.0.
npts
Type: System..::..Int32%
On exit: the number of function evaluations used in the calculation of the integral.
relerr
Type: System..::..Double%
On exit: a rough estimate of the relative error achieved.
f
Type: NagLibrary..::..D01..::..D01AH_F
f must return the value of the integrand f at a given point.

A delegate of type D01AH_F.

nlimit
Type: System..::..Int32
On entry: a limit to the number of function evaluations. If nlimit0, the method uses a default limit of 10000.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Return Value

d01ah computes a definite integral over a finite range to a specified relative accuracy using a method described by Patterson.

Description

d01ah computes a definite integral of the form
abfxdx.
The method uses as its basis a family of interlacing high precision rules (see Patterson (1968)) using 1, 3, 7, 15, 31, 63, 127 and 255 nodes. Initially the family is applied in sequence to the integrand. When two successive rules differ relatively by less than the required relative accuracy, the last rule used is taken as the value of the integral and the operation is regarded as successful. If all rules in the family have been applied unsuccessfully, subdivision is invoked. The subdivision strategy is as follows. The interval under scrutiny is divided into two sub-intervals (not always equal). The basic family is then applied to the first sub-interval. If the required accuracy is not obtained, the interval is stored for future examination (see ifail=2) and the second sub-interval is examined. Should the basic family again be unsuccessful, then the sub-interval is further subdivided and the whole process repeated. Successful integrations are accumulated as the partial value of the integral. When all possible successful integrations have been completed, those previously unsuccessful sub-intervals placed in store are examined.
A large number of refinements are incorporated to improve the performance. Some of these are:
(a) The rate of convergence of the basic family is monitored and used to make a decision to abort and subdivide before the full sequence has been applied.
(b) The ε-algorithm is applied to the basic results in an attempt to increase the convergence rate. See Wynn (1956).
(c) An attempt is made to detect sharp end point peaks and singularities in each sub-interval and to apply appropriate transformations to smooth the integrand. This consideration is also used to select interval sizes in the subdivision process.
(d) The relative accuracy sought in each sub-interval is adjusted in accordance with its likely contribution to the total integral.
(e) Random transformations of the integrand are applied to improve reliability in some instances.

References

Patterson T N L (1968) The Optimum addition of points to quadrature formulae Math. Comput. 22 847–856
Wynn P (1956) On a device for computing the emSn transformation Math. Tables Aids Comput. 10 91–96

Error Indicators and Warnings

Note: d01ah may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
ifail=1
The integral has not converged to the accuracy requested. It may be worthwhile to try increasing nlimit.
ifail=2
Too many unsuccessful levels of subdivision have been invoked.
ifail=3
On entry,epsr0.0.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value
When ifail=1 or 2 a result may be obtained by continuing without further subdivision, but this is likely to be inaccurate.

Accuracy

The relative accuracy required is specified by you in the variable epsr. The method will terminate whenever the relative accuracy specified by epsr is judged to have been reached.
If on exit, ifail=0, then it is most likely that the result is correct to the specified accuracy. If, on exit, ifail=1 or 2, then it is likely that the specified accuracy has not been reached.
relerr is a rough estimate of the relative error achieved. It is a by-product of the computation and is not used to effect the termination of the method. The outcome of the integration must be judged by the value of ifail.

Parallelism and Performance

None.

Further Comments

The time taken by d01ah depends on the complexity of the integrand and the accuracy required.

Example

This example evaluates the integral to a requested relative accuracy of 10-5 
0141+x2dx=π.

Example program (C#): d01ahe.cs

Example program data: d01ahe.d

Example program results: d01ahe.r

See Also