Lesson Video: Numerical Integration: The Trapezoidal Rule Mathematics • Higher Education

In this video, we will learn how to approximate definite integrals using the trapezoidal rule and estimate the error when using it.

15:37

Video Transcript

In this video, we’ll learn how to approximate definite integrals using the trapezoidal rule and estimate the error when using it. You’ve probably already seen that the exact area between a curve and the π‘₯-axis can be found by performing a definite integral of the function that describes that curve between the two points you’re interested in. When approximating the integrals and therefore the area, we commonly use rectangles. These are known as midpoint sums and Riemann sums. In this video, we’re going to investigate how using trapezoids can actually often give a better approximation than rectangular sums that use the same number of subdivisions. And then derive a formula for what is commonly known as the trapezoidal rule.

Let’s imagine we’re wanting to approximate the area between the curve given by the function 𝑓 of π‘₯ equals eight minus two π‘₯ squared plus three π‘₯ and the π‘₯-axis. Bounded by the lines given by π‘₯ equals zero and π‘₯ equals two. At this point, we have a few different methods. We might use a midpoint sum, whereby we break the area up into rectangles. Let’s say two of these and to find the height of the rectangle as the value of the function at the midpoint of each interval. Well, that is one method. But let’s consider the shape of the curve. Wouldn’t it make sense to choose a different shape than a rectangle? Well, we can actually try trapezoids.

Let’s assume we want to use four subintervals now. Our trapezoids would look a little something like this. Notice that this does indeed appear to give a better approximation than using rectangles. And we can use the formula for the area of the trapezoid to calculate the total area between the curve and the π‘₯-axis. This is a half times π‘Ž plus 𝑏 times β„Ž. Where π‘Ž and 𝑏 are the lengths of the parallel sides of the trapezoid. And β„Ž is the height between them. We can see by observation that the height of each of our trapezoids is equal to the width of the subinterval. Here, that’s 0.5 units.

We can use the equation of our curve to work out the lengths of each of the parallel sides. And it can be useful to include a table at this stage. Somewhat counterintuitively with four subintervals, we’ll have five columns. And in fact, that’s always the case. We will always have one more column than the number of subintervals. The length of the first parallel side in the first trapezoid is given by 𝑓 of zero. That’s eight minus two times zero squared plus three times zero, which is eight. The second parallel side in this first trapezoid is eight minus two times 0.5 squared plus three times 0.5, which is nine. 𝑓 of one is eight minus two times one squared plus three times one, which, despite a poorly drawn graph, is also nine. And in a similar way, we obtain 𝑓 of 1.5 to be this height here. And that’s eight. And 𝑓 of two to be this height here. And that’s six.

We’ll now calculate the area of each of the trapezoids. The first trapezoid has an area of a half times eight plus nine times 0.5, which is 4.25 square units. The second has an area of a half times nine plus nine times 0.5, which is 4.5 square units. The third has an area of a half times nine plus eight times 0.5, which is once again 4.25. And our final trapezoid has an area of a half times eight plus six times 0.5, which is 3.5 square units. The sum of these is 16.5. And we know that we commonly use definite integration to evaluate the area under the curve. So we can say that an approximation to the definite integral evaluated between zero and two of eight minus two π‘₯ squared plus three π‘₯ is equal to 16.5. Well, this is all fine and well. But you might be thinking, surely there must be a quicker way of performing this calculation. And you’d be in luck; there is. Let’s take a generic function 𝑓 of π‘₯ and split it into 𝑛 subintervals.

We’ll say that the height of each trapezium is Ξ”π‘₯. We saw that the lengths of the parallel sides of the first trapezoid are found by substituting our first value of π‘₯ and our second value of π‘₯ into the function. So we can say that π‘Ž one is equal to a half times 𝑓 of π‘₯ nought plus 𝑓 of π‘₯ one times Ξ”π‘₯. Similarly, our second trapezoid will have an area of a half times 𝑓 of π‘₯ one plus 𝑓 of π‘₯ two times Ξ”π‘₯. Our third will have an area of a half times 𝑓 of π‘₯ two plus 𝑓 of π‘₯ three times Ξ”π‘₯. And only continue until the 𝑛th trapezoid, which will have an area of a half times 𝑓 of π‘₯ 𝑛 minus one plus 𝑓 of π‘₯ 𝑛 times Ξ”π‘₯.

The total area under the curve and therefore an estimate for the definite integral of 𝑓 of π‘₯ between the first π‘₯-value and the last π‘₯-value is the sum of these. When finding their sum, we can factor a half and Ξ”π‘₯. And we obtain the total area of the trapezoids to be Ξ”π‘₯ over two times 𝑓 of π‘₯ nought plus 𝑓 of π‘₯ one plus another 𝑓 of π‘₯ one. Plus all the way up to 𝑓 of π‘₯ 𝑛 minus one plus another 𝑓 of π‘₯ 𝑛 minus one plus 𝑓 of π‘₯ 𝑛.

Now we can simplify this a little further to obtain the general formula for the trapezoid rule using 𝑛 subintervals. We combine all the 𝑓 of π‘₯ ones, all the 𝑓 of π‘₯ twos, all the way through to all the 𝑓 of π‘₯ 𝑛 minus ones. The rule is Ξ”π‘₯ over two times 𝑓 of π‘₯ nought plus 𝑓 of π‘₯ 𝑛 plus two times everything else. 𝑓 of π‘₯ one plus 𝑓 of π‘₯ two all the way through to 𝑓 of π‘₯ 𝑛 minus one. And Ξ”π‘₯ can be obtained really easily. It’s 𝑏 minus π‘Ž divided by 𝑛, where π‘Ž and 𝑏 are the beginning and end of our interval. And our values for π‘₯ subscript 𝑖 are found by adding 𝑖 lots of Ξ”π‘₯ to the lower limit of our interval. That’s π‘Ž plus 𝑖Δπ‘₯. We’re now going to have a look at the application of this rule.

Use the trapezoidal rule to estimate the definite integral between zero and two of π‘₯ cubed with respect to π‘₯ using four subintervals.

Remember, the trapezoidal rule says that we can find an approximation to the definite integral between the limits of π‘Ž and 𝑏 of 𝑓 of π‘₯ by using the calculation Ξ”π‘₯ over two times 𝑓 of π‘₯ nought plus 𝑓 of π‘₯ 𝑛 plus two lots of 𝑓 of π‘₯ one plus 𝑓 of π‘₯ two all the way through to 𝑓 of π‘₯ 𝑛 minus one. Where Ξ”π‘₯ is equal to 𝑏 minus π‘Ž over 𝑛. And π‘₯ subscript 𝑖 is equal to π‘Ž plus 𝑖 times Ξ”π‘₯.

Let’s break this down and just begin by working out the value of Ξ”π‘₯. Contextually, Ξ”π‘₯ is the width of each of our subintervals. In this case, we’re working with four subintervals. So we could say that 𝑛 is equal to four. π‘Ž is the lower limit of our integral. So π‘Ž is equal to zero, where 𝑏 is the upper limit. And that’s equal to two. Ξ”π‘₯ is therefore two minus zero over four, which is one-half or 0.5. The values for 𝑓 of π‘₯ nought and 𝑓 of π‘₯ one and so on require a little more work. But we can make this as simple as possible by adding a table.

It’s useful to remember that there will always be 𝑛 plus one columns required in the table. So here, that’s four plus one, which is five. We have five columns in our table. The π‘₯-values run from π‘Ž to 𝑏. That’s zero to two. And the ones in between are found by repeatedly adding Ξ”π‘₯, that’s 0.5, to π‘Ž, which is zero. That’s 0.5, one, and 1.5. And that gives us our four strips of width 0.5 units. We’re then simply going to substitute each π‘₯-value into our function. We begin with 𝑓 of zero. That’s zero cubed, which is zero. Next, we have 𝑓 of 0.5. That’s 0.5 cubed, which is 0.125. 𝑓 of one is one cubed, which is still one. And we obtain the final two values in a similar manner. 𝑓 of 1.5 is 3.375. And 𝑓 of two is eight. And that’s the tricky bit done with. All that’s left is to substitute what we know into our formula for the trapezoidal rule.

It’s Ξ”π‘₯ over two, which is 0.5 over two, times the first 𝑓 of π‘₯ value plus the last 𝑓 of π‘₯ value. That’s zero plus eight plus two lots of everything else. That’s two times 0.125 plus one plus 3.375. And that gives us a value of 17 over four. So using four subintervals, the trapezoidal rule gives us the estimate to the definite integral of π‘₯ cubed between zero and two to be 17 over four. Now where possible, this can be checked in a number of ways. You could evaluate a Riemann or midpoint sum or here simply perform the integration.

When we integrate π‘₯ cubed, we get π‘₯ to the fourth power divided by four. Evaluating this between the limits of zero and two gives us two to the fourth power divided by four minus zero to the fourth power divided by four, which is 16 over four. And that’s really close to the answer we got, suggesting we’ve probably performed our calculations correctly.

We’ll now consider an example which involves a consideration on accuracy.

Estimate the definite integral between the limits of one and two of 𝑒 to the power of π‘₯ over π‘₯ dπ‘₯, using the trapezoidal rule with four subintervals. Approximate your answer to two decimal places.

Remember, the trapezoidal rule says that we can find an estimate for the definite integral of some function 𝑓 of π‘₯ between the limits of π‘Ž and 𝑏 by performing the calculation Ξ”π‘₯ over two times 𝑓 of π‘₯ nought plus 𝑓 of π‘₯ 𝑛 plus two times 𝑓 of π‘₯ one plus 𝑓 of π‘₯ two all the way through to 𝑓 of π‘₯ 𝑛 minus one. Where Ξ”π‘₯ is 𝑏 minus π‘Ž over 𝑛, where 𝑛 is the number of subintervals. And π‘₯ 𝑖 is π‘Ž plus 𝑖 lots of Ξ”π‘₯. We’ll begin then just simply by working out Ξ”π‘₯. Contextually, Ξ”π‘₯ is the width of each of our subinterval. Here we’re working with four subintervals. So 𝑛 is equal to four. π‘Ž is equal to one. And 𝑏 is equal to two. Ξ”π‘₯ is therefore two minus one over four, which is a quarter or 0.25. That’s the perpendicular height of each trapezoid.

The values for 𝑓 of π‘₯ nought and 𝑓 of π‘₯ one and so on require a little more work. But we can make this as simple as possible by including a table. We recall that there will always be one more 𝑓 of π‘₯ value than the number of subintervals. So here, that’s going to be four plus one, which is five 𝑓 of π‘₯ values. The π‘₯-values themselves run from π‘Ž to 𝑏. That’s here from one to two. And the ones in between are found by repeatedly adding Ξ”π‘₯, that’s 0.25, to π‘Ž, which is one. So these values are 1.25, 1.5, and 1.75. And that gives us our four strips of width 0.25 units. We’re then going to substitute each π‘₯-value into our function.

Here, we’re going to need to make a decision on accuracy. Whilst the question tells us to use an accuracy of two decimal places, that’s only for our answer. A good rule of thumb is to use at least five decimal places. We begin with 𝑓 of one. That’s 𝑒 to the power of one over one, which is 2.71828, correct to five decimal places. We have 𝑓 of 1.25, which is 𝑒 to the power of 1.25 divided by 1.25. That’s, correct to five decimal places, 2.79227. We repeat this process for 1.5. 𝑓 of 1.5 is 2.98779. 𝑓 of 1.75 is 3.28834. And 𝑓 of two is 3.69453 rounded to five decimal places. All that’s left is to substitute what we know into our formula for the trapezoidal rule. It’s Ξ”π‘₯ over two. That’s 0.25 over two times 𝑓 of one. That’s 2.71828 plus 𝑓 of two. That’s 3.69453 plus two lots of everything else essentially. That’s 2.79227, 2.98779, and 3.28834. That gives us 3.0687, which, correct to two decimal places, is 3.07.

It’s useful to remember that we can check whether this answer is likely to be sensible by using the integration function on our calculator. And when we do, we get 3.06 correct to two decimal places. That’s really close to the answer we got, suggesting we’ve probably performed our calculations correctly. And so an approximation to the integral evaluated between one and two of 𝑒 to the power of π‘₯ over π‘₯ dπ‘₯ is 3.07.

In our final example, we’re going to look at how to find the error in our approximation. It’s outside the scope of this video to look at where this comes from. But the formula we’ll use is given by. The absolute value of the error is less than or equal to π‘š times 𝑏 minus π‘Ž cubed over 12𝑛 squared. And this could be used when the second derivative of the function is continuous. And π‘š is an upper bound for the modulus of the second derivative over the closed interval π‘Ž to 𝑏.

a) For 𝑛 equals four, find the error bound for the trapezoidal rule approximation of the definite integral of one over π‘₯ evaluated between one and two. And b) How large should we take 𝑛 in order to guarantee that the trapezoidal rule approximation for the integral of one over π‘₯ between one and two is accurate to within 0.0001?

We can see that we’re going to need to work out 𝑓 double prime of π‘₯, the second derivative of the function one over π‘₯. Let’s alternatively write 𝑓 of π‘₯ as π‘₯ to the power of negative one. Then 𝑓 prime of π‘₯, the first derivative, is negative π‘₯ to the power of negative two. And 𝑓 double prime of π‘₯ is two π‘₯ to the power of negative three or two over π‘₯ cubed. We know that π‘₯ is greater than or equal to one and less than or equal to two. And that tells us that one over π‘₯ must be less than or equal to one.

So let’s consider what this tells us about the absolute value of the second derivative of 𝑓 of π‘₯. Well, it’s the absolute value of two over π‘₯ cubed. So that must be less than or equal to two over one cubed, which we know is two. So we’re going to take π‘š as being equal to two since this is the upper bound for the second derivative in this question. π‘Ž is one and 𝑏 equals two. And we’re told in the question that 𝑛 is equal to four. And this means the absolute value of our error is less than or equal to two times two minus one cubed over 12 times four squared, which is roughly equal to 0.01041 and so on. We can therefore say that the absolute value for the error is less than 0.01042, correct to five decimal places.

Then, for part b of this question, we’re going to use what we did in part one. This time though, we’re trying to work out the value of 𝑛. So we say that the absolute value of our error is less than or equal to two times two minus one cubed over 12 times 𝑛 squared, which simplifies to one over six 𝑛 squared. We need this to be less than 0.0001. So we form the inequality one over six 𝑛 squared is less than 0.0001. And we solve for 𝑛. By rearranging, we obtain the inequality 𝑛 squared is greater than one over 0.0006. And then we find the square root of both sides. We don’t here need to worry about the negative square root of one over 0.0006. As we know, by definition, that 𝑛 must be a positive number. So we obtain 𝑛 to be greater than 40.824. For us to be able to guarantee that the approximation is accurate to within 0.0001, we’re going to let 𝑛 be equal to 41.

In this video, we’ve learned that the trapezoidal rule approximation could be used to approximate definite integrals. We obtained the formula for the trapezoidal rule approximation as shown. And we saw that, under certain circumstances, we can establish the error involved in these approximations by using this formula.

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy.