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 _ )
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 )
- Type: System..::..DoubleOn entry: , the lower limit of integration.
- Type: System..::..DoubleOn entry: , the upper limit of integration. It is not necessary that .
- 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.
- Type: System..::..Double
- Type: System..::..Double
- Type: System..::..Int32On entry: the maximum number of successive rules that may be used.
- Type: System..::..Int32On entry: indicates the task to be performed by the method.
Constraint: , or .
- 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.
- Type: System..::..Double%
- Type: System..::..Double%On exit: the estimated value of the integral.
- Type: System..::..Int32%
- Type: array<System..::..Double>()An array of size On entry: if , alpha must contain the coefficients of the Legendre expansions of the integrand, as returned by a previous call of d01ar with and a range containing the present range.If or , alpha need not be set on entry.
d01ar evaluates definite and indefinite integrals of the form:
using the method described in Patterson (1968).
In this case d01ar must be called with . By linear transformation the integral is changed to
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.
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 .
Patterson T N L (1968) The Optimum addition of points to quadrature formulae Math. Comput. 22 847–856
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 .
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.
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.
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