Loading [MathJax]/jax/output/HTML-CSS/jax.js
SciPy

This is documentation for an old release of SciPy (version 0.17.1). Read this page in the documentation of the latest stable release (version 1.15.1).

scipy.integrate.newton_cotes

scipy.integrate.newton_cotes(rn, equal=0)[source]

Return weights and error coefficient for Newton-Cotes integration.

Suppose we have (N+1) samples of f at the positions x_0, x_1, ..., x_N. Then an N-point Newton-Cotes formula for the integral between x_0 and x_N is:

xNx0f(x)dx=ΔxNi=0aif(xi)+BN(Δx)N+2fN+1(ξ)

where ξ[x0,xN] and Δx=xNx0N is the average samples spacing.

If the samples are equally-spaced and N is even, then the error term is BN(Δx)N+3fN+2(ξ).

Parameters:

rn : int

The integer order for equally-spaced data or the relative positions of the samples with the first sample at 0 and the last at N, where N+1 is the length of rn. N is the order of the Newton-Cotes integration.

equal : int, optional

Set to 1 to enforce equally spaced data.

Returns:

an : ndarray

1-D array of weights to apply to the function at the provided sample positions.

B : float

Error coefficient.

Notes

Normally, the Newton-Cotes rules are used on smaller integration regions and a composite rule is used to return the total integral.