# Simpson's rule

 $\frac{d}{dx} \sin x=?\,$ This article/section deals with mathematical concepts appropriate for a student in late high school or early university.

In Calculus, Simpson's Rule is a method of estimating integrals by using parabolas or other higher order polynomial expressions. It is named after its discoverer, Thomas Simpson[1].

## Simpson's Rule

Specifically, Simpson's Rule states:

$\int_a^b f(x)dx \approx {{b - a} \over 6}\left [ f(a) + 4f \left ({{a+b} \over 2} \right ) + f(b) \right ]$

### Example 1

Example 1
Explanation Color
The integrand (what is being integrated) blue line
The lower bound green line
The upper bound red line
The parabola that we are using to approximate the area purple line
The area under both f(x) and the parabola aqua area
The extra area that the approximation count yellow area
The area that the approximation does not count dark read area

Given:

$\int_1^4 (-x^3 + 4x^2-x+1) dx$

We can use Simpson's Rule to get a quick approximation of the actual value of the definite integral.

a = 1
b = 4
f(x) = − x3 + 4x2x + 1
f(1) = − 13 + 4(1)2 − 1 + 1 = 3
f(4) = − 43 + 4(4)2 − 4 + 1 = − 3
$f \left ({4+1 \over 2} \right ) = f(2.5) = -2.5^3 + 4(2.5)^2 - 2.5 + 1 = 7.875$

Now we can evaluate the integral:

${{4-1} \over 6} \left [ 3 + 4(7.875) - 3 \right ] = \left ({1 \over 2} \right)(31.5) = 15.75$

In the picture on the right the "error area" is the yellow and dark red area. In cases where the approximation does not give a good answer, we increase the number of subintervals.

If we solve this using integration, we find that Simpson's Rule gave the exact value for the definite integral. However, this is rarely the case, as shown in the next example.

### Example 2

Given:

$\int_4^{12}\frac{3x+11}{x^2-x-6}dx$

Directly solving this integral would require an understanding of partial fractions. If we want to quickly attain an approximation of the integral, we can use Simpson's Rule.

a = 4
b = 12
Example 2
Explanation
This shows the parabolic approximation we are using. Note how much more error area that there is compared to the previous example.
$f(x)=\frac{3x+11}{x^2-x-6}$
$f(4) = \frac{3(4)+11}{4^2-4-6} = {23 \over 6}$
$f(12) = {47 \over 126}$
$f\left ({{4+12}\over{2}}\right ) = f(8) = \frac{3(8)+11}{8^2-8-6} = {35\over50} = {7\over10}$

Now we can solve:

$\left ({12-4 \over 6}\right ) \left ( {23 \over 6} + 4 \left( {7\over10} \right)+ {47 \over 126} \right ) = \left ( {4\over3} \right ) \left({2207\over315}\right) \approx 9.34179...$

As the function given does not resemble a parabola, the answer we get is completely off of the real answer, which is:

$\approx 7.94160...$

This is why we will sometimes split the interval of integration into multiple pieces. When we increase the number of subintervals, the approximation approaches the actual value (see example below). When we do this, we use the Composite Simpson's Rule.

## Composite Simpson's Rule

Simpson's Rule can be applied to segments of an integral, effectively making it a Riemann Integral.
If the interval [a,b] is split into N segments, with N as an even number, there is a formula that can be used to solve for the integral.
Note that:

xn = x + nh
$h = {{b - a} \over N}$

As an extension of Simpson's Rule, we can find that:

$\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]$

The above formula can be rewritten as:

$\int_a^b f(x) \, dx\approx \frac{h}{3}\bigg[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+\cdots+4f(x_{n-1})+f(x_n)\bigg]$
The formulas above do not work unless N is even.

### Example 2 Continued

Example 2 Continued
Click on the image to get a better view.

As our estimation was quite off, we should use the Composite Rule to get a better approximation.
For this example, we will use 8 subintervals.

N = 8
$h = {8 \over 8} = 1$
x0 = 4,x1 = 5,x2 = 6,x3 = 7,x4 = 8,x5 = 9,x6 = 10,x7 = 11,x8 = 12
$\int_4^{12} {3x+11 \over x^2 - x - 6}dx \approx \left({1\over3}\right ) \bigg[ f(4)+4f(5)+2f(6)+4f(7)+2f(8)+4f(9)+2f(10)+4f(11)+f(12) \bigg]$
$= \left ( { 1 \over 3 } \right ) \bigg[ {23\over6} + 4\left ( {13\over7} \right) + 2\left ( {29\over24} \right) + 4\left ( {8\over9} \right) + 2\left ( {7\over10} \right) + 4\left ( {19\over33} \right) + 2\left ( {41\over84} \right) + 4 \left ( {11\over26} \right) + {47\over126} \bigg]$
$=\left ( { 1 \over 3 } \right ) \left( {68579\over2860} \right) = {68579\over8580}$
$\approx 7.99289...$

This new answer is much closer than the original; it is off by about .05. In the picture on the right, note how much less "error" area that there is compared to when we only used one parabola. The graph represents the first parabola we use for Example 2 Continued, evaluating from 4 to 6. By reducing the interval that each individual parabola approximates, our total approximation became more accurate.

If the number of subintervals is increased, it can be shown that the estimated value approaches the real value:

N Estimate
2 9.34179
4 8.26138
8 7.99289
10 7.96783
100 7.94161
1000 7.94160

After we reach 106 subintervals, the approximation is correct for five digits.

## Other Versions of Simpson's Rule

There are a few other rules that Simpson proved. For example, Simpson's 3/8 Rule[2] shows that cubic functions can be used to approximate integrals.