Simpson's rule
|
In numerical analysis, Simpson's rule (named after Thomas Simpson) is a way to get an approximation of an integral:
- <math> \int_{a}^{b} f(x) dx<math>
Contents |
Basics
Simpson's rule works by approximating <math>f(x)<math> by the quadratic polynomial <math>P(x)<math> which takes the same values as <math>f(x)<math> at a, b, and the midpoint m=(a+b)/2. One can use Lagrange polynomial interpolation to find an expression for this polynomial,
- <math>P(x)=f(a)\frac{(x-m)(x-b)}{(a-m)(a-b)}+
f(m)\frac{(x-a)(x-b)}{(m-a)(m-b)}+ f(b)\frac{(x-a)(x-m)}{(b-a)(b-m)} <math>.
Simpson's rule then follows by an easy (albeit tedious) calculation:
- <math> \int_{a}^{b} f(x) dx\approx \int_{a}^{b} P(x) dx =\frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right].<math>
Simpsons_method_illustration.png
The error in approximating an integral by Simpson's rule is
- <math>-\frac{h^5}{90}f^{(4)}(\xi),<math>
with <math>h=(b-a)/2<math> and <math>\xi<math> some number between <math>a<math> and <math>b<math>.
Composite Simpson's rule
We see that Simpson's rule provides an adequate approximation if the interval of integration <math>[a, b]<math> is small, which does not happen most of the time. The obvious solution is to split the interval of integration in small subintervals, apply Simpson's rule on each subinterval, and add up the results. In this way one obtains the composite Simpson's rule
- <math>\int_a^b f(x) dx\approx
\frac{h}{3}\bigg[f(x_0)+2\sum_{j=1}^{n/2-1}f(x_{2j})+ 4\sum_{j=1}^{n/2}f(x_{2j-1})+f(x_n) \bigg],<math>
where <math>n<math> is the number of subintervals in which one splits <math>[a, b]<math> with <math>n<math> an even number, <math>h=(b-a)/n<math> is the length of each subinterval, and <math>x_i=a+ih<math> for <math>i=0, 1, ..., n-1, n<math>, in particular, <math>x_0=a<math> and <math>x_n=b<math>. Alternatively, the above can be written as:
- <math>\int_a^b f(x) dx\approx
\frac{h}{3}\bigg[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+...+4f(x_{n-1})+f(x_n)\bigg].<math>
The maximum error associated with the composite Simpson's rule can be found using the following formula:
<math>-\frac{h^4}{180}(b-a)f^{(4)}(\xi),<math>
Where <math>h<math> is the "step length", given by <math>h=(b-a)/n<math>.
See also: Newton-Cotes formulas.