In this segment, we're going to derive the trapezoidal
rule of integration.
Trapezoidal rule is one of the basic ways of finding the
approximate value of an integral. So let's suppose somebody tells you that, hey, I want
you to find the value of an integral which is of this
particular form, that the function, or the integrand, is given to you,
which is this, so we call this as the integrand, that's the lower limit
of integration, and this here
is called the upper limit of integration. So somebody is asking
you to calculate the value of the integral of the function f of x, which is the integrand,
from a to b. So if we want to find it approximately, one of the things which we can so is . . .
so let's go ahead and look at it graphically. So let's suppose if I have a function like
this, and somebody says, hey, I want you to integrate from a to b, so this is my function
f of x, as a function of x, and says, hey, this is b, let's suppose. So
you have the value of the function here, you have the
value of the function here, actually the area under the curve is all
the one . . . all the area which is from a to b under this curve here.
But in trapezoidal rule, what you are basically doing is you are drawing a straight line . . .
you're drawing a straight line from the value of the function at a here to the value of
the function at b here, so basically these coordinates here,
the coordinate here is a, comma, f of a, and the coordinate here is b, comma,
f of b. So what you are trying to do is you're trying to find the area under the curve.
So the area under the curve of this straight line would be this area of the trapezoid,
because this shape which you are seeing here is basically that of a trapezoid.
And the reason why you are doing this, somebody might say, hey, why are you trying to draw
a straight line going from point a to point b? It is,
when we talk about numerical integration, the reason why
we are approximating our original function by this particular straight line, let's suppose,
is mainly because we know how to integrate under
a straight line, because a straight line is a first-order polynomial, and
from your integral calculus class, you already know how to integrate under a straight line,
or under a linear polynomial function. So that's what
the bottom line is about doing numerical integration,
that you're approximating the function, the original function, which you may or may
not be able to find exactly, by some other function, of which you know how to find
the integral. So let's go ahead and derive what trapezoidal rule is, so basically
we have to find out what this area under the curve is, under this
curve going from point a to point b. So since this is a trapezoid, I can just write it as
the area of a trapezoid. So what is the definition,
or what is the formula for the area of the trapezoid? It's simply
the average of the length of the parallel sides, so sum of the
length of parallel sides. So if you take the
sum of the length of the parallel sides, you take the average of them two, which basically
means that you are dividing it by 2, and you multiply it by the perpendicular
distance between the parallel sides.
So that's what you are doing, you are going to multiply it by the perpendicular distance
between the parallel sides. So in this case, the parallel
are the value of the function at a, plus the value of the function at b,
those are the two parallel sides. So you're going to take the length of that one side,
which is f of a, length of the other side, which is f of b, we'll divide it by 2, because
that's the average, and then you multiply it by b minus
a, because that's the distance between the parallel sides. So your trapezoidal
rule formula is basically becoming a to b, the integral of
f of x from a to b is simply approximately equal to
b minus a, times the value of the function at a,
plus the value of the function at b, divided by 2,
okay? So this is the approximate formula for the . . . for the trapezoidal
rule, it's b minus a, which is the width of the interval,
times the average value of the function at a and b. So you can also look at it this way
is that this particular term here is actually some
average value of the function, it's not the exact
average value of the function, this is some approximate
value of the f-bar in a, comma, b, because you're only
taking two points from a . . . a to b, the one at a and the one at b,
dividing by 2, and getting some approximate value of the average value of the function
in a, b. In fact, you will have to take infinite number of points of points if you want to
get the exact average value of the function from a to b. In that case, that
would give you the exact value of the integral. Why is that so? The reason
for that is as follows, because if you remember your integral calculus class, the
average value of the function from point a to point b is given by the value of
the area under the curve from point a to point b, divided by b minus a.
So in that case, the exact value of the integral can also be
viewed as the exact average value of the function from point a to point b,
times b minus a. In this trapezoidal rule, what we are doing is
we are approximating that average value of the function by the value
of the function at a, plus the value of the function at b, divided by 2,
because in order to be able to calculate this exact average value of the function, I can
also do it on a point by point basis, like I'm doing it here,
but I'll have to choose infinite number of points from
point a to point b.