CHRISTINE BREINER: Welcome back to recitation.
In this video I want to explain to you where the
coefficients we saw in Simpson's rule
actually come from.
So what I'm going to do is take this curve that I have
and show you what the picture of Simpson's rule does.
And then I'm actually going to determine explicitly where the
coefficients come from.
So let's look at this picture first. The picture I have
here, the white curve is going to be my y
equals f of x function.
And so, if you remember, what Simpson's rule is saying, you
have to have two delta x's.
So in this case h is equal to delta x.
So what Simpson's rule is saying is I can find,
approximate, the area under this curve from minus h to h
by a certain expression.
And the expression is, I said delta x is equal to h, so let
me write h over 3 times y0 plus 4 y1 plus y2-- oh, y2.
So that's what you got, that's what you saw in the lecture,
that this is what the coefficients are.
So I want to explain why this is a 1, why that's a 4, why
that's a 1, and where that 3 comes from.
The picture is not going to explain it, but the picture
will help us understand how to go.
So what Simpson's rule does is it takes those three points,
so the x0, y0, the x1, y1 and x2, y2 that are on the curve y
equals f of x.
And it finds a parabola through those three points.
So I'm going to do my best to draw what looks like a
parabola through those three points.
Something--
I'll draw it lightly first and then I'll fill it in.
Something along these lines.
Something like that.
That's a sort of looks like a parabola.
And os the idea is Simpson's rule is saying I can find the
area under the blue curve.
So I can find the area under the blue curve.
So this is a function, we'll call this y equal P of x.
And that's what you were actually
told about in lecture.
That you're approximating your function y equals f of x by a
quadratic function that goes through the values x0, y0, x1,
y1, and x2, y2.
And then you find the area under that parabola.
Between minus h and h.
Now this picture, you might say, Christine, this looks
really like a bad estimate.
This looks kind of stupid.
Maybe you should have picked a different
function to estimate this.
And I did this one because I wanted to be zoomed out far
and to show you, to give you a little intuition about what
happens when we make h smaller.
Notice that if I cut the size of h in half, so if I started
with here was minus h to h, what would my three points be?
My three points would be this point, y1, and y2 would be
right here.
Well the quadratic through those points is much closer to
the actual function.
And if I cut that in half again, I'd have points here,
here, and here.
Something like that, and that starts to look almost exactly
like a quadratic.
So if I found the area under this--
or if I wanted to estimate the area under this piece of the
curve using a quadratic through those three points,
they would be very close.
So don't be alarmed by Simpson's rule as an
approximation based on this large picture.
So now, what do we have to do?
Remember, what's our goal?
Our goal is to figure out where the
coefficients come from.
So what I actually need to do is I need to evaluate a
certain integral.
Or I need to integrate a certain function.
I need to integrate P of x.
So what I'm going to be finding through the rest of
this video, is the integral from minus h
to h of P of x dx.
And my goal is to show that this integral is equal to this
expression.
I want to show that these are equal.
That's my goal.
So let's get down to it.
What do I know?
What's the only thing I know right away about P of x?
I know I'm choosing it to be a quadratic function and I know
it goes through three certain points.
Right?
I'll write down what the three points are when we need them.
But first let's just say, in general, let's take this
integral for a general quadratic and see how much
information we actually need.
So let me come over here.
Actually, let me say first, what do I
mean my general quadratic?
I mean something of the form big A, capital Ax squared plus
Bx plus C. So I'm not filling in values for these
coefficients yet.
Those coefficients are coming exactly from my three points.
x0, y0, x1, y1 and x2, y2.
So let's just integrate that from minus h to h first and
see what kind of information we need.
So if I come over here.
So what do I get when I actually integrate this?
Well, I get Ax to the third over 3, plus Bx squared over
2, plus Cx, and then I have to evaluate for minus h to h.
Well, if you were thinking about this, it shouldn't be
surprising that when I do this, there's not
going to be a B term.
Why is that?
Well, these two functions are even.
Ax squared and C are even functions.
And I'm integrating over something that's symmetric
about the y-axis.
I'm going from minus h to h.
So if you think about Ax squared, and I'm going from
minus h to h, I'm finding the area under a quadratic, from
minus h to h, it's going to be twice the area from 0 to h.
But Bx, that's a line with slope B. If I wanted to
integrate Bx from minus h to h, that's the area, the signed
area under the curve of a line Bx, from minus h to h.
If I just draw a quick picture, what
does that look like?
It's symmetric with respect to a rotation there.
I'd have this signed area.
This is the curve y equals Bx.
From minus h to h, I get this area is negative and this are
is positive and they're equal.
So, what I'm about to do, you shouldn't be surprised there
won't be a B term.
So what do we actually get when we evaluate this?
We get 2A h cubed, over 3, plus 2C h.
That's what we get.
You can actually work it all, put in and all the h's and see
that, but I knew I was going to have double what was here
when I evaluated at h, and nothing from the B term.
So we're getting closer.
We're getting closer.
We might not look like we're getting closer, but we're
getting closer.
So let's simplify this expression a little bit.
Actually, what I ultimately need to do is I need to figure
out C and I need to figure out something over here.
I need to actually figure out Ah squared.
And let me explain why I need to figure out Ah squared.
In the end, if I come over back to what I want to show--
let me even box it, so we see it--
I want to show that this integral, which I've started
to calculate, is equal to h over 3 times this quantity.
So I want to keep one around, but I want the other, any
other powers of h to not be there when I'm done.
Right?
I need one power of h there.
In fact I need an h over 3 there.
So I think what I'll do is I'll start off and I'll pull
out an h over 3, and then I'll try and figure out if I can
get the rest of my expression to look like what's in the
parentheses.
That's really, ultimately, what I'd like to do.
So let's come back over here.
I'm going to pull out an h over 3 from both of these and
we're going to see what we end up with.
OK so if I pull out an h over 3 here, what do I end up with?
This is easy.
That's 2A h squared.
And this one's a little bit trickier.
But I have to multiply by 3 over 3 to get a 3 there.
So I end up with 6C.
OK.
Let's make sure I didn't make any mistakes.
If I multiply through here I get 2A h cubed over 3.
If I multiply through here I get 2h C. Looking good so far.
Now I have to figure out A and C, or Ah squared and C. Well,
C is pretty easy to find.
Let's think about why that is.
I have this polynomial.
The polynomial was equal to-- if we come over here and we
look again, it's Ax squared plus Bx plus C. And the
polynomial has to go through those three points I had.
So when x is 0, P of 0 is C. So let's come back and look at
our picture.
When x is 0, what's the output on the white curve?
It's y1.
So C is exactly y1.
How am I going to find Ah squared?
Well, what I need to do is use these other two points.
I'm going to evaluate the function P of x at minus h.
And it's output has to be y0.
And I'm going to evaluate the function P of x at h and it's
output has to be y2.
So we're going to come over to the other side, but that's
really what we're doing next.
So let's come over here and let's evaluate P of h
and P of minus h.
So P of h is Ah squared plus Bh plus C. And P of minus h is
Ah squared minus Bh plus C. OK.
What else?
Again we said this one has to be y2, the output, and this
one has to be y0.
Because the output at h has to agree with the output of the
function f of x.
And its output at h was y2.
The output at minus h of P has to be the same as the output
at minus h of f.
And that was y0.
Now this might not look fun yet but what if I add these
two things together.
What happens?
I get 2A h squared.
These drop out.
And then I get plus 2C is equal to y0 plus y2.
I'm getting closer.
I'm getting much closer.
Because now notice what I have. I have 2A h squared, I
can isolate that.
And that's something that I want to figure out.
I want to figure 2A h squared.
So let's figure out what that is.
2A h squared is equal to y0 plus y2 minus, well what did
we say C was?
C was the output at x equals 0.
Which is y1.
So it's minus 2C, which is minus 2 y1.
So now we're very close, we're very close to
getting what we want.
And that's good, because I'm almost out of room.
So let's take that expression, we were working on this
expression right here, and let's start to
fill in what we get.
We get h over 3 times 2A h squared which is y0 plus y2
minus 2 y1, and then I have to add 6C.
Now what's C?
C is y1.
So I'm going to add 6 y1.
And if I simplify that, I get y0--
bingo--
plus 4 y1 plus y2.
And that's what we wanted.
So let me take us through kind of where all this came from
again, what the big pieces were and we'll see now we
understand how we do Simpson's rule, and these small chunks
of Simpson's rule.
So let's come back to the very beginning.
OK, in the very beginning, what we had was a function f
of x, that was the white curve. y equals f of x was the
white curve.
And then I found a quadratic that went through minus h, y0,
0, y1, and h, y2.
Went through those three points.
And I called that quadratic P of x.
And then what I was doing, we know Simpson's rule says find
the area under the curve of P of x between minus h and h.
So what I did was I came over here and I said OK, P of x,
integral of P of x from minus h to h.
I wrote P of x in a very general form.
And then I actually found an integral.
I came through and after writing it out, calculating
the integral, I got to this expression.
This is actually the integral of P of x from minus h to h.
So it's the area under the curve of P of x from minus h
to h is that.
And now I had to figure this out, how to write this in
terms of the outputs of f of x.
Which were y0, y1, and y2.
Those were the ones we were interested in.
So I ultimately knew I wanted an h over three in front.
I knew I wanted my integral in my quadratic to be h over 3
times something, so I pulled out an h over 3, and then I
looked at what this expression was.
And if I could get this expression to look like the
inside of what I wanted, which was y0 plus 4 y1 plus y2, I
was in business.
And so then I used outputs that I knew for p of x to find
2A h squared and to find C. I know P of h is the output of
the f of x function at the far right, which was y2.
And I knew P of minus h was the output of the f of x
function at the far left.
That's y0.
I actually then evaluate P at h and minus h, and when I add
those together, I get my 2Ah squared in terms
of y0, y1, and y2.
Let me do this in terms of y0, y1, and y2.
Because I also knew C was y1.
We talked about that as well.
C had to be y1.
So I can then do the substitution I need right here
and show where the coefficients in
Simpson's rule come from.
So hopefully that was informative for you.
And I think I'll stop there.