Newton-Cotes Quadrature

Here we assume the $n+1$ sample points of the integrand $f(x)$ are equally spaced:

$\displaystyle x_{i+1}-x_i=h=\frac{b-a}{n},\;\;\;\;\;\;(i=0,\cdots,n-1)$ (28)

then we have $x_0=a,\;\;\;x_i=a+ih,\;\;\;x_n=a+nh=b$. We further introduce another variable $t$ so that $x=a+th$, and $dx=h\,dt,\;\;\;\;x-x_j=(t-j)h$, and the coefficients in Eq. (25) can be written as:
$\displaystyle c_i$ $\displaystyle =$ $\displaystyle \int_a^b\left(\prod_{j=0,\;j\ne i}^n
\frac{x-x_j}{x_i-x_j}\right)dx
=\int_0^n \left(\prod_{j=0,\;j\ne i}^n\frac{t-j}{i-j}\right)\,h\,dt$  
  $\displaystyle =$ $\displaystyle h\int_0^n \frac{\prod_{j=0,\;j\ne i}^n (t-j)}
{i(i-1)\cdots(i-i+1)\;(i-i-1)\cdots(i-n)} dt$  
  $\displaystyle =$ $\displaystyle h\;\frac{(-1)^{n-i}}{i!\,(n-i)!}\int_0^n
\frac{\prod_{j=0}^n(t-j)}{t-i}\;dt,\;\;\;\;\;\;(i=0,\cdots,n)$ (29)

These $n+1$ coefficients can be found by the following Matlab:

function c=coefs(n)
    syms x
    w=1;
    for i=0:n
        w=w*(x-i);
    end
    c=[];
    for i=0:n        
        f=w/(x-i);
        ci=int(f,[0,n])*(-1)^(n-i)/factorial(i)/factorial(n-i);
        c=[c ci];
    end
end

This integral of an nth-degree polynomial can be easily carried out. The quadrature rule based on such coefficients is called the Newton-Cotes formula:

$\displaystyle I_n[f]=\sum_{i=0}^n c_i\;f(x_i)=\sum_{i=0}^n c_i\;y_i$ (30)

As mentioned before, in general the degree of accuracy of $I_n[f]$ is at least $n$. We now further show that if the sample points are equally spaced and if $n$ is even, the degree of accuracy of $I_n[f]$ is at least $n+1$. Consider a polynomial integrand of degree $n+1$, e.g., $f(x)=x^{n+1}$. We have $f^{(n+1)}(x)=(n+1)!$ and the integration error is

$\displaystyle E_n[x^{n+1}]$ $\displaystyle =$ $\displaystyle \int_a^b R_n(x)dx=\frac{1}{(n+1)!}
\int_a^b f^{(n+1)}(\xi)\prod_{i=0}^n(x-x_i)dx$  
  $\displaystyle =$ $\displaystyle \int_a^b \prod_{i=0}^n(x-x_i)dx=h^{n+2}\int_0^n \prod_{i=0}^n(t-i)dt$ (31)

Since $n$ is even, $n/2$ is an integer. Introducing $u=t-n/2$, we further get

$\displaystyle E_n[x^{n+1}]=h^{n+2}\int_{-n/2}^{n/2} \prod_{i=0}^n(u-i+n/2)\, du
=h^{n+2}\int_{-n/2}^{n/2} \prod_{j=-n/2}^{n/2}(u-j)\, du=0$ (32)

The last equation is due to the fact that the integrand is an odd function of $u$. This result indicates that when $n$ is even, the degree of accuracy of $I_n[f]$ is at least $n+1$.

Given the integrand $f(x)$ and the quadrature rule, we need to further determine the specific integration error

$\displaystyle E_n[f]=\int_a^b R_n(x)\,dx
=\int_a^b\frac{f^{(n+1)}(\xi(x))}{(n+1)!}l_n(x)\,dx$ (33)

If $l_n(x)$ does not change sign in the interval $(a,\,b)$, we can further have

$\displaystyle E_n[f]=\frac{f^{(n+1)}(\eta)}{(n+1)!}\int_a^b l_n(x)\,dx$ (34)

according to the weighted mean-value theorem for integrals, where $\eta\in [a,\,b]$. However, if $l_n(x)$ does change signs in the interval, this result is not valid and we have to try some other method. In this case, we assume the integration error takes the form $E_n[f]=Kf^{(m+1)}(\eta)$, where $K$ is a constant independent of $f(x)$, if the degree of accuracy of $L_n(x)$ is $m$. This way, $E_n[x^k]=K\,(x^k)^{(m+1)}$ is zero if $k\le m$ but non-zero if $k>m$, i.e., the degree of accuracy of $L_n(x)$ is indeed $m$. Next, to find $K$, we let $f(x)=x^{m+1}$ with $f^{(m+1)}(x)=(m+1)!$, and get

$\displaystyle K=\frac{E_n[f]}{f^{(n+1)}(x)}=\frac{E_n[x^{m+1}]}{(x^{m+1})^{(m+1)}}
=\frac{E_n[x^{m+1}]}{(m+1)!}$ (35)

Now the integration error can be found to be

$\displaystyle E_n[f]=K f^{(m+1)}(\eta)
=\frac{f^{(m+1)}(\eta)}{(m+1)!}E_n[x^{m+1}]
=\frac{f^{(m+1)}(\eta)}{(m+1)!}\int_a^b l_m(x)dx$ (36)

The last equation is due to Eq. (?) in the previous section, where $E_n[x^{m+1}]$ can be found by either of two ways:
$\displaystyle E_n[x^{m+1}]$ $\displaystyle =$ $\displaystyle I[x^{m+1}]-I_n[x^{m+1}]$  
  $\displaystyle =$ $\displaystyle \int_a^b l_m(x)dx=\int_a^b \prod_{i=0}^m(x-x_i)\,dx
=h^{n+2}\int_0^n t(t-1)\cdots(t-m)\,dt$ (37)

In the following, we will consider the Newton-Cotes quadrature and its integration error for $n=1,\;2,\;3,\;4$.

The coefficients and integration errors for other quadrature rules with higher $n$ can be similarly obtained.

\begin{displaymath}\begin{array}{c\vert c\vert c\vert\vert r\vert r\vert r\vert ...
... 5/288 & 19 & 75 & 50 & 50 & 75 & 19 & & \\ \hline
\end{array}\end{displaymath}    

Example:

Here we consider the integral of the normal (Gaussian) distribution function with zero mean and unit standard deviation $\sigma=1$:

$\displaystyle \int_0^3 g(x)\,dx=\frac{1}{\sqrt{2\pi}}\int_0^3
\exp\left(-\frac{x^2}{2}\right)\,dx$ (68)

Twice of this value is the probability of $x$ taking a value within 3 standard deviations. This integral is carried out by each of the four methods with different truncation errors. We see that as $n$ increases, the error $E_n[g]$ reduces.

\begin{displaymath}\begin{array}{c\vert\vert c\vert c\vert c\vert c}\hline
n & 1...
....06e-01 & 3.79e-02 & 1.44e-02 & -2.35e-03 \\ \hline
\end{array}\end{displaymath} (69)

QuadratureExample1.png