 We finished pretty much with technical integration, and you notice the clickers today because an issue with the laptop is a little bit different than it was today. The midterm is two weeks from tomorrow night. It will cover stuff that we haven't done yet. It will cover through section 6.3, which we will definitely get to before midterm. It's just going to sound very loud. Can you hear anything? If you're having, I've been receiving increasing emails about, this is hard, I can't do it. If you can't do it, this is why we have office hours, there's a lot of stuff available. So the math learning center is open for quite a number of hours. It tends to be open for something like 10 to 8, Monday through Thursday, and Friday until about 3. The drawback of the math learning center is it's drop-in, and so you get, and sometimes you have to fight for it all. There are, I think, eight of us associated with this course. Each of us have three office hours, and that makes 24 office hours. A number of them are in the math learning center, but there's still quite a few that you can use. And you can also make a point that's outside of office hours. I've seen exactly two people so far in this course for office hours. That's pretty bad, that was 340. There's not 340 in this room, but still. You know, I don't mind if you don't come, I've got stuff to do, but I'm there in case you have questions. Anything else? Any questions or issues people are having? Does that go along with academics? Does that mean, like, if you're having problems with other stuff? If you're having problems with material, sure. Well, then you should ask. Okay, great. Yeah! Sorry, go ahead. So the partial fractions, I want to say, I mean, I can go over one more partial fractions, but I've sort of gone over that. So I would recommend that what you lose, that you have a problem with the partial fractions and the integration by partial fractions. Come see me after. And we'll work it together. You know, I kind of said all that, but if you'd like to say anything. If you have a specific question about partial fractions, during relation by partial fractions, do you have one? It's the whole idea. Okay, so then definitely that's an office hour kind of thing. Other questions or issues people are having? I guess not, because I just asked and I shot it down. So I suck. Okay, so let's move on. So I want to point out a few things. We've covered all the basic techniques, in fact, less than basic, all of the techniques of integration. You know, there's some special tricks that you can use hyperbolic signs and things like that. But for the most part, that's it. You should be able to do pretty much probably more integral than I can do, because I'm actually not very good at doing anything. There are a lot of, and I was going to show it, but I don't have the laptop, there are computer programs that can integrate better than anybody. So there's a program called Maple, which you can download from software. You have a site license for it by virtue of being a student here. There's a program called Mathematica, same thing. There's a free program called Octopus. There are a number of programs where you just type in the integral and you, you know, in syntax like it, q, x, and it says the answer is one-fourth x and four. So it just does the integral for you. So there are programs that will do this stuff for you probably better than either you or I can do. They do a whole lot more than just that. Because integration isn't just a very mechanical process. There's a bunch of techniques. You mess around with it, out comes the answer. Same thing with derivatives and so on. But there's a lot of things. So how would you do this integral? Try parts. I would try parts too. It won't work. Then what? Whatever you try, it won't work. So this integral or this integral or let me get another one. It doesn't have an e in it, about that one. Well this one sort of has an e in it. This integral or give only the sign. Sign in so we're actually sure. This integral, this integral, these integrals and hundreds of others, thousands, infinitely many others. None of these integrals have nice formula to express what they are. But they are well defined functions. They make sense. They are real things. They represent actual quantities. So there's an area underneath the curves involved in all of these things. So there's an integral here. But we just don't have symbols to represent it. Now sometimes we need to use this. People will make up formulas. I think this one has the special name s i. This one I know for sure is something like that. I always forget exactly how it goes. There's this thing called the error function. This guy, forget about this name. This integral, let's look at that integral. So if I graph this, it's a familiar thing. Anybody know what to graph with this one? There's a negative here. Anyone know what to graph with this one? Yes. So this is the bell curve. It looks like that. And it comes up all the time. So this integral of e to the negative x squared dx maybe with a 2 pi and maybe with a half in there and stuff like that shows up all the time especially in statistics. If we want to know how much area there is between here and here this tells us something about the probability of a normally distributed event occurring. This tells us the expected height of people or the expected grade on a big exam or something like that. All these things. So this is something important that we should be able to do. But we have no formula for it except calling it or something like that. We can calculate the value. So how does that work? The way that works is you remember that the integral of a function is in fact the limit as the number of things go to infinity adding up. That's what we did at the start of the class because this is and so you can write a computer program to estimate this pretty easily. You can calculate this with whatever precision you want. If I want to know what is the integral from 0 to 1 half minus X squared BX this is a number. I don't know what it is off the top of my net but I can calculate it to any precision I want. So I can calculate this to a thousand digits if you want it. So what I want to talk about mostly today it's not a hard topic but something we need to cover is how to do this because this comes up a lot of times in applications and some words get thrown around that maybe you've heard before about Simpson's rule. How many people have heard of Simpson's rule? A couple. How many people have not heard of Simpson's rule? Most. So like Simpson's rule or trapezoid method or midpoint method or things like that these are numerical methods for approximated integrals that enable you to do this. And you should have some understanding of what they are even though you probably will never write the computer code yourself you'll just have your computer to do it and it will use some numerical methods to have an idea of what's going on behind the scenes. Do you know what works and what doesn't work and why it does work? So the general idea here is we have our function and we just draw my usual unknown function and I want to calculate this area so what we did in the beginning is we just take a bunch of rectangles and here I'm putting them on the left side so I can just take a bunch of rectangles I have too many in here already like that and in this case I chose the rectangles so that they all sit and just all the left side well this is the left side so if we just add up the area of these rectangles this gives us the left approximation and this is with 1, 2, 3, 4, 5, 6 rectangles and that's you can figure out I think pretty easily what that formula is so well so that's one let me not do that because it's easy another thing I can do is I can make the right approximation and just draw the same function which would be slightly different here I'm using on the right 1, 2, 3, 4, 5, 6 so here's the right approximation and again it's pretty straightforward to figure out the formula here there are 6 6 skies and I'm going from let's say 0 to 3 then the first one since I'm going from 0 to 3 then if I have 6 this one is going to be 1, 2, 3, 4, 5, 6 so this would be 1, 2, 3, 4, 5, 6 to 2.5 pretty pretty and so I'll do an example just to set those are two pretty obvious things that you can do much harder is to try and use the lower approximation so we won't do this but you can know it exists the lower approximation let me just is going to fit my rectangle underneath and every time so sometimes I'll use the right sometimes I'll use the left sometimes I'll use the middle and then there's another approximation where I fit my rectangle over I'm not going to talk about these these are hard you can get hard work hard points and usually you don't know the function well enough to find the points anyway so when will the lower approximation be the same as let's say the left approximation and the slope is always positive so if the function is increasing then the lower will be the same as the left and if the function is decreasing the lower will be the same as the right and if the function has a max or a min then the lower will be mixed and the same about the other I mean reversing okay so that's pretty straightforward and rather than writing down a formula for this we already did these left approximations and right approximations in the first week of classes let's talk about some slightly better ones so using this method is I might have to use a lot of points using end points if I want to get good accuracy I might have to use a whole lot of points so there are some ways we can improve the accuracy and so what is one can anyone suggest what might be a better way to get a better typically better accuracy without using more points I don't know whether you're just like higher he's the only guy who's way yeah so what does that mean so one suggestion is a crap as well which means if I have this function here it is and I have my six rectangles I don't have this name anymore then instead of using rectangles I have to slope on the tops you can see them maybe I should make a curve here just connect the dots so here I just connect the dots I formed a line so what is the what is the area of the trapezoid I guess if you're laying on the side the way I drew it here the base is the same so it's really the average of the two heights so the area like this if this is my let's just call this delta x for my base actually let's call this x1 and x2 these two points so in this case to get the area of this thing then the base x2 minus x1 and the height this height is f of x1 and this height is f of x2 and one way you can remember this is it's the same as the area of the rectangle if I cut this part off and plump it over there then I get a rectangle I cut the top off and fold it over then I get a rectangle of exactly the average height of the arrow the thing is very steep well I guess it is so the area this is going to be the average of the heights now suppose I've already calculated the left and the right approximations what does that tell me the trapezoid approximations are all of the heights on this side and the right guys are all of the heights on that side which is the heights so these two things this guy is just the average but let's write a formula for the trapezoid so suppose I'm going to use n rectangles so I want to integrate from g d f of x well I don't recommend that you memorize these formulas because you'll forget them if you memorize them just draw the picture it only takes a minute if you know what's going on so what we have to do here well the base is in everything right so we're just going to multiply by the base so at every stage I'm going to multiply by the width of my rectangle that's the width of each one of those rectangles and now I just have to worry about the heights so let's worry about the height so let's look at the whole picture rather than just one picture how many right sides are left sides am I going to get one for this rectangle one for this rectangle one for this rectangle so I'm going to get n I'm going to get n left sides and n right sides so I'm going to get some x zero this is the left side and then I'm going to get f of x one this is the left number two and then I'm going to get f of x two f of x three and then I'm going to stop at one before the last this is the left side this is a big parentheses and now I need to add in the right sides well the first one here I don't use this but once I call this the right left side once the second one then I get the right side here and the right side here and the right side here and the right side here and the right side there so I get n right sides but I don't get this one but one part so and then f of x two f of x three and this left side of f of x the last guy but then I get one more let me write that a little cleaner notice that here I get two here I get two except for the first and the last this is going to be one half e minus a over n and I'm going to use let me not use some so then it's the first guy plus twice the second guy plus twice the third guy plus twice the next guy blah blah blah blah plus twice an ultimate guy plus the last one that's a pretty easy formula it's just so if I'm using n rectangles that means I'm going to have I'm going to use my rectangles I'll have six points because I have edges we've got something in half we actually have three ends right from the left side right side and I count everything double except for the two ends and then I average that so I need one half e minus a those are pretty straightforward formulas pretty easy to do let me do an example of an actual function here f of x n it's just a function at the very last one so let me do just to make it obvious I'll do it with a very simple function let's just do x squared so let's I mean this is a stupid example because we can figure out this exactly approximate the reason we're doing it approximately is because everything's easy we would never do this for real but let's do it for real anyway so let's integrate from let's start at one rather than zero let me use four points let me get four four intervals so let's integrate from one to x squared with four squared okay so this is a really stupid example that means I'm going to have five points I need to check at maybe I should go from one to three let's go from one to three but I only have half okay and I'm going to use the trapezoid so this would be t four is the usual notation and this is going to be one half so the total is three minus one is two but I'm doing four rectangles so it's another half we write it as three minus one is four that's half and then the points that I'm doing it on we draw the picture I guess I'm starting here at one and I'm doing four rectangles I'm going out to three so two's in the middle ten and a half and two and a half my function is making that so those are my trapezoids that I'm doing and so I just compute f of one so that's one squared plus twice f of two that's three halves plus twice f of two plus twice five halves plus now the last guy only gets in once so that's three so that's nine over four times two nine halves and that's four times two eight is 25 over four times two so that's 25 over two which is some number I don't know 17 18 plus 30 is 17 is 35 so this is 35 over four when I get 35 over four for this yeah four rectangles I started at one so I didn't use the stuff before one when I started at one I started at one it's the integral from one to three wouldn't it be over two? that's what somebody said somebody made a comment about over two okay so eight to one but now I don't have to find you okay so this is pretty easy it's just a matter of thinking about what you're doing and writing down what you're doing the correct answer of course is x cubed over three evaluated from one to three it says 27 over three minus third is 26 over three which is some number I don't know what that means it's a number it's like eight to two-thirds and that's like eight and three-four this is actually not so bad the back answer is eight four rectangles I can sort of get ballpark with four hundred rectangles I can get really close let me mention let me not do the example another thing you can do here instead of doing trapezoids another thing we can do here instead of doing trapezoids and we can get the same amount of work is to take the midpoints think of the same picture so actually let me just do it so I'm doing the same integral here for midpoints here one to three four bits I have four midpoints the numbers are a little loopier because I have these same intervals one one and a half two two and a half and the points that I want are the middles of those points so I can also I'm not going to do it all out so again it will be two fourths the length of the rectangle is each of them is one and a half those will be four to three I have four of them and now I want to do the function evaluated here at the first middle so the first middle is halfway between one and three halfs which is one point two five for one and a quarter and then the next one will be at halfway between one and a quarter between one and a half two which is one and three quarters and then the next one will be halfway between two and two and a half that will be a two point two five and then the last one will be between two and a half to three so that's two point seven so I square up all of those numbers and I divide by a half and that gives me my midpoint approximation also pretty easy with a lot of work that we will not do in this class we can actually get a bound on how far off these are even if you don't know the right answer if you have no way of knowing how good your estimate is then this is kind of useful but if I can tell you so if you ask me how much money do you have a hundred million dollars that's my estimate I don't know maybe I'm only off five nine hundred ninety nine million nine hundred ninety nine thousand that tells you like nothing maybe I only have a dollar that's an estimate but it's a useless one because the error is so big we have no way of knowing what the error is from the estimate is useful so we can not in this class but in a numerical analysis class or if you really want to work hard we can figure out what the error is in these cases what's this going to depend on what this is going to what will contribute to the error how many rectangles are certainly a critical factor and then another factor is sort of how we lean the functions the derivative if the second derivative is less than an absolute value but the biggest the second derivative is because the second derivative tells us how much this function bends the second derivative if there's some number k so the second derivative is no bigger than that than absolute value then the trapezoid approximation minus the actual value is going to be less than and I also get what we divide by here so the error depends on the size that you chop it up into so it depends on the interval goes like the square of the number of intervals I take that means that if in this case so here I was off by about less than quarter if I went with with I doubled the number of rectangles then I should I should increase my answer my answer should get better by a factor of 4 because I'm going from 4 squared so if I increase my thing by if I double it the number of rectangles of my answer should get better by a factor of 4 the midpoint is kind of the same if the second derivative is found by k on the interval then the midpoint approximation is didn't even afford to give up less than or equal to the same constant v minus a q and here it's 24 so the midpoint is a little better but it doesn't it doesn't really buy you much the error in this point is about half of what the error in the trapezoid rule is but increasing n is way better k is the same k it's bound on the second derivative the second derivative is less than k on the whole issue k depends on the function so in this case the second derivative well x is the derivative of x is 2x the derivative of 2x is 2 so in this case k is 2 if I'm doing a sine then the derivative is the second derivative of a sine which is again the sine but if I'm doing a very bendy function if I'm doing e to the x the second derivative so depending on how bendy the function is controls how good this approximation is the second derivative so if I have a function and that makes some of that sense because if my function goes like this on top of my rectangle the second derivative is very big so my rectangle is going to be a terrible approximation remainder I want to talk about something a little bit deciding how many you can this is rule because what it does is here's my function and here's my rectangle which I'm drawing very big instead of just looking at the middle at the two ends it uses all three of those and it puts a parabola instead of using a straight line like the paraboloid or a rectangle like the midpoint rule it puts a parabola through the three points the two ends of the middle so that means that you almost can't even see the difference in most cases it's very hard for me to draw a function unless it's a formula Wibbler thing that doesn't look a lot on the small piece it isn't a parabola the vertex doesn't have to be in the middle vertex in this case whatever parabola goes through those three points so just like you know that two points determine a line three points determine a parabola and I don't have time to go through all the algebra and you'll all fall asleep anyway it isn't a book if you want to read it but it turns out that this is just a kind of a special average between the parabolas and the midpoint the pattern is one four two four two four two so what does that mean so if we look at this then we think about let me put some more rectangles here with parabola so every time notice that the edges get counted once because he counts only for the beginning rectangle and this guy gets counted twice because he counts from this side and from this side and this guy and so on and the last guy gets counted once and then it turns out by doing the calculation that the middles get counted four times and then we have to average I think you can divide by 3 let's forget whether it's 3 or 6 depends on what you call middles I like to divide by 6 so this width is my base I divide by 6 so I'll write out the formula so here I'm going to use so ok there's a little issue of terminology in this picture should I say that N is 1, 2, 3, 4, 5, 6 6 or should I say that N is 3 depends on what picture you're thinking of here I'm thinking of 3 rectangles 3 rectangles I have 7 points I have to play the book calls this 6 so what so so let's call this N let's call it 2N let's just call it N which means that I'm using issue of what you want to call N how many parabolas you're fitting or how many points you're using the way the book uses it is they call it N and I tend to prefer to call it the number of N so let's do N to be the same as the number of points there's a homework problem that you don't have yet it's 4 so if N so it's N plus 1 so that means that this little width here is B minus A the average with a half kind of because I have 3 points and I do an average with a third but then the averaging I do is kind of funny I take the first point once and I take 4 times the second point x1 that's a middle then I take twice of the third point and then I take 4 times of the next point of the next point and so on and I do this until I'm almost done then at the end I take 4 of the last midpoint and just 1 this is kind of a funny average it's a weighted sum the middle counts more than the edges the middle counts double the edges 1, 4, 2, 4, 2, 4, 2, 4 if you do the little calculation 2 you can see that this actually finds you the very best for average 2 comes because I'm counting this as a whole twice but let me, yeah I have 3 points that I'm averaging so it's going to be a half but it's a third but it's a funny average because I'm weighted and I better have gotten this right so let me do x squared again I don't know but even I'll do n equals 4 well n equals 4 isn't enough to do the pattern but maybe it is so let me do x squared with n equals 4 it doesn't matter so I'm going to do this again the same 1 to 3 dx with n equals 4 by Simpson's rule so this would be 1 third which you might say over 2 times and then here I want to do 1 squared plus 4 times 4 times 3 half squared plus 2 plus 2 squared plus 4 5 half squared plus 4 so that's what Simpson's rule again notice the pattern 1, 4, 2, 4, 4 now the error here which is the whole use of Simpson's method I mean Simpson's rule and I guess I'll have to finish this next time the error here is instead of saying let's let m I need another number so I need I'm pretty sure it's the fourth derivative we have the fourth derivative so there's some number that the fourth derivative is less than m then the error is going to be less than Simpson's method is going to be less than m over 10 squared so the important thing goes down like n to the fourth so doing a little more work gives you a huge piece of formula so you can memorize the patterns I will not ask you to memorize these error formulas I mean I'm going to use them for example this starts in the next class