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]} [ a , b ] into n {n} n subintervals of equal length Δ x = b − a n \Delta{x}=\frac{{{b}-{a}}}{{n}} Δ x = n b − a , and also require n {n} n to be even number.
Then on each consecutive pair of intervals we approximate the curve y = f ( x ) {y}={f{{\left({x}\right)}}} y = f ( x ) by a parabola. If y i = f ( x i ) {y}_{{i}}={f{{\left({x}_{{i}}\right)}}} y i = f ( x i ) , then P i = ( x i , y i ) {P}_{{i}}={\left({x}_{{i}},{y}_{{i}}\right)} P i = ( x i , y i ) is the point on the curve lying above x i {x}_{{i}} x i .
A typical parabola passes through three consecutive points P i {P}_{{i}} P i , P i + 1 {P}_{{{i}+{1}}} P i + 1 and P i + 2 {P}_{{{i}+{2}}} P i + 2 .
First we find equation of parabola that passes through points ( x 0 , y 0 ) {\left({x}_{{0}},{y}_{{0}}\right)} ( x 0 , y 0 ) , ( x 1 , y 1 ) {\left({x}_{{1}},{y}_{{1}}\right)} ( x 1 , y 1 ) and ( x 2 , y 2 ) {\left({x}_{{2}},{y}_{{2}}\right)} ( x 2 , y 2 ) .
Also note that x 1 = x 0 + Δ x {x}_{{1}}={x}_{{0}}+\Delta{x} x 1 = x 0 + Δ x and x 2 = x 0 + 2 Δ x {x}_{{2}}={x}_{{0}}+{2}\Delta{x} x 2 = x 0 + 2 Δ x .
Equation of any parabola has form y = A x 2 + B x + C {y}={A}{{x}}^{{2}}+{B}{x}+{C} y = A x 2 + B x + C and so area under parabola from x = x 0 {x}={x}_{{0}} x = x 0 to x = x 2 = x 0 + 2 Δ x {x}={x}_{{2}}={x}_{{0}}+{2}\Delta{x} x = x 2 = x 0 + 2 Δ x is
S = ∫ x 0 x 0 + 2 Δ x ( A x 2 + B x + C ) d x = ( A 3 x 3 + B 2 x 2 + C x ) ∣ x 0 x 0 + 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}}}}= S = ∫ x 0 x 0 + 2 Δ x ( A x 2 + B x + C ) d x = ( 3 A x 3 + 2 B x 2 + C x ) ∣ x 0 x 0 + 2 Δ x =
= ( A 3 ( x 0 + 2 Δ x ) 3 + B 2 ( x 0 + 2 Δ x ) 2 + C ( x 0 + 2 Δ x ) ) − ( A 3 x 0 3 + B 2 x 0 2 + C x 0 ) = ={\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)}= = ( 3 A ( x 0 + 2 Δ x ) 3 + 2 B ( x 0 + 2 Δ x ) 2 + C ( x 0 + 2 Δ x ) ) − ( 3 A x 0 3 + 2 B x 0 2 + C x 0 ) =
= 2 A Δ x x 0 2 + 4 A ( Δ x ) 2 x 0 + 8 3 A ( Δ x ) 3 + 2 B Δ x x 0 + 2 B ( Δ x ) 2 + 2 C Δ 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}= = 2 A Δ x x 0 2 + 4 A ( Δ x ) 2 x 0 + 3 8 A ( Δ x ) 3 + 2 B Δ x x 0 + 2 B ( Δ x ) 2 + 2 C Δ x =
= Δ x 3 ( A ( 6 x 0 2 + 12 Δ x x 0 + 8 A ( Δ x ) 2 ) + B ( 6 x 0 + 6 Δ x ) + 6 C ) =\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)} = 3 Δ x ( A ( 6 x 0 2 + 12 Δ x x 0 + 8 A ( Δ x ) 2 ) + B ( 6 x 0 + 6 Δ x ) + 6 C ) .
Additionally parabola should pass through points P 0 = ( x 0 , y 0 ) {P}_{{0}}={\left({x}_{{0}},{y}_{{0}}\right)} P 0 = ( x 0 , y 0 ) , P 1 = ( x 1 , y 1 ) {P}_{{1}}={\left({x}_{{1}},{y}_{{1}}\right)} P 1 = ( x 1 , y 1 ) and P 2 = ( x 2 , y 2 ) {P}_{{2}}={\left({x}_{{2}},{y}_{{2}}\right)} P 2 = ( x 2 , y 2 ) (recall that x 1 = x 0 + Δ x {x}_{{1}}={x}_{{0}}+\Delta{x} x 1 = x 0 + Δ x and x 2 = x 0 + 2 Δ x {x}_{{2}}={x}_{{0}}+{2}\Delta{x} x 2 = x 0 + 2 Δ x ), so
{ y 0 = A x 0 2 + B x 0 + C y 1 = A ( x 0 + Δ x ) 2 + B ( x 0 + Δ x ) + C y 2 = A ( x 0 + 2 Δ x ) 2 + B ( x 0 + 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.} ⎩ ⎨ ⎧ y 0 = A x 0 2 + B x 0 + C y 1 = A ( x 0 + Δ x ) 2 + B ( x 0 + Δ x ) + C y 2 = A ( x 0 + 2 Δ x ) 2 + B ( x 0 + 2 Δ x ) + C
From this we have that
y 0 + 4 y 1 + y 2 = {y}_{{0}}+{4}{y}_{{1}}+{y}_{{2}}= y 0 + 4 y 1 + y 2 =
= A x 0 2 + B x 0 + C + 4 ( A ( x 0 + Δ x ) 2 + B ( x 0 + Δ x ) + C ) + A ( x 0 + 2 Δ x ) 2 + B ( x 0 + 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 x 0 2 + B x 0 + C + 4 ( A ( x 0 + Δ x ) 2 + B ( x 0 + Δ x ) + C ) + A ( x 0 + 2 Δ x ) 2 + B ( x 0 + 2 Δ x ) + C =
= A ( 6 x 0 2 + 12 Δ x x 0 + 8 ( Δ x ) 2 ) + B ( 6 x 0 + 6 Δ x ) + 6 C ={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} = A ( 6 x 0 2 + 12 Δ x x 0 + 8 ( Δ x ) 2 ) + B ( 6 x 0 + 6 Δ x ) + 6 C .
If we know multiply both sides of equality by Δ x 3 \frac{{\Delta{x}}}{{3}} 3 Δ x we will obtain that
Δ x 3 ( y 0 + 4 y 1 + y 2 ) = Δ x 3 ( A ( 6 x 0 2 + 12 Δ x x 0 + 8 ( Δ x ) 2 ) + B ( 6 x 0 + 6 Δ x ) + 6 C ) \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)} 3 Δ x ( y 0 + 4 y 1 + y 2 ) = 3 Δ x ( A ( 6 x 0 2 + 12 Δ x x 0 + 8 ( Δ x ) 2 ) + B ( 6 x 0 + 6 Δ x ) + 6 C ) .
But right side is exactly area S {S} S under parabola.
Therefore, S = Δ x 3 ( y 0 + 4 y 1 + y 2 ) {S}=\frac{{\Delta{x}}}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{y}_{{2}}\right)} S = 3 Δ x ( y 0 + 4 y 1 + y 2 ) .
Similarly, it can be shown that the area under parabola through P 2 {P}_{{2}} P 2 , P 3 {P}_{{3}} P 3 and P 4 {P}_{{4}} P 4 from x = x 2 {x}={x}_{{2}} x = x 2 to x = x 4 {x}={x}_{{4}} x = x 4 is Δ x 3 ( y 2 + 4 y 3 + y 4 ) \frac{{\Delta{x}}}{{3}}{\left({y}_{{2}}+{4}{y}_{{3}}+{y}_{{4}}\right)} 3 Δ x ( y 2 + 4 y 3 + y 4 ) .
In general, area under parabola through P i {P}_{{i}} P i , P i + 1 {P}_{{{i}+{1}}} P i + 1 , P i + 2 {P}_{{{i}+{2}}} P i + 2 from x = x i {x}={x}_{{i}} x = x i to x = x i + 2 {x}={x}_{{{i}+{2}}} x = x i + 2 is Δ x 3 ( y i + y i + 1 + y i + 2 ) \frac{{\Delta{x}}}{{3}}{\left({y}_{{i}}+{y}_{{{i}+{1}}}+{y}_{{{i}+{2}}}\right)} 3 Δ x ( y i + y i + 1 + y i + 2 ) .
Summing areas under parabolas on each subinterval we will obtain that ∫ a b f ( x ) d x ≈ Δ x 3 ( y 0 + 4 y 1 + y 2 ) + Δ x 3 ( y 2 + 4 y 3 + y 4 ) + … + Δ x 3 ( y n − 2 + 4 y n − 1 + y n ) {\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)} ∫ a b f ( x ) d x ≈ 3 Δ x ( y 0 + 4 y 1 + y 2 ) + 3 Δ x ( y 2 + 4 y 3 + y 4 ) + … + 3 Δ x ( y n − 2 + 4 y n − 1 + y n ) .
Simpson's Rule. ∫ a b f ( x ) d x ≈ S n = Δ x 3 ( y 0 + 4 y 1 + 2 y 2 + 4 y 3 + 2 y 4 + … + 2 y n − 2 + 4 y n − 1 + y n ) {\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)} ∫ a b f ( x ) d x ≈ S n = 3 Δ x ( y 0 + 4 y 1 + 2 y 2 + 4 y 3 + 2 y 4 + … + 2 y n − 2 + 4 y n − 1 + y n ) .
where n {n} n is even and Δ x = b − a n \Delta{x}=\frac{{{b}-{a}}}{{n}} Δ x = n b − a .
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 ∫ 1 2 1 x 2 d x {\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x} ∫ 1 2 x 2 1 d x with n = 8 {n}={8} n = 8 .
Here a = 1 {a}={1} a = 1 , b = 2 {b}={2} b = 2 , f ( x ) = 1 x 2 {f{{\left({x}\right)}}}=\frac{{1}}{{{x}}^{{2}}} f ( x ) = x 2 1 and n = 8 {n}={8} n = 8 . So, Δ x = b − a n = 2 − 1 8 = 0.125 \Delta{x}=\frac{{{b}-{a}}}{{n}}=\frac{{{2}-{1}}}{{8}}={0.125} Δ x = n b − a = 8 2 − 1 = 0.125 .
So, ∫ 1 2 1 x ( d x ) ≈ S n = {\int_{{1}}^{{2}}}\frac{{1}}{{x}}{\left({d}{x}\right)}\approx{S}_{{n}}= ∫ 1 2 x 1 ( d x ) ≈ S n =
= 0.125 3 ( f ( 1 ) + 4 f ( 1.125 ) + 2 f ( 1.25 ) + 4 f ( 1.375 ) + 2 f ( 1.5 ) + 4 f ( 1.625 ) + 2 f ( 1.75 ) + 4 f ( 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)}= = 3 0.125 ( f ( 1 ) + 4 f ( 1.125 ) + 2 f ( 1.25 ) + 4 f ( 1.375 ) + 2 f ( 1.5 ) + 4 f ( 1.625 ) + 2 f ( 1.75 ) + 4 f ( 1.875 ) + f ( 2 ) ) =
= 0.125 3 ( 1 1 2 + 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 + 1 2 2 ) ≈ 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}. = 3 0.125 ( 1 2 1 + ( 1.125 ) 2 4 + ( 1.25 ) 2 2 + ( 1.375 ) 2 4 + ( 1.5 ) 2 2 + ( 1.625 ) 2 4 + ( 1.75 ) 2 2 + ( 1.875 ) 2 4 + 2 2 1 ) ≈ 0.5000299 .
True value of integral is I = ∫ 1 2 1 x 2 d x = 0.5 {I}={\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x}={0.5} I = ∫ 1 2 x 2 1 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 = ∫ a b f ( x ) d x − A p p {E}={\int_{{a}}^{{b}}}{f{{\left({x}\right)}}}{d}{x}-{A}{p}{p} E = ∫ a b f ( x ) d x − A p p where A p p {A}{p}{p} A p p is approximation and E {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} ∣ ∣ f ( 4 ) ( x ) ∣ ∣ ≤ M for a ≤ x ≤ b {a}\le{x}\le{b} a ≤ x ≤ b then ∣ E ∣ ≤ M ( b − a ) 5 180 n 4 {\left|{E}\right|}\le\frac{{{M}{{\left({b}-{a}\right)}}^{{5}}}}{{{180}{{n}}^{{4}}}} ∣ E ∣ ≤ 180 n 4 M ( b − a ) 5 .
Example 2 . How large should we take n {n} n in order to guarantee that the Simpson's Rule approximation for ∫ 1 2 1 x 2 d x {\int_{{1}}^{{2}}}\frac{{1}}{{{x}}^{{2}}}{d}{x} ∫ 1 2 x 2 1 d x are accurate to within 0.0002?
Here a = 1 {a}={1} a = 1 , b = 2 {b}={2} b = 2 , f ( x ) = 1 x 2 {f{{\left({x}\right)}}}=\frac{{1}}{{{x}}^{{2}}} f ( x ) = x 2 1 .
Then f ′ ( x ) = − 2 x 3 {f{'}}{\left({x}\right)}=-\frac{{2}}{{{x}}^{{3}}} f ′ ( x ) = − x 3 2 , f ′ ′ ( x ) = 6 x 4 {f{''}}{\left({x}\right)}=\frac{{6}}{{{x}}^{{4}}} f ′′ ( x ) = x 4 6 , f ′ ′ ′ ( x ) = − 24 x 5 {f{'''}}{\left({x}\right)}=-\frac{{24}}{{{x}}^{{5}}} f ′′′ ( x ) = − x 5 24 and f ( 4 ) ( x ) = 120 x 6 {{f}}^{{{\left({4}\right)}}}{\left({x}\right)}=\frac{{120}}{{{x}}^{{6}}} f ( 4 ) ( x ) = x 6 120 .
Therefore ∣ f ( 4 ) ( x ) ∣ ≤ 120 {\left|{{f}}^{{{\left({4}\right)}}}{\left({x}\right)}\right|}\le{120} ∣ ∣ f ( 4 ) ( x ) ∣ ∣ ≤ 120 for 1 ≤ x ≤ 2 {1}\le{x}\le{2} 1 ≤ x ≤ 2 .
Thus, 120 ( 2 − 1 ) 5 180 n 4 < 0.0002 \frac{{{120}{{\left({2}-{1}\right)}}^{{5}}}}{{{180}{{n}}^{{4}}}}<{0.0002} 180 n 4 120 ( 2 − 1 ) 5 < 0.0002 or n 4 > 120 180 ⋅ 0.0002 = 1 0.0003 {{n}}^{{4}}>\frac{{120}}{{{180}\cdot{0.0002}}}=\frac{{1}}{{{0.0003}}} n 4 > 180 ⋅ 0.0002 120 = 0.0003 1 .
So, n > 1 0.0003 4 ≈ 7.6 {n}>\frac{{1}}{{{\sqrt[{{4}}]{{{0.0003}}}}}}\approx{7.6} n > 4 0.0003 1 ≈ 7.6 .
So, we need to take n = 8 {n}={8} n = 8 (remember n {n} n must be even).
This is much better then n = 36 {n}={36} n = 36 for the midpoint rule and n = 51 {n}={51} n = 51 for the trapezoidal rule .