CHAPTER 07.03: SIMPSON'S 1/3RD RULE: Multiple Segment: Derivation: Part 1 of 2   In this segment, we're going to derive the multiple segment Simpson's 1/3 rule. In the previous segment, I showed you the motivation for developing the multiple segment Simpson's 1/3 rule, but in order to be able to algorithmically be able to apply Simpson's 1/3 rule, we do need to derive a formula for it, so that we can program it as a function or subroutine, if we want to integrate functions by using Simpson's 1/3 rule.  So if we look at, again, a general example, that we want to be able to integrate a function going from a to b, and that's what we are trying to do, numerically, that we want to integrate the function going from a to b numerically. So what we're going to do is, in order to be able to apply multiple segment Simpson's 1/3 rule, we're going to divide the interval from a to b into n equal segments.  So what that means is that each segment width will be equal to b minus a, divided by n, where n is the number of segments we're going to divide our interval from a to b into.  However, what you've got to recognize is that n has to be even . . . n has to be even, it has to be an even integer.  The reason why it has to be and even integer is because, if you look at the single application of Simpson's 1/3 rule, it is applied over two segments.  So if you're going to apply, let's suppose, Simpson's 1/3 rule twice, it'll be four segments, three times, six segments, so all of these numbers which you are hearing now, they're all even, so it has to be even.  So what we're going to do is we're going to break it up into n equal segments, and let's suppose I'm going to call this for x0, and I'm going to call this xn, for convenience sake.  Although there is no difference between x0 and a, and xn and b, this is only being done for convenience so that when I write the formula, that it looks neat and tidy, and I'm going to break it up into n equal segments.  So that means that if I have n equal segments like this, each of these widths, which is going to be h, will be equal to b minus a, divided by n, that's what the distance between each of the points will be when I draw these segment points.  So I'm going to draw it again a little bit larger, just the x-axis, so that we can see that what we are trying to do. So this is what I'm going to do here.  So I'm just drawing the x-axis, so we have x0 here, and we have xn here, and if we are going to break it up into n equal segments, this next segment will be x1, that next segment will be x2, then there'll be x3, there'll be x4, and will continue to take place until I, for example, I get here I get x-sub-n-minus-2, and here I'll get x-sub-n-minus-1. So those will be the points along the x-axis when I am integrating from a to b, x0 is nothing but a, xn is nothing but b, we already know that. So what we're going to do is we're going to apply Simpson's 1/3 rule over two segments, like this, then apply the Simpson's 1/3 rule again on those two segments, then again on the next two segments, and so on and so forth, all the way up to the last two segments, like that one, and that's how we're going to derive the formula for the multiple segment Simpson's 1/3 rule. So what that means is that we have this integral going from a to b, f of x dx, and just for convenience, we are rewriting our lower limit of integration to be x0, upper limit of integration to be xn, and we're going to write it like this. So there's no difference between what I'm writing here and what I'm writing here, the only thing is that I'm renaming the convention that x0 is a and xn is b.  And now what I'm going to break this integral into n parts . . . or n divided by 2 parts, actually.  I'm going to say x0 to x2, so not x0 to x1, but x0 to x2, because I have to apply the Simpson's 1/3 rule over two segments.  I have to apply the Simpson's 1/3 rule over two segments, so that's why I'm breaking this integral from x0 to xn to x0 to x2, x2 to x4, and so on and so forth.  So I'm going to do something like this, this x0 to x2, f of x dx, then I'm going to go from x2 to x4, f of x dx, and then I'll continue to do this, until, let's suppose, I'll look at the last two steps here of breaking this, I'm going to say xn-minus-4 to xn-minus-2, f of x dx, so these are those limits of integration, and then the last one, it'll be x-sub-n-minus-2 to xn, f of x dx. So what you have done is that you have broken up the integral from x0 to xn into n divided by 2 such integrals, because n is the number of segments, and since a single application of Simpson's 1/3 rule is over two segments, the number of integrals which you'll have, which will look like this, will be n divided by 2, and again, i has to be even, otherwise you'll have something remaining. So let's go ahead and apply now the Simpson's 1/3 rule over each of . . . for each of these integrals.  So I'm going to apply Simpson's 1/3 rule on this integral, I'm going to apply Simpson's 1/3 rule on this integral, I'm going to apply Simpson's 1/3 rule on this integral, and on this integral, and everything in between, which I have not shown here, between the second integral and the second-last integral.  So let's go ahead and see that how we can . . . we're going to apply that, that means that this is approximately equal to x2 minus x0, divided by 6, times the value of the function at the lower limit, plus 4 times the value of the function at the middle point, which is x1, plus the value of the function at the upper limit of integration, which is x2, right?  So that's the first approximation . . . approximation for the first integral.  Now I'm going to look at the approximation for the second integral will be x4 minus x2, divided by 6, times the value of the function at x2, plus 4 times the value of the function at the midpoint, which is x3, plus the value of the function at x4. Now, keep in mind that x3 is nothing but the midpoint between x2 and x4, which is simply x2 plus x4, divided by 2, but again, we're not writing x2 plus x4, divided by 2 as the argument of the function here, mainly for convenience sake. Then we'll have several of these integrals approximations which we will write, and then we'll write down the approximation for the second-last integral, which is x-sub-n-minus-2 minus x-sub-n-minus-4, divided by 6, times the value of the function at the lower limit of integration, which is x-sub-n-minus-4, plus 4 times the value at the midpoint, plus the value at the upper point, so that's what I get there.  Then plus, for the last integral, I'll have upper limit minus lower limit, divided by 6, times the value of the function at the upper limit . . . sorry, lower limit, plus 4 times the value of the function at the midpoint, and the value of the function at the upper limit there.