naginterfaces.library.quad.dim1_​indef

naginterfaces.library.quad.dim1_indef(a, b, f, relacc, absacc, maxrul, iparm, alpha, data=None)[source]

dim1_indef computes definite and indefinite integrals over a finite range to a specified relative or absolute accuracy, using the method described in Patterson (1968).

For full information please refer to the NAG Library document for d01ar

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/d01/d01arf.html

Parameters
afloat

, the lower limit of integration.

bfloat

, the upper limit of integration. It is not necessary that .

fcallable retval = f(x, data=None)

must return the value of the integrand at a given point.

Parameters
xfloat

The point in at which the integrand must be evaluated.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
retvalfloat

The value of evaluated at .

relaccfloat

The relative accuracy required. If convergence according to absolute accuracy is required, should be set to zero (but see also Accuracy). If , its absolute value is used.

If , is not used.

absaccfloat

The absolute accuracy required. If convergence according to relative accuracy is required, should be set to zero (but see also Accuracy). If , its absolute value is used.

If , is not used.

maxrulint

The maximum number of successive rules that may be used.

iparmint

Indicates the task to be performed by the function.

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 for later use in computing indefinite integrals.

is integrated analytically over using the previously computed expansion, stored in . No further evaluations of the integrand are required. The function must previously have been called with and the interval must lie within that specified for the previous call. In this case only the arguments , , , and are used.

alphafloat, array-like, shape

If , must contain the coefficients of the Legendre expansions of the integrand, as returned by a previous call of dim1_indef with and a range containing the present range.

If or , need not be set on entry.

dataarbitrary, optional

User-communication data for callback functions.

Returns
accfloat

If or , contains the absolute value of the difference between the last two successive estimates of the integral. This may be used as a measure of the accuracy actually achieved.

If , is not used.

ansfloat

The estimated value of the integral.

nint

When or , contains the number of integrand evaluations used in the calculation of the integral.

If , is not used.

alphafloat, ndarray, shape

If , the first elements of hold the coefficients of the Legendre expansion of the integrand, and the value of is stored in . must not be changed between a call with and subsequent calls with .

If , the first elements of are unchanged on exit.

Raises
NagValueError
(errno )

On entry, .

Constraint: , or .

(errno )

The function was called with , but a previous call with has been omitted, or made with zero integration interval.

(errno )

The function was called with , but the interval for indefinite integration is not contained within the interval specified in the previous call with .

Warns
NagAlgorithmicWarning
(errno )

All rules have been used but the integral has not converged to the accuracy requested. .

(errno )

Failure in convergence during the run with in which the Legendre expansion was created.

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

dim1_indef evaluates definite and indefinite integrals of the form:

using the method described in Patterson (1968).

Definite Integrals

In this case dim1_indef 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 function 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 , or relatively by not more than . The result of the last rule used is taken as the value of the integral (), and the absolute difference of the results of the last two rules used is taken as an estimate of the absolute error (). 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 dim1_indef should first be called with the argument and the interval set to . The function then calculates the integral over and the Legendre expansion of the integrand, using the same integrand values. If the function 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