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


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++
static double d01ah(
	double a, 
	double b, 
	double epsr, 
	[OutAttribute] int% npts, 
	[OutAttribute] double% relerr, 
	D01..::..D01AH_F^ f, 
	int nlimit, 
	[OutAttribute] int% ifail
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 


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

A delegate of type D01AH_F.

Type: System..::..Int32
On entry: a limit to the number of function evaluations. If nlimit0, the method uses a default limit of 10000.
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.


d01ah computes a definite integral of the form
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.


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:
The integral has not converged to the accuracy requested. It may be worthwhile to try increasing nlimit.
Too many unsuccessful levels of subdivision have been invoked.
On entry,epsr0.0.
An error occured, see message report.
Negative dimension for array value
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.


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


Further Comments

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


This example evaluates the integral to a requested relative accuracy of 10-5 

Example program (C#): d01ahe.cs

Example program data: d01ahe.d

Example program results: d01ahe.r

See Also