## Encyclopedia > Simpson's rule

Article Content

# Simpson's rule

In computer science, in the field of numerical analysis, Simpson's Rule is a way to get an approximation of an integral:

$\int_{a}^{b} f(x) dx$

using an interpolating polynomial of higher degree. Simpson's rule belong to the family of rules derived from Newton-Cotes formulas. The most common is a quadratic polynomial interpolating at a, (a+b)/2, and b which gives us the polynomial:

$P(x) = f(a) + (x-a)f\left[a,\left( \frac{a+b}{2} \right)\right] + \left(x-\left( \frac{a+b}{2} \right)\right)(x-a)f\left[a,\left( \frac{a+b}{2} \right), b\right]$

From this Simpson's Rule is:

$\int_{a}^{b} f(x) dx \approx S(f) = \frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right]$

### Proof

We want to have our polynomial on the form:

$P(x) = \alpha x^2 + \beta x + \gamma$

Assume we have the function values $a=x_0$, $\frac{a+b}{2}=x_1$ and $b=x_2$. The situation will look like this, with our sampled function values at $f(a)$, $f\left(\frac{a+b}{2}\right)$ and $f(b)$:

As this Simpson's rule apply to equidistant points, we know that $x_0 < x_1 < x_2$ and that $x_1-x_0 = x_2-x_1$. This means we may transport our solution to the intervals formed by $-h, 0, h$ such that

$h \equiv \frac{a+b}{2}$

We need to interpolate these values and function values with a polynomial and form our equations:

$f(-h) = \alpha h^2 - \beta h + \gamma$
$f(0) = \gamma$
$f(h) = \alpha h^2 + \beta h + \gamma$

Which yields:

$\alpha = \frac{f(-h) - 2f(0) + f(h)}{2h^2}$
$\beta = \frac{f(h) - f(-h)}{2h}$
$\gamma = f(0)$

We then integrate our polynomial:

$\int_{-h}^h P(x) dx =$
$\int_{-h}^h \frac{f(-h) - 2f(0) + f(h)}{2h^2}x^2 + \frac{f(h) - f(-h)}{2h}x + f(0) dx =$
$\left[\frac{f(-h) - 2f(0) + f(h)}{6h^2}x^3 + \frac{f(h) - f(-h)}{4h}x^2 + f(0)x \right]_{-h}^h =$
$\frac{f(-h) - 2f(0) + f(h)}{6h^2}h^3 + \frac{f(h) - f(-h)}{4h}h^2 + f(0)h +$
$\frac{f(-h) - 2f(0) + f(h)}{6h^2}h^3 - \frac{f(h) - f(-h)}{4h}h^2 + f(0)h =$
$\frac{f(-h) - 2f(0) + f(h)}{3h^2}h^3 + 2f(0)h$

Substitute back our original values:

$\frac{f(a) - 2f\left(\frac{a+b}{2}\right) + f(b)}{3\left(\frac{b-a}{2}\right)^2}\left(\frac{b-a}{2}\right)^3 + 2f\left(\frac{a+b}{2}\right) \left(\frac{b-a}{2}\right) =$
$\frac{f(a) - 2f\left(\frac{a+b}{2}\right) + f(b)}{3}\left(\frac{b-a}{2}\right) + 2f\left(\frac{a+b}{2}\right) \left(\frac{b-a}{2}\right) =$
$\frac{b-a}{6} \left(f(a) - 2f\left(\frac{a+b}{2}\right) + f(b) + 6f\left(\frac{a+b}{2}\right) \right) =$
$\frac{b-a}{6} \left(f(a) + 4f\left(\frac{a+b}{2}\right) + f(b) \right)$

### Error of Simpson's Rule

To examine the accuracy of the rule, take $c = \frac{a+b}{2}$, so

$\int_{a}^{b} f(x) dx = \int_{a}^{c} f(x) dx + \int_{c}^{b} f(x) dx$

Using integration by parts we get:

$\int_{a}^{c} f(x) dx = f(x)(x-\alpha)|^c_a - \int_{a}^{c} f'(x)(x-\alpha) dx$
and
$\int_{c}^{b} f(x) dx = f(x)(x-\beta)|^b_c - \int_{c}^{b} f'(x)(x-\beta) dx$

where α and β are constants that we can choose. Adding these expressions, we get:

$\int_{a}^{b} f(x) dx = f(b)(b-\beta)+f(c)(\beta-\alpha)+f(a)(\alpha-a) - \int_{a}^{c} f'(x)(x-\alpha) dx - \int_{c}^{b} f'(x)(x-\beta) dx$

Let's take α and β, so as to get Simpson's Rule:

$\alpha = \frac{b+5a}{6}, \beta = \frac{5b+a}{6}$

and defining the function Py(x) by:

$P_y(x)=\left\{\begin{matrix} x-\alpha, & \mbox{if }a\le x \le c \\ x-\beta, & \mbox{if }c < x \le b \end{matrix}\right.$

we have

$\int_{a}^{b} f(x) dx = S(f) - \int_{a}^{b}f'(x)P_y(x)dx$

where

$\int_{a}^{b}f'(x)P_y(x)dx$
is the error value.

All Wikipedia text is available under the terms of the GNU Free Documentation License

Search Encyclopedia
 Search over one million articles, find something about almost anything!

Featured Article
 Grateful Dead ... made on the sale of their show tapes. Starting in 1991 the Grateful Dead has released numerous live concerts from their archives in two concurrent series: the From the ...