d01ar computes definite and indefinite integrals over a finite range to a specified relative or absolute accuracy, using the method described in Patterson (1968).
Syntax
C# |
---|
public static void d01ar( double a, double b, D01..::..D01AR_FUN fun, double relacc, double absacc, int maxrul, int iparm, out double acc, out double ans, out int n, double[] alpha, out int ifail ) |
Visual Basic |
---|
Public Shared Sub d01ar ( _ a As Double, _ b As Double, _ fun As D01..::..D01AR_FUN, _ relacc As Double, _ absacc As Double, _ maxrul As Integer, _ iparm As Integer, _ <OutAttribute> ByRef acc As Double, _ <OutAttribute> ByRef ans As Double, _ <OutAttribute> ByRef n As Integer, _ alpha As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void d01ar( double a, double b, D01..::..D01AR_FUN^ fun, double relacc, double absacc, int maxrul, int iparm, [OutAttribute] double% acc, [OutAttribute] double% ans, [OutAttribute] int% n, array<double>^ alpha, [OutAttribute] int% ifail ) |
F# |
---|
static member d01ar : a : float * b : float * fun : D01..::..D01AR_FUN * relacc : float * absacc : float * maxrul : int * iparm : int * acc : float byref * ans : float byref * n : int byref * alpha : float[] * ifail : int byref -> unit |
Parameters
- a
- Type: System..::..DoubleOn entry: , the lower limit of integration.
- b
- Type: System..::..DoubleOn entry: , the upper limit of integration. It is not necessary that .
- fun
- Type: NagLibrary..::..D01..::..D01AR_FUNfun must return the value of the integrand at a specified point.
A delegate of type D01AR_FUN.
If , fun is not called.
- relacc
- Type: System..::..DoubleOn entry: the relative accuracy required. If convergence according to absolute accuracy is required, relacc should be set to zero (but see also [Accuracy]). If , its absolute value is used.If , relacc is not used.
- absacc
- Type: System..::..DoubleOn entry: the absolute accuracy required. If convergence according to relative accuracy is required, absacc should be set to zero (but see also [Accuracy]). If , its absolute value is used.If , absacc is not used.
- maxrul
- Type: System..::..Int32On entry: the maximum number of successive rules that may be used.
- iparm
- Type: System..::..Int32On entry: indicates the task to be performed by the method.
- Only the definite integral over is evaluated.
- As well as the definite integral, the expansion of the integrand in Legendre polynomials over is calculated, using the same values of the integrand as used to compute the integral. The expansion coefficients, and some other quantities, are returned in alpha for later use in computing indefinite integrals.
- is integrated analytically over using the previously computed expansion, stored in alpha. No further evaluations of the integrand are required. The method must previously have been called with and the interval must lie within that specified for the previous call. In this case only the arguments a, b, iparm, ans, alpha and ifail are used.
Constraint: , or .
- acc
- Type: System..::..Double%
- ans
- Type: System..::..Double%On exit: the estimated value of the integral.
- n
- Type: System..::..Int32%
- alpha
- Type: array<System..::..Double>[]()[][]An array of size []
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
d01ar evaluates definite and indefinite integrals of the form:
using the method described in Patterson (1968).
Definite Integrals
In this case d01ar must be called with . By linear transformation the integral is changed to
where
and is then approximated by an -point quadrature rule
where are the weights and are the abscissae.
The method uses a family of nine interlacing rules based on the optimal extension of the three-point Gauss rule. These rules use , , , , , , , and points and have respective polynomial integrating degrees , , , , , , , and . Each rule has the property that the next in sequence includes all the points of its predecessor and has the greatest possible increase in integrating degree.
The integration method is based on the successive application of these rules until the absolute value of the difference of two successive results differs by not more than absacc, or relatively by not more than relacc. The result of the last rule used is taken as the value of the integral (ans), and the absolute difference of the results of the last two rules used is taken as an estimate of the absolute error (acc). Due to their interlacing form no integrand evaluations are wasted in passing from one rule to the next.
Indefinite Integrals
Suppose the value of the integral
is required for a number of sub-intervals , all of which lie in an interval .
In this case d01ar should first be called with the parameter and the interval set to . The method then calculates the integral over and the Legendre expansion of the integrand, using the same integrand values. If the method is subsequently called with and the interval set to , the integral over is calculated by analytical integration of the Legendre expansion, without further evaluations of the integrand.
For the interval the expansion takes the form
where is the order Legendre polynomial. Assuming that the integral over the full range was evaluated to the required accuracy using an -point rule, then the coefficients
are evaluated by that same rule, up to
The accuracy for indefinite integration should be of the same order as that obtained for the definite integral over the full range. The indefinite integrals will be exact when is a polynomial of degree .
References
Patterson T N L (1968) The Optimum addition of points to quadrature formulae Math. Comput. 22 847–856
Error Indicators and Warnings
Note: d01ar may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
- If or , this indicates that all maxrul rules have been used and the integral has not converged to the accuracy requested. In this case ans contains the last approximation to the integral, and acc contains the difference between the last two approximations. To check this estimate of the integral, d01ar could be called again to evaluateIf , this indicates failure of convergence during the run with in which the Legendre expansion was created.
- On entry, , or
- The method is called with but a previous call with has been omitted or was invoked with an integration interval of length zero.
- On entry, with , the interval for indefinite integration is not contained within the interval specified when d01ar was previously called with .
Accuracy
The relative or absolute accuracy required is specified by you in the variables relacc or absacc. d01ar will terminate whenever either the relative accuracy specified by relacc or the absolute accuracy specified by absacc is reached. One or other of these criteria may be ‘forced’ by setting the parameter for the other to zero. If both relacc and absacc are specified as zero, then the method uses the value for relacc.
If on exit , then it is likely that the result is correct to one or other of these accuracies. If on exit , then it is likely that neither of the requested accuracies has been reached.
When you have no prior idea of the magnitude of the integral, it is possible that an unreasonable accuracy may be requested, e.g., a relative accuracy for an integral which turns out to be zero, or a small absolute accuracy for an integral which turns out to be very large. Even if failure is reported in such a case, the value of the integral may still be satisfactory. The device of setting the other ‘unused’ accuracy parameter to a small positive value (e.g., for an implementation of -digit precision) rather than zero, may prevent excessive calculation in such a situation.
To avoid spurious convergence, it is recommended that relative accuracies larger than about be avoided.
Parallelism and Performance
None.
Further Comments
The time taken by d01ar depends on the complexity of the integrand and the accuracy required.
This method uses the Patterson method over the whole integration interval and should therefore be suitable for well behaved functions. However, for very irregular functions it would be more efficient to submit the differently behaved regions separately for integration.
Example
This example evaluates the following integrals
(i) | Definite integral only for
|
||
(ii) | Definite integral together with expansion coefficients for
|
||
(iii) | Indefinite integral using previous expansion for
|