 Welcome back everyone. Let's talk some more about finding numerical approximations to integrals when the funnel theorem calculus either doesn't apply or we can't use it very effectively. In the previous example that we did we were able to calculate the exact answer to the integral we were we were trying to approximate and we compared that answer to the approximation we had with with the exact value and the approximation becomes very easy to determine what the error is in such a calculation. But how can one determine what the error is if you don't actually know what the exact result is because if you know what the exact result is why you approximate in the first place. And so we had kind of mentioned before that when you consider the graph of our continuous function f can the geometry of that graph there, the left hand rule l n is going to overestimate the area under f when f is decreasing and underestimates it when f is increasing. And conversely the right endpoint rule r n is going to underestimate the area under f when it's decreasing and it'll overestimate the area under f when f is increasing. Some similar statements can be said about the midpoint rule and the trapezoid rule. This idea of increase and decreasing this is the monotonicity of a function related to that is actually the concavity of the function that is do we concave upward do we concave downward something like this. Well when you consider the trapezoidal rule right the trapezoidal rule takes the points at the end points the left and right and you connect them with the secant line, and then you form your trapezoid using something like that. You can see that when the graph is concave upward the track the secant line is going to live above the curve and thus it's going to overestimate the area under the curve. Conversely, if your graph is concave downward the trapezoid rule is going to underestimate the value there, given that the secant line will then be below the curve when it's concave downward. So if we kind of summarize what we just saw right then and there, we can say that for the trapezoid rule TN, when you are concave up, what did we say when you're concave upward you're going to overestimate. And then when you're concave down, you're going to underestimate the value there. Well what about the midpoint rule? It turns out it's very similar in nature right if you are concave up versus concave down. The midpoint rule remember it uses the tangent line to the curve at the so-called midpoint and it calculates the area using that. And we see that when you're concave down, sorry concave up it'll underestimate and of course when you are similar of speaking, when you are concave down you're going to overestimate the area there. And that's because when you're concave down the tangent line will be above the curve and when you're concave up the tangent line will be under the curve. So the midpoint rule we see does the opposite it's going to underestimate when you're concave up and it's going to overestimate when you're concave down. So much like the left and right rule we can make some predictions about whether we can over and underestimate things. And so the point I bring this up is the concavity does tell us something about how effective the trapezoid and midpoint rules are giving us here. So the concavity we use the second derivative. So with that in mind, let me present you some error bounds to the midpoint and trapezoid rules here. So to begin, let's consider the second derivative of our function F. So if the second derivative is bounded by some value K, right, so the absolute value of the second derivative is bounded above by some value K while X lives between A and B. We interpreted the left and right bounds of our integral. So with these, so with this bound K, it can be shown that the error associated to the trapezoid rule. So remember this is going to be the absolute value of the integral from A to B, F of X DX minus T in. So this is the error of using the trapezoid rule to estimate the area under the curve, which is the integral right there. So the error of the trapezoid rule is going to equal K times B minus a cubed over 12 in squared. So again, B and A, these are the bounds of the integral K is this bounding value on the second derivative which measures concavity. And then in here, N is the number of rectangles number subdivisions you use. And it turns out this error bound that is this bounds the error the error can never be worse than this value right here. The reason why this error bound is useful is that if we can force the error bound to be small, that will force the actual error to be small as well. So even if we don't know what the error is, we can force the error to be small by guarantee the error bound is small as well. And for the most part, this is a pretty simple calculation. The only difficulty is coming with an appropriate choice of K here. And we typically want K to be as small as reasonably possible because the smaller K is, then we can choose smaller values of N, which is the whole point of this as well. The midpoint rule follows a very similar formula, the error of the midpoint rule. So this is going to be the difference between the true value under the curve and the approximation for the midpoint rule. This is going to equal K, we can use the exact same K value, b minus a cube, that's identical right there. And by this time we get 24 in squared. And so that's the difference between the trapezoidal and the midpoint rule here is that with the midpoint rule, we actually expect half the error because having a 24 would just twice 12, you actually expect only half the error. On average, we would expect the midpoint rule to be twice as accurate because it is half the error compared to the trapezoid rule. So that's one reason we like the midpoint rule very well here. Notice that as the interval gets bigger, b minus a, that's the length of the interval. As the interval gets bigger, bigger, bigger, you're going to cube it. So the longer the interval, the harder it is to approximate the area. But in contrast, you have an n squared that shows up on the bottom. The more n's, the more rectangles you use, the more subdivisions, the bigger the denominator is going to be. And then that makes it a smaller fraction. So the idea here is small area, small length of the interval and large number of subdivisions. So that will give you a good bound. So if we were to apply this to the previous examples we had done, that is we were looking at the function f of x equals one over x, like so. We could see that it's the first derivative. This is going to equal negative one over x squared. It's second derivative just by the power rule here. You're going to end up with positive two over x cubed. Could we find a bound for this? Because we were looking at the interval from one to two, one over x dx. How do we make sure that this thing is small? Our interval is from one to two. And I want to note here that on this function two over x cubed, this function is decreasing. It's decreasing on the interval one to two. We could detect that, of course, geometrically just if we think of the graph of this function two over x cubed. The basic graph is going to look something like this from one to two. You could also take a look at the third derivative because the third derivative here you would see is completely negative and therefore it's going to be decreasing. The reason I mentioned this is the function is decreasing from one to two. Where is the largest value going to be obtained? Well, the largest value is going to be happening at the left endpoint when x equals one. The y value is going to equal two over one cubed, which is two. And so we can see that two is actually going to be the k value that we select. Over here, if you look at the point two, that's going to be much, much smaller. You end up with one fourth in that situation. So because it's decreasing, choose the maximum over here on the left, and that's going to take our k value to be two. So with the k value of two, we can see that the error of the trapezoid rule, which we actually computed it earlier, the error we got was 0.002488. By this error bound, this should be smaller than two times the length of the interval two minus one cubed over 12 times n squared. We had five, so that's a five squared there. You're going to end up with, when you're done with this, two minus one, of course, is one. Two over 12 times 25, which should be 300. So you get two over 300, or one over 150 running into my space there. Let me move the screen. So our estimate, one over 150, as a decimal, that'll be approximately 0.0066. It just repeats after that, right? And so we see that our estimate is much, the actual error of 0.002 is much smaller than this error bound, 0.006. We're actually about a third of what it is. But if we don't know what the error is, if we don't know that, we still at least know that it's at least accurate to two decimal places. We're not quite the third yet. We can't guarantee that. Now, if we did the same thing for the midpoint rule, right? Our estimate we had before was 0.001239. If we look at the error bound, you get two times two minus one cubed over 24, five squared. This is just going to be half of what we had before, one over 300. And so this will be approximately 0.00333, etc., right? And so again, our error was much better than that, about a third of that. But because this error bound is much smaller, we anticipate that on average the midpoint rule is going to be doing much, much better than the trapezoidal rule.