Saturday, July 27, 2019

Background and proof for Simpson's Rule

Background and proof for Simpson's Rule

We aim to find the area under the following general curve.
Simpson's Rule explanation
We divide it into 4 equal segments. (It must be an even number of segments for Simpson's Rule to work.)
Simpson's Rule explanation
We next construct parabolas which very nearly match the curve in each of the 4 segments. If we are given 3 points, we can pass a unique parabola through those points.
NOTE: We don't actually need to construct these parabolas when applying Simpson's Rule. This section is just to give you some background on why and how it works.
Let's start with the first 2 segments on the left. We take the end points, and the middle point as shown:
Simpson's Rule explanation
We can take measurements (using an overlaid grid) and observe these three points to be:
\displaystyle{\left({x}_{{0}},{y}_{{0}}\right)}={\left(-{1.57},{1}\right)}
\displaystyle{\left({x}_{{1}},{y}_{{1}}\right)}={\left(-{0.39},{1.62}\right)}
\displaystyle{\left({x}_{{2}},{y}_{{2}}\right)}={\left({0.79},{2.71}\right)}
Using these 3 points, we use the general form of a parabola, \displaystyle{y}={a}{x}^{2}+{b}{x}+{c}, and substitute the known \displaystyle{x}- and \displaystyle{y}-values, as follows.
\displaystyle{1}={a}{\left(-{1.57}\right)}^{2}+{b}{\left(-{1.57}\right)}+{c}
\displaystyle{1.62}={a}{\left(-{0.39}\right)}^{2}+{b}{\left(-{0.39}\right)}+{c}
\displaystyle{2.71}={a}{\left({0.79}\right)}^{2}+{b}{\left({0.79}\right)}+{c}
This gives us a set of 3 simultaneous equations in 3 unknowns, which we can solve using these algebraic methods. Doing so gives us:
\displaystyle{a}={0.17021}\displaystyle{b}={0.85820}\displaystyle{c}={1.92808}.
So the parabola passing through those 3 points is
\displaystyle{y}={0.170}{x}^{2}+{0.858}{x}+{1.93}
Note: Of course, we are using full calculator accuracy throughout, but final results are rounded.
Here is what that parabola looks like:
Simpson's Rule explanation
We can see the parabola passes through the 3 points, and it is close to our original curve, and so it's a good approximation for the curve in that portion of the graph. As usual, the more divisions we take, the more accurate it will be.
We do the same process for the final 2 segments, and get a parabola that passes through the 3 points shown, and which looks like this:
Simpson's Rule explanation
There are noticeable gaps between the oriignal curve and our parabolas. We only have to halve the segment size to get a much better fit, as we can see in this next image. The parabola is almost identical to the curve.
Simpson's Rule explanation
See an applet that explores this concept here:
Riemann Sums

Proof of Simpson's Rule

We consider the area under the general parabola \displaystyle{y}={a}{x}^{2}+{b}{c}+{c}.
For easier algebra, we start at the point \displaystyle{\left({0},{y}_{{1}}\right)}, and consider the area under the parabola between \displaystyle{x}=-{h} and \displaystyle{x}={h}, as shown. (Note that \displaystyle\Delta{x}={h}.)
Simpson's Rule explanation - parabola
We have:
\displaystyle{\int_{{-{h}}}^{{h}}}{\left({a}{x}^{2}+{b}{x}+{c}\right)}\ {\left.{d}{x}\right.}
\displaystyle={{\left[\frac{{{a}{x}^{3}}}{{3}}+\frac{{{b}{x}^{2}}}{{2}}+{c}{x}\right]}_{{-{h}}}^{{h}}}
\displaystyle={\left(\frac{{{a}{h}^{3}}}{{3}}+\frac{{{b}{h}^{2}}}{{2}}+{c}{h}\right)}- \displaystyle{\left(-\frac{{{a}{h}^{3}}}{{3}}+\frac{{{b}{h}^{2}}}{{2}}-{c}{h}\right)}
\displaystyle=\frac{{{2}{a}{h}^{3}}}{{3}}+{2}{c}{h}
\displaystyle=\frac{h}{{3}}{\left({2}{a}{h}^{2}+{6}{c}\right)} (getting it into a convenient form)
Our parabola passes through \displaystyle{\left(-{h},{y}_{{0}}\right)}\displaystyle{\left({0},{y}_{{1}}\right)}, and \displaystyle{\left({h},{y}_{{2}}\right)}. Substituting these \displaystyle{x}- and \displaystyle{y}-values into the general equation of our parabola, we get:
\displaystyle{y}_{{0}}={a}{h}^{2}-{b}{h}+{c}
\displaystyle{y}_{{1}}={c}
\displaystyle{y}_{{2}}={a}{h}^{2}+{b}{h}+{c}
Solving these gives us
\displaystyle{c}={y}_{{1}} (from the second line)
and
\displaystyle{2}{a}{h}^{2}={y}_{{0}}-{2}{y}_{{1}}+{y}_{{2}} (by adding the first and 3rd line)
Substituting these into \displaystyle{A}=\frac{h}{{3}}{\left({2}{a}{h}^{2}+{6}{c}\right)} from above, we have:
\displaystyle{A}=\frac{h}{{3}}{\left({2}{a}{h}^{2}+{6}{c}\right)}
\displaystyle=\frac{h}{{3}}{\left({y}_{{0}}-{2}{y}_{{1}}+{y}{2}+{6}{y}_{{1}}\right)}
\displaystyle=\frac{h}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{y}_{{2}}\right)}
The parabola passing through the next set of 3 points will have an area of:
\displaystyle{A}=\frac{h}{{3}}{\left({y}_{{2}}+{4}{y}_{{3}}+{y}_{{4}}\right)}
Adding the 2 areas, we get:
\displaystyle{A}=\frac{h}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{2}{y}_{{2}}+{4}{y}_{{3}}+{y}_{{4}}\right)}
Say we have 6 subintervals. We just find the areas under the 3 resulting parabolas, and add them to obtain:
\displaystyle{A}=\frac{h}{{3}}{\left[{y}_{{0}}+{4}{y}_{{1}}+{2}{y}_{{2}}+{4}{y}_{{3}}+\right.} \displaystyle{2}{y}_{{4}}+ \displaystyle{4}{y}_{{5}}+ \displaystyle{\left.{y}_{{6}}\right]}
We could keep going by creating more and more segments, and adding the areas as we go along. and we would obtain Simpson's Rule:
\displaystyle{\int_{{a}}^{{b}}} f{{\left({x}\right)}}{\left.{d}{x}\right.} \displaystyle\approx\frac{{\Delta{x}}}{{3}}{\left({y}_{{0}}+{4}{y}_{{1}}+{2}{y}_{{2}}+{4}{y}_{{3}}+\right.} \displaystyle{2}{y}_{{4}}\ldots+ \displaystyle{4}{y}_{{{n}-{1}}}+ \displaystyle{\left.{y}_{{n}}\right)}

No comments:

Post a Comment