In this segment, we'll talk about the composite trapezoidal rule
and look through an example. What the composite trapezoidal rule is,
is a method of approximating integrals. It is sometimes also called the multiple segment
So, this is the example which we are asked to solve for,
and since we're using the composite trapezoidal rule, you also got to know how many segments
you're going to use. And it's also asking for true error and absolute relative true error,
that is mainly to get a glimpse of how good this composite trapezoidal rule is working. So, let's
go and write down the formula for the, recall the formula for the composite trapezoidal rule. So,
for an integral of a function f(x) going from a to b, it is approximated as b-a by 2 n, (where n
is the number of segments) times the value of the function at a plus 2 times the summation which is
basically calculating the value of the function at some intermediate points between a and b,
plus the value of the function at b. So, where h is which is the segment width is
b minus a divided by n. So, let's go and see how we can use this formula.
So, for example h will be equal to b minus a divided by n, which will be 1.3-0.1 divided by 3.
So, it will be 0.4, and that makes sense because if I want to start from 0.1
and end at 1.3, I have three segments here. So, the first segment will be 0.4 away from here,
will be 0.5. The next one will be 0.4 again away, gives 0.9 and we have our three segments. So,
the integral going from 0.1 to 1.3 f(x) dx will be approximately equal to b minus a
divided by 2 times n which is 3, times the value of the function at 0.1 (which is
f(a)) plus 2 times the summation, i is equal to 1 to n-1. n is equal to 3-1.
F(a) is 0.1 plus I, and h is 0.4. So, keep in mind that this is the argument of the function,
plus the value of the function at 1.3. And from here, I’ll get 1.2 divided by 6,
times the value of the function at 0.1 plus 2 times the summation of i is equal to 1 to 2
of the value of the function at 0.1 plus I times 0.4, plus the value of the function at 1.3.
And this will give us 1.2 divided by 6
times the value of the function at 0.1. Now, we’ve got to now see that
the series is going from one to two, so there are two terms in the series. So, I will put i=1 first,
and then for the next one I’ll put i=2 to get my two terms of the series.
And then I have my last term, which is 1.3. Don't forget about the 2 which is outside of
the summation, so you have to bring that also. But look at the compact expression which you're
going to get now, will be f(0.1) plus 2 times the value of the function being calculated at 0.5,
plus 2 times the value at 0.9, plus the value of the function at 1.3.
So, all you have to do now is to substitute the values of the function at
these particular points and be able to find out what the answer is.
So, we get 0.2 times the value of the function at 1 is what, 5(0.1) e to the power 2 times 0.1 plus
2 times 5 times 0.5e to the power -2 times 0.5 plus 2 times 5 times
0.9 e to the power -2 times 0.9 plus 5 times 1.3e to the power -2(1.3). So, if we
do all these calculations now, we'll get 0.84385 as the approximate value of the integral.
Now to compare it with the exact integral. The integral of 0.1 to 1.3
of this particular integrand and it turns out to be 0.89387. You can do it as homework, all you
do is use integration by parts to do that. So, the true error, in this case, will be the exact value,
which is here, minus the approximate value, which is here, and so the true error is 0.05002.
It's also asking you to calculate the absolute relative true error.
That is nothing but the exact value minus the approximate value divided by the exact value
times 100. If you're calculating terms of percentages and this turns out to be 5.59%. So,
giving indication that using three segment trapezoidal rule gave us a reasonable amount, a
reasonable value of the estimate of the integral. And, of course, if we increase the number of
segments, we expect to get even better results than that and that is the end of this segment.