Simpson's Rule

An idea of the Simpson's rule is in following: approximate curve by parabola and then find area of parabola (it is easy to do because we know antiderivative of quadratic function).

Again we divide [a,b]{\left[{a},{b}\right]} into n{n} subintervals of equal length Δx=ban\Delta{x}=\frac{{{b}-{a}}}{{n}}, and also require n{n} to be even number.simpson's rule

Then on each consecutive pair of intervals we approximate the curve y=f(x){y}={f{{\left({x}\right)}}} by a parabola. If yi=f(xi){y}_{{i}}={f{{\left({x}_{{i}}\right)}}}, then Pi=(xi,yi){P}_{{i}}={\left({x}_{{i}},{y}_{{i}}\right)} is the point on the curve lying above xi{x}_{{i}}.

A typical parabola passes through three consecutive points Pi{P}_{{i}}, Pi+1{P}_{{{i}+{1}}} and Pi+2{P}_{{{i}+{2}}}.

First we find equation of parabola that passes through points (x0,y0){\left({x}_{{0}},{y}_{{0}}\right)}, (x1,y1){\left({x}_{{1}},{y}_{{1}}\right)} and (x2,y2){\left({x}_{{2}},{y}_{{2}}\right)}.

Also note that x1=x0+Δx{x}_{{1}}={x}_{{0}}+\Delta{x} and x2=x0+2Δx{x}_{{2}}={x}_{{0}}+{2}\Delta{x}.

Equation of any parabola has form y=Ax2+Bx+C{y}={A}{{x}}^{{2}}+{B}{x}+{C} and so area under parabola from x=x0{x}={x}_{{0}} to x=x2=x0+2Δx{x}={x}_{{2}}={x}_{{0}}+{2}\Delta{x} is

S=x0x0+2Δx(Ax2+Bx+C)dx=(A3x3+B2x2+Cx)x0x0+2Δx={S}={\int_{{{x}_{{0}}}}^{{{x}_{{0}}+{2}\Delta{x}}}}{\left({A}{{x}}^{{2}}+{B}{x}+{C}\right)}{d}{x}={\left(\frac{{A}}{{3}}{{x}}^{{3}}+\frac{{B}}{{2}}{{x}}^{{2}}+{C}{x}\right)}{{\mid}_{{{x}_{{0}}}}^{{{x}_{{0}}+{2}\Delta{x}}}}=

=(A3(x0+2Δx)3+B2(x0+2Δx)2+C(x0+2Δx))(A3x03+B2x02+Cx0)=={\left(\frac{{A}}{{3}}{{\left({x}_{{0}}+{2}\Delta{x}\right)}}^{{3}}+\frac{{B}}{{2}}{{\left({x}_{{0}}+{2}\Delta{x}\right)}}^{{2}}+{C}{\left({x}_{{0}}+{2}\Delta{x}\right)}\right)}-{\left(\frac{{A}}{{3}}{{x}_{{0}}^{{3}}}+\frac{{B}}{{2}}{{x}_{{0}}^{{2}}}+{C}{x}_{{0}}\right)}=

=2AΔxx02+4A(Δx)2x0+83A(Δx)3+2BΔxx0+2B(Δx)2+2CΔx=={2}{A}\Delta{x}{{x}_{{0}}^{{2}}}+{4}{A}{{\left(\Delta{x}\right)}}^{{2}}{x}_{{0}}+\frac{{8}}{{3}}{A}{{\left(\Delta{x}\right)}}^{{3}}+{2}{B}\Delta{x}{x}_{{0}}+{2}{B}{{\left(\Delta{x}\right)}}^{{2}}+{2}{C}\Delta{x}=

=Δx3(A(6x02+12Δxx0+8A(Δx)2)+B(6x0+6Δx)+6C)=\frac{{\Delta{x}}}{{3}}{\left({A}{\left({6}{{x}_{{0}}^{{2}}}+{12}\Delta{x}{x}_{{0}}+{8}{A}{{\left(\Delta{x}\right)}}^{{2}}\right)}+{B}{\left({6}{x}_{{0}}+{6}\Delta{x}\right)}+{6}{C}\right)}.

Additionally parabola should pass through points P0=(x0,y0){P}_{{0}}={\left({x}_{{0}},{y}_{{0}}\right)}, P1=(x1,y1){P}_{{1}}={\left({x}_{{1}},{y}_{{1}}\right)} and P2=(x2,y2){P}_{{2}}={\left({x}_{{2}},{y}_{{2}}\right)} (recall that x1=x0+Δx{x}_{{1}}={x}_{{0}}+\Delta{x} and x2=x0+2Δx{x}_{{2}}={x}_{{0}}+{2}\Delta{x}), so

{y0=Ax02+Bx0+Cy1=A(x0+Δx)2+B(x0+Δx)+Cy2=A(x0+2Δx)2+B(x0+2Δx)+C{\left\{\begin{array}{c}{y}_{{0}}={A}{{x}_{{0}}^{{2}}}+{B}{x}_{{0}}+{C}\\{y}_{{1}}={A}{{\left({x}_{{0}}+\Delta{x}\right)}}^{{2}}+{B}{\left({x}_{{0}}+\Delta{x}\right)}+{C}\\{y}_{{2}}={A}{{\left({x}_{{0}}+{2}\Delta{x}\right)}}^{{2}}+{B}{\left({x}_{{0}}+{2}\Delta{x}\right)}+{C}\\ \end{array}\right.}

From this we have that

y0+4y1+y2={y}_{{0}}+{4}{y}_{{1}}+{y}_{{2}}=

=Ax02+Bx0+C+4(A(x0+Δx)2+B(x0+Δx)+C)+A(x0+2Δx)2+B(x0+2Δx)+C=={A}{{x}_{{0}}^{{2}}}+{B}{x}_{{0}}+{C}+{4}{\left({A}{{\left({x}_{{0}}+\Delta{x}\right)}}^{{2}}+{B}{\left({x}_{{0}}+\Delta{x}\right)}+{C}\right)}+{A}{{\left({x}_{{0}}+{2}\Delta{x}\right)}}^{{2}}+{B}{\left({x}_{{0}}+{2}\Delta{x}\right)}+{C}=

=A(6x02+12Δxx0+8(Δx)2)+B(6x0+6Δx)+6C={A}{\left({6}{{x}_{{0}}^{{2}}}+{12}\Delta{x}{x}_{{0}}+{8}{{\left(\Delta{x}\right)}}^{{2}}\right)}+{B}{\left({6}{x}_{{0}}+{6}\Delta{x}\right)}+{6}{C}.

If we know multiply both sides of equality by Δx3\frac{{\Delta{x}}}{{3}} we will obtain that

Δx3(y0+4y1+y2)=Δx3(A(6x02+12Δxx0+8(Δx)2)+B(6x0+6Δx)+6C)\frac{{\Delta{x}}}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{y}_{{2}}\right)}=\frac{{\Delta{x}}}{{3}}{\left({A}{\left({6}{{x}_{{0}}^{{2}}}+{12}\Delta{x}{x}_{{0}}+{8}{{\left(\Delta{x}\right)}}^{{2}}\right)}+{B}{\left({6}{x}_{{0}}+{6}\Delta{x}\right)}+{6}{C}\right)}.

But right side is exactly area S{S} under parabola.

Therefore, S=Δx3(y0+4y1+y2){S}=\frac{{\Delta{x}}}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{y}_{{2}}\right)}.

Similarly, it can be shown that the area under parabola through P2{P}_{{2}}, P3{P}_{{3}} and P4{P}_{{4}} from x=x2{x}={x}_{{2}} to x=x4{x}={x}_{{4}} is Δx3(y2+4y3+y4)\frac{{\Delta{x}}}{{3}}{\left({y}_{{2}}+{4}{y}_{{3}}+{y}_{{4}}\right)}.

In general, area under parabola through Pi{P}_{{i}}, Pi+1{P}_{{{i}+{1}}}, Pi+2{P}_{{{i}+{2}}} from x=xi{x}={x}_{{i}} to x=xi+2{x}={x}_{{{i}+{2}}} is Δx3(yi+yi+1+yi+2)\frac{{\Delta{x}}}{{3}}{\left({y}_{{i}}+{y}_{{{i}+{1}}}+{y}_{{{i}+{2}}}\right)}.

Summing areas under parabolas on each subinterval we will obtain that abf(x)dxΔx3(y0+4y1+y2)+Δx3(y2+4y3+y4)++Δx3(yn2+4yn1+yn){\int_{{a}}^{{b}}}{f{{\left({x}\right)}}}{d}{x}\approx\frac{{\Delta{x}}}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{y}_{{2}}\right)}+\frac{{\Delta{x}}}{{3}}{\left({y}_{{2}}+{4}{y}_{{3}}+{y}_{{4}}\right)}+\ldots+\frac{{\Delta{x}}}{{3}}{\left({y}_{{{n}-{2}}}+{4}{y}_{{{n}-{1}}}+{y}_{{n}}\right)}.

Simpson's Rule. abf(x)dxSn=Δx3(y0+4y1+2y2+4y3+2y4++2yn2+4yn1+yn){\int_{{a}}^{{b}}}{f{{\left({x}\right)}}}{d}{x}\approx{S}_{{n}}=\frac{{\Delta{x}}}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{2}{y}_{{2}}+{4}{y}_{{3}}+{2}{y}_{{4}}+\ldots+{2}{y}_{{{n}-{2}}}+{4}{y}_{{{n}-{1}}}+{y}_{{n}}\right)}.

where n{n} is even and Δx=ban\Delta{x}=\frac{{{b}-{a}}}{{n}}.

Note the pattern of coeffcients: 1,4,2,4,2,4,2,4,2,...,4,2,4,2,4,2,4,1.

Example 1. Use the Simpson's Rule to approximate value of 121x2dx{\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x} with n=8{n}={8}.

Here a=1{a}={1}, b=2{b}={2}, f(x)=1x2{f{{\left({x}\right)}}}=\frac{{1}}{{{x}}^{{2}}} and n=8{n}={8}. So, Δx=ban=218=0.125\Delta{x}=\frac{{{b}-{a}}}{{n}}=\frac{{{2}-{1}}}{{8}}={0.125}.

So, 121x(dx)Sn={\int_{{1}}^{{2}}}\frac{{1}}{{x}}{\left({d}{x}\right)}\approx{S}_{{n}}=

=0.1253(f(1)+4f(1.125)+2f(1.25)+4f(1.375)+2f(1.5)+4f(1.625)+2f(1.75)+4f(1.875)+f(2))==\frac{{{0.125}}}{{3}}{\left({f{{\left({1}\right)}}}+{4}{f{{\left({1.125}\right)}}}+{2}{f{{\left({1.25}\right)}}}+{4}{f{{\left({1.375}\right)}}}+{2}{f{{\left({1.5}\right)}}}+{4}{f{{\left({1.625}\right)}}}+{2}{f{{\left({1.75}\right)}}}+{4}{f{{\left({1.875}\right)}}}+{f{{\left({2}\right)}}}\right)}=

=0.1253(112+4(1.125)2+2(1.25)2+4(1.375)2+2(1.5)2+4(1.625)2+2(1.75)2+4(1.875)2+122)0.5000299.=\frac{{0.125}}{{3}}{\left(\frac{{1}}{{{1}}^{{2}}}+\frac{{4}}{{{\left({1.125}\right)}}^{{2}}}+\frac{{2}}{{{\left({1.25}\right)}}^{{2}}}+\frac{{4}}{{{\left({1.375}\right)}}^{{2}}}+\frac{{2}}{{{\left({1.5}\right)}}^{{2}}}+\frac{{4}}{{{\left({1.625}\right)}}^{{2}}}+\frac{{2}}{{{\left({1.75}\right)}}^{{2}}}+\frac{{4}}{{{\left({1.875}\right)}}^{{2}}}+\frac{{1}}{{{2}}^{{2}}}\right)}\approx{0.5000299}.

True value of integral is I=121x2dx=0.5{I}={\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x}={0.5}. As can be seen Simpson's rule gave very good approximation.

When we approximate integral we will always have some error: E=abf(x)dxApp{E}={\int_{{a}}^{{b}}}{f{{\left({x}\right)}}}{d}{x}-{A}{p}{p} where App{A}{p}{p} is approximation and E{E} is error.

Error Bound for Simpson's Rule. Suppose f(4)(x)M{\left|{{f}}^{{{\left({4}\right)}}}{\left({x}\right)}\right|}\le{M} for axb{a}\le{x}\le{b} then EM(ba)5180n4{\left|{E}\right|}\le\frac{{{M}{{\left({b}-{a}\right)}}^{{5}}}}{{{180}{{n}}^{{4}}}}.

Example 2. How large should we take n{n} in order to guarantee that the Simpson's Rule approximation for 121x2dx{\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x} are accurate to within 0.0002?

Here a=1{a}={1}, b=2{b}={2}, f(x)=1x2{f{{\left({x}\right)}}}=\frac{{1}}{{{x}}^{{2}}}.

Then f(x)=2x3{f{'}}{\left({x}\right)}=-\frac{{2}}{{{x}}^{{3}}}, f(x)=6x4{f{''}}{\left({x}\right)}=\frac{{6}}{{{x}}^{{4}}}, f(x)=24x5{f{'''}}{\left({x}\right)}=-\frac{{24}}{{{x}}^{{5}}} and f(4)(x)=120x6{{f}}^{{{\left({4}\right)}}}{\left({x}\right)}=\frac{{120}}{{{x}}^{{6}}}.

Therefore f(4)(x)120{\left|{{f}}^{{{\left({4}\right)}}}{\left({x}\right)}\right|}\le{120} for 1x2{1}\le{x}\le{2}.

Thus, 120(21)5180n4<0.0002\frac{{{120}{{\left({2}-{1}\right)}}^{{5}}}}{{{180}{{n}}^{{4}}}}<{0.0002} or n4>1201800.0002=10.0003{{n}}^{{4}}>\frac{{120}}{{{180}\cdot{0.0002}}}=\frac{{1}}{{{0.0003}}}.

So, n>10.000347.6{n}>\frac{{1}}{{{\sqrt[{{4}}]{{{0.0003}}}}}}\approx{7.6}.

So, we need to take n=8{n}={8} (remember n{n} must be even).

This is much better then n=36{n}={36} for the midpoint rule and n=51{n}={51} for the trapezoidal rule.