6.2: Composite Rules
( \newcommand{\kernel}{\mathrm{null}\,}\)
We now use our elementary formulas obtained for (6.2) to perform the integral given by (6.1)
6.2.1. Trapezoidal rule
We suppose that the function f(x) is known at the n+1 points labeled as x0,x1,…,xn, with the endpoints given by x0=a and xn=b. Define
fi=f(xi),hi=xi+1−xi
Then the integral of (6.1) may be decomposed as
∫baf(x)dx=n−1∑i=0∫xi+1xif(x)dx=n−1∑i=0∫hi0f(xi+s)ds
where the last equality arises from the change-of-variables s=x−xi. Applying the trapezoidal rule to the integral, we have
∫baf(x)dx=n−1∑i=0hi2(fi+fi+1)
If the points are not evenly spaced, say because the data are experimental values, then the hi may differ for each value of i and (6.6) is to be used directly.
However, if the points are evenly spaced, say because f(x) can be computed, we have hi=h, independent of i. We can then define
xi=a+ih,i=0,1,…,n
and since the end point b satisfies b=a+nh, we have
h=b−an
The composite trapezoidal rule for evenly space points then becomes
∫baf(x)dx=h2n−1∑i=0(fi+fi+1)=h2(f0+2f1+⋯+2fn−1+fn)
The first and last terms have a multiple of one; all other terms have a multiple of two; and the entire sum is multiplied by h/2.
6.2.2. Simpson’s rule
We here consider the composite Simpson’s rule for evenly space points. We apply Simpson’s rule over intervals of 2h, starting from a and ending at b :
∫baf(x)dx=h3(f0+4f1+f2)+h3(f2+4f3+f4)+…+h3(fn−2+4fn−1+fn)
Note that n must be even for this scheme to work. Combining terms, we have
∫baf(x)dx=h3(f0+4f1+2f2+4f3+2f4+⋯+4fn−1+fn)
The first and last terms have a multiple of one; the even indexed terms have a multiple of 2; the odd indexed terms have a multiple of 4; and the entire sum is multiplied by h/3.