 Welcome back everyone. We are now gonna introduce one last approximation method for integration. Up until now, we've have approximated the area under the curve using rectangles for the most part, like the left rule, the left endpoint rule, the left endpoint rule, the right endpoint rule, and the midpoint rule can approximate the area using rectangles. And we've also used trapezoids, right? The trapezoidal rule that they suggest uses trapezoids to model the area under the curve. But also the midpoint rule could be thought of as a trapezoidal rule as well. And trapezoids we've seen have worked better than just rectangles themselves because using CK entertainment lines, we could try to match the curvature of the function using a slanted line than just a flat line. And so these methods altogether, rectangles versus trapezoids and such, this essentially boils down to approximating the neighborhoods of the graph, y equals f of x using just straight lines. Again, slanted lines are better than flat lines, but still straight lines can only do so well when you have a curvy function of some kind. So our last method, which is known as Simpson's rule, is going to equate to approximate the neighborhoods of the graph using parabolas. And the idea is a parabola actually has nonzero curvature to it. And so a parabola could potentially fit the curve better than just a straight line here. Now with Simpson's rule, like before, we're gonna subdivide the domain into small pieces. We have like an x0, x1, x2, x3, x4, all the way up to xn right here. In this illustration, you see there's 10 x's, but we can have as many as we want. One stipulation we do have to have though for Simpson's rule is we have to have an even number of subdivisions. So like here we can do 10 subdivisions, we could do 12, we could do 100, we can't do 101 and we'll explain why in a little bit why that's the case. So we're gonna divide up the domain into an even number of subdivisions and we're gonna make sure that each subdivision is equal length. So the distance from x0 to x1 is the same as the distance from x1 to x2, which is the same as the distance from x2 to x3. And all of these are gonna be delta x with the usual meaning as before, b minus a, it's the length of interval divided by n, the number of subdivisions. That part is the exact same, all right? But like I said, unlike before, n has to be an even number for this to work. So we have to have, we could do 10, we couldn't do nine. And so for the reason for this is gonna be the following reason. A little bit like I've explained here, what we're gonna do is that if we have n subdivisions, we're only gonna have n over two parabolas. So the number of regions is actually gonna be half of the total amount. So it has to be an even number. And so the reason why we need that is in order to draw a line, we only have to have two points. Two points determine a line. But to determine a parabola, we actually need at least three points to fit, to fit to a parabola. And so you can see here, you're gonna take, you're gonna take the coordinate at f of x0. You're gonna take the coordinate of f of x1 and you're gonna take the coordinate at f of x2. And so with three points, this will uniquely determine a parabola. And also be aware that if the three points were perfectly co-linear, the parabola it would determine would just be a straight line. That's a possibility here. But more likely, the three points we find will be non-colonial points. And we can get a unique parabola that fits those points. And so if you take the points x2, x3, x4, there's a unique parabola that fits those between x4, x5 and x6. There's a unique parabola that fits those. And we keep on doing this. We take these points. So the odd numbers are gonna serve at the odd positions like x1, x2, x5. They're gonna be the midpoints of these intervals. The even ones, zero, two, four. They're gonna be the endpoints here, right? But notice that two, four, six, eight, who do we appreciate? They're actually gonna show up twice. They're gonna be the left endpoint of one and the right endpoint of another. The very bookends x0 and x10 in this picture, they're only gonna show up once. That's an important distinction that I'm gonna show you in a second why that is. All right, so we fit parabolas to fit through these three points. You need three points to determine a parabola. Let's kinda clean this thing up here then. So we have this diagram for these things and you can see in this diagram that the parabola fits the curve much better. Like if you look from x4 to x6, you can hardly tell the difference between the function and the parabola. Just the curvature is just so much more effective here. All right, and so let's talk about the formula. So Simpson's rule will have the following formula, Sn. So this is the Simpson approximation using n subdivisions where n is an even number. You're gonna take delta x divided by three and you're gonna times that by the sum where you take f of x0 plus four times f of x1, two times f of x2, four times f of x3, two times f of x4 and this pattern will continue, continue, continue till you get two f of x2n minus two, four times f of xn minus one and then finally f of x, f of x in there, all right? So let me try to tell you how you should think about this function. Let's first talk about the delta x over three. Delta x over three, where does this thing come from? Well, delta x is multiplied everything because that's gonna be the thickness of these things. You know, that's gonna be the width of this. So, admittedly that's half of the width but it'll be taken care of that. With all of these approximations, we always multiply delta x, that's an important part. Where did the one over three come from? This really comes from the fact that if you integrate x squared dx because we can find the area under a parabola because you can integrate that using the fundamental theorem of calculus. The airtight derivative of x squared is a one-third x cubed plus a constant. Of course, the plus c cancels out when you do these things as definite integrals for me to be right. But, notice that as you take the anti-derivative of a quadratic, there's a one-third that pops out. And that's essentially why there's a one-third in this formula, okay? The other things to look at is the very first term, f of x zero, it has a coefficient of one. And the very last term, f of x in, will have a coefficient of one as well. And the reason for that is x in will only show up in the first parabolic rectangle. And x in will only show up in the very last parabolic rectangle. So because of that, there's only gonna be a coefficient of one there. Then you'll notice you're gonna have terms four f of x one, two f of x two, four f of x three, two f of x four. And this pattern will continue where you get a four and then a two and then a four and then a two and then a four and then a two and then it continues on. So you always get this pattern. So your sequence, your coefficients and symptoms will look like one, four, two, four, two, four, two, four, dot, dot, dot, two, four, one. You'll start and end with a one, then you'll have four and four and it'll alternate four, two, four, two, four, two. Make sure you end with a four, not with a two, right? Well, what's basically if you use the diagram below, you're gonna get one, four, two, four, two, four, two, four, two, four and one. So the left, the left endpoint, the right endpoint of the whole interval will get a one. Each midpoint gets a coefficient of four and the other terms get twos. And the main reason why there's a difference between the midpoints and these endpoints right here is because the endpoint x two is associated to this parabolic parabola and this parabolic parabola. And since it shows up twice, there's some combination for which you get a different coefficient and such. If you wanna see the exact details behind Simpson's rule, please open up the written lecture notes for this video. There's a complete proof of that, but in this video, I'm gonna proceed on to do a calculation here. So let us do Simpson's rule. I wanna approximate the integral for one to two of one over x dx using Simpson's rule with 10 subdivisions. Just so we're clear, we have already calculated this once before. We see that this integral is actually equal to the natural log of two, which is approximately equal to 0.693147. So keep that in mind as we do this calculation. So with this approximation, we have our delta x, which will be two minus one over 10. So we get one 10th or just 0.1 if we prefer. And so if we think about our interval, right, we're gonna go from x zero all the way up to x 10. So we're gonna get one, two, three, four, five, six, seven, eight, nine and 10. And so what are the numerical values here? You're going to get, we start at one, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, and two. These are the values that we have to compute. So Simpson's rule S10, this will equal our delta x, 0.1 over three. And then we have to plug these numbers into our function and our function here is f of x equals one over x. You take the reciprocal. So we're gonna have one plus four times one over 1.1. Then we're gonna get two times one over 1.2. Then we're gonna get four times one over 1.3. We get two times one over 1.4. We're gonna get four times one over 1.5. We're gonna get next two times. We have this alternating pattern of twos and fours, 1.6. We get four times one over 1.7. We're gonna get two times one over 1.8. We get four times one over 1.9. And then finally, we're gonna get just one times one over two, which is one half. So we have this monster of a number in front of us, right? We wanna simplify this arithmetic, use your calculator. At the very least use a scientific calculator to do this. And if you add these things up very carefully, you will end up with 0.693150. And so compare that with the calculation we had before, right? The natural log of two. Remember, you can't see it on the screen anymore, but it was 0.693147, right? And so if we calculate the error associated to Simpson's rule, this is gonna be the difference of these two numbers. And so if you subtract this one from the other, taking the absolute value because we want a positive number, you're gonna get 0.000, maybe sure I get the right number of zeros here, 0,000, there's five zeros there, three, right? So it's accurate to one, two, three, four, five decimal places and almost another one, right? We're pretty close to that right there. And so I want you to compare this error with what we had before, right? Because we did the same calculation using the midpoint rule, MN, and we also did the trapezoid rule. So for the midpoint rule, remember our error turned out to be, where was it? Turned out to be 0.001239 and the error of the trapezoid rule when we did the same exercise before, that one was 0.002488, right? So you can see that the Simpson rule here was far more accurate than the other ones. Now you might think that this is sort of like comparing apples to oranges, right? Because this was the midpoint rule for five and this was the trapezoid rule for five and we did the Simpson rule for 10, right? So that might seem a little unfair, but remember how Simpson's rule is computed here. S10 is gonna use five parabolic rectangles while this one's using five rectangles and this one here uses five trapezoids. So it really is a fair comparison here and we see that Simpson's rule just dominates. It just demolishes the other ones in terms of their accuracy and we'll see in the next video why Simpson's rule is such a more accurate technique for which it probably makes sense given how a Kirby function will be modeled better with curves in his straight lines. I also wanna mention that we can calculate these things using online software, computer software and such. I'm gonna use another calculator from emathhelp.net. Again, the ads on this website are super hideous, but I've changed it so that we can do, we won't be bothered by those ads in this thing. And so it is set up ready to go, right? Simpson's rule, so it's sometimes called the parabolic rule, but Simpson's rule calculator, we wanna do the function one over X, we're gonna go from one to two and we're gonna have 10 subdivisions. So it should be good to go. Like the other one, if you want, you can show all the steps by having this box clicked at the bottom. If not, just hit calculate. I mean, if you don't wanna see the steps, you can unclick it. We'll leave the steps on. In which case it shows us step by step what we had to do. So our delta X turned out to be one-tenth. We go from one to two and we have all these subdivisions right there. It wrote them as fractions, but we did them with some decimals. That's okay as well. We get all these estimations here, all these calculations, and then put it together. You're gonna get one over 10 divided by three. That's one-thirty. If you add those all together, you end up with 0.69315, which is the SN, which we had earlier. Feel free to use calculators like this one to help you with your calculations and your homework and such. Realizing that you should know the formulas behind the midpoint rule, symptoms rule and such, but by all means, even if you know the formula, but yet a calculator help you so you don't have to go through all of this tedious calculations. The calculator doesn't complain. It doesn't have a brain, right? It has no, it was never programmed to complain about arithmetic. Use that calculator to help you with your calculations so your approximations are accurate and correct.