The Newton-Cotes quadrature rules estimate the integral of a function over the integral interval based on an nth-degree interpolation polynomial as an approximation of , based on a set of points. To achieve higher accuracy, we need to increase the number of sample points to reduce the step size , i.e., we need to use a higher degree polynomial to approximate . However, due to Runge's phenomenon, a high degree interpolation polynomial tends to result in oscillation at the edges of an interval and thereby causing large error.
The figure below shows the approximation of the sinc function by an nth-degree polynomials with . Note that when is too low, the approximation is poor, but when is too high, Runge's phenonmenon is observed.
To avoid this problem, the composite quadrature rules can be used, which subdivides the entire integral interval into a set of subintervals each of size between every two consecutive sample points in , and estimates as the sum of of the integrals over all such subintervals, each obtained by Newton-Cotes quadrature in Eq. (30) using a low-degree polynomial of degree based on subsample points in each subinterval (sharing the two end points with neighboring subintervals):
(70) |
(72) |
(73) |
(74) |
(75) |
(76) |
The Matlab function below estimates the integral of a given function in interval by composite quadrature of degree :
function CompositeQuadrature(f,a,b,n,N) h=(b-a)/N; % length of each of the N subintervals for n=1:4 % for each of the n polynomials I=0; c=coefs(n); % quadrature coefficients of the nth polynomial for i=0:N-1 % for each of N intervals j=a+i*h; % starting point for the ith interval for m=0:n % add each of the n terms I(n)=I(n)+c(m+1)*f(j+m*h/n); end end I=h*I/n; fprintf('n=%d\tI=%f\n',n,I); end end
Example: Reconsider the integral in the previous example:
(77) |
Taylor expansion of around the middle point between and :
(78) |