 Welcome back, Math 241 Calculus II at NC State University. We are on day 20, lecture 20 for this course. We are embarking in chapter 7 and we started it with the idea that we're going to look at some things called differential equations. Equations that have possibly some unknown original function and some derivatives. First derivative, second derivative, third derivatives. The order of the differential equation is based on the nature of the derivative that is in that equation. So today we're going to look at kind of the visual image of what a differential equation might look like if we graphed it in the x, y plane. So we're going to be given something about a differential equation. And we're in the second section of chapter 7 now. They call these things direction fields or slope fields. So a differential equation, let's say it has a first derivative in it. And let's say it's just something really, really simple. Let's say the derivative of y with respect to x is the x value. You can't get a whole lot simpler than that. We'll look at the whole slope field for this in a moment. But at any point in the plane, if we want to know what the slope of the tangent line is, if the curve happens to contain that point, all we have to do is look at the x value. And this tells us that the slope at any point is the same as the x value. We're not going to generate lots of slope fields ourselves, but we do know when we see a slope field, we do need to know how to handle that. So let's say we're at the point 2, 1. If we're at the point 2, 1. And if our curve, ultimately our curve goes through that, remember we had a family of curves yesterday, so we want to pick the one that goes through this point. The slope at this point should be the x value. Therefore the slope, if it goes through this point, would be what? It would be 2. So we would go up 2 and over 1. So you'll see a bunch of tiny little line segments in these things called slope fields or direction fields. Have you dealt with slope fields before? Okay. So we're not going to generate lots of these pictures, but that's how each individual slope is generated. We know the derivative. It's described in terms of x or x and y or just y alone. We end up with this mass of little tiny line segments in the plane. All they are is these slope fields are kind of sign posts or guide posts that if the curve goes through there, then the curve does something like this. It kind of lays up against there in that fashion, or maybe the curve is down here and it lays up against that little segment that constitutes the slope of the tangent line at that point. It has to be that. That's the way the differential equation has described it. So we would expect then if we come out here to 3, it doesn't really matter what the y value is. It matters what the x value is. That's the slope. At 3, 1 it would be a little bit steeper. At 4, 1 it would be even steeper than that. And we generate this thing which has a bunch of these line segments on it. And let's take a look at if I can find it quickly what this would look like. And we'll come back to this. If we were to put all these together, this would be the slope field for dy over dx equals x. So we might as well talk about this. This was generated in Maple. This little package, I think you've used repeatedly the with student package, right? In Maple. So this is another package with DE tools. So that activates a lot of the stuff that you would do with differential equations. So here is the differential equation itself. DEQ, that's the name of it. It is diff y of x with respect to x. So that's basically dy over dx equals x. So there's the statement of the differential equation. And then this is a DE plot that what we named this up here. We're going to plot that from x equals negative 4 to 4 and y equals negative 4 to 4. So we end up with this slope field. So here's the kind of the Maple ease version of this. Its name is DEQ. What is it? It's derivative of y with respect to x equals x. So then it generates this. We were at the point 2, 1, and we knew that the slope was 2. Well, look at every place where the x value is 2. What's the slope at every one of these points where the x value is 2? It's 2. Jump over here to x equals 3. The slope at every one of these points where x is 3 is 3 and so on. So you can see the commonalities of the graph based on the fact that it's a pretty simple differential equation. The slope is always the x value. Where is it flat? Where is this particular family of curves? If we were to put some in here, where would they be flat? On the y axis, because on the y axis the x value is 0, therefore the slope is 0. So at all these points in here, the slope is actually 0. Can you visualize the curves that would fit in this particular family of curves? So as long as we stipulate, we want the one that goes through the point 2, 1. Well, 2, 1 is right here. So what would that look like? That might look something like that, right? And wouldn't it have a mirror image over here? The same thing. Is that what you would expect for something that has x for its derivative? Well, let's anti-differentiate and see what we would expect. If y prime is x, what is it that has x for its derivative? One-half x squared. One-half x squared, right? So y would be one-half x squared plus c. Is that what you visualize in here? A bunch of those one-half x squareds plus c. So the one-half, does that make it a little fatter than our old friend y equals x squared or a little skinnier? It makes it a little fatter, right? Which these ought to look a little fatter. So if we want the one that goes through this point, maybe it looks like this. So all these little slope fields, these little line segments kind of tell us where the curve should be going if the curve, in fact, is in that vicinity. If we've got one that's down here, then we've got these, again, these signposts that tell us where the curve is if it's down here. So it can be that simple. D y over dx equals the x value, and we know what these look like. They're falling into this format. If we force it to go through a certain point, then that allows us to focus in on a specific value for c. Other than that, it is a family of curves. All right, this will change things drastically. I think this is from our book somewhere. Direction field for this differential equation. So we've looked at a real simple one. D y over dx equals x. The slope is the x value at every point. That's significantly different, but that is a description of what the slope is at any specific point. Can you visualize some different curves in this particular slope field? If it comes up through this point, it looks like it dips down, right, and comes up here. Maybe it dips down not quite so far. I don't know. Let's graph these. So there's a whole bunch of solutions. Let's suppose that the y of 0 is 1. That means when x is 0, y is 1. So there's 0, 1. What's that look like? Right there, it's flat, right? Is that true? By the way, at the point 0, 1, 0 for x, it doesn't really matter what y is, right? If x is 0, the slope is 0. So if you'll notice that x equals 0, the slope is always 0. Shouldn't it, what, head upward and then flatten out something like that? If that's the slope field that represents this set of points. Looks like we've got a symmetric image over here. That's one of the members, kind of rough, of this family of curves. How about this one? Y of 0 equals 2. So it goes through the point 0, 2. Is that a different looking curve? It's slightly different looking. Looks like it comes up here and then is asymptotic there again. But it doesn't dip down quite so far. Different looking, but kind of similarly shaped. The next one's very different looking. Y of 0 equals pi. What's that look like? It's linear, isn't it? And that's an equilibrium solution. Why would that be true? Because don't we have the sine of y, right? And the sine of pi is 0. And all of these isn't the y value going to be pi, right? So we're always going to get 0. Well, if the rate of change is 0, it's not changing at all. So it's flat all the way across. So this is an equilibrium solution. How about y of 0 equals 4? Now we're up here. Again, a very different looking curve from the first two because these are asymptotic but coming in from the other side. And y of 0 equals 5. We end up with a curve that looks like that. So you've got a whole bunch of possible curves, including an equilibrium solution. We found one of them. Is there another one? Zero. At zero, right? So down here it's flat all the way across. There's an equilibrium solution. Why is that? Because the x value is 0 all the time. It doesn't really matter what the y value is because 0 times the sine of whatever y is is going to be 0. Are there other equilibrium solutions that aren't pictured here? 2 pi, same thing going the other direction, every pi units, right? So we're going to have equilibrium solutions. First one is at zero and what? Every pi radians from there? How would we write that? n times pi where n is what? Not all real numbers. We want it to be an integer, right? Some integer multiple of pi. Integer normally is a capital Z. That'd be a good little research project. Why it's called capital Z for integers. I is irrational. But that'll take care of all of them, right? Does that take care of the ones down here also? Because that'd be zero plus negative one times pi. So we're going to capture all the equilibrium solutions in that statement. Questions about that before it moves? So you're not going to have to generate these by hand, but they're very easy to do in Maple with that d e plots command. I think this is in your book. Here's a slope field. We have no idea what the equation is, but can you visualize a lot of different curves in this particular slope field? This is on page 506. I think it's the same thing. This is actually from the previous edition, but I think it's the same equation. Looks like if they're coming up here, they're right, and then go back up. So here's a variety of solutions from this particular slope field. So if we're forcing it to capture this point right here, how would it do that? Follows the slope field. A little signpost, that's all they are that tell the graph where to go if it goes through that point. Looks like these are almost simultaneous here, but this one does something radically different from the one that's slightly above it, simply because it captured this point. And it dips back down through here and then comes back up. One that goes through this point. So we have different looking curves. They have some similarity, but they all have the same differential equation. That differential equation, let's see if I can find it. I don't see it. It's not all that relevant. We're looking at a slope field. These are some different members of that family of curves. All right, here is a maple version differential or the diff of y of x with respect to x equals y. There's the command. So here's our equation. Derivative of y with respect to x is y. Here's what they look like. It goes through this point. It comes over here. It comes over here and goes through this point. Looks like they're all asymptotic to the x-axis. They might be down here. A lot of different members of this family of curves. I bet you know what the solution is to this. What is a y thing that we can take the derivative of y and it's the same thing as what we started with? e to the x would be a solution, right? Can you see e to the x in here? Something that looks like this, right? And other variations of that? Well, how could we get other variations of this? We could have some constants involved, right? And the derivatives of the constants wouldn't appear. How else could we have a coefficient out in front that would change it? Could we have a negative 1 out in front? Could we have an e to the negative x, possibly? Would that work? Is the derivative of e to the negative x also e to the negative x? Not quite, right? It's the negative of itself, so that's slightly different from this. But we could have other coefficients which will take this image here and reflect it down, right? So we could have some coefficients out in front. So we've got a whole bunch of different shapes, but all of them above the axis are similarly shaped to this and all of them below the axis are similarly shaped to that. We'll have a technique to solve. We won't have to make a guess at this. Our first technique of solving differential equations will be those that are called separable differential equations. We'll isolate or separate the x's and the dx's from the y's and the dy's, and we'll be able to solve for y. Okay, another one. Here's the differential equation. It looks like dy over dx is the x value minus the y value. Now, that looks like a pretty simple differential equation. That actually is a pretty difficult problem to do in terms of a separable differential equation. Things that are added and subtracted are going to be difficult to deal with. Things that are multiplied and or divided will be relatively easy to deal with because we can move them around where we want to. To isolate the x's and dx's from the y's and the dy's. So if we take the x value, subtract away the y value, we get the slope at any point. So where do you see the flat places here? Where would the slope of the tangent lines be zero? When x and y are the same, right? If x and y are the same and you subtract one from the other, you get zero. So look at a point where the x and the y are the same. And here's the point two, two, right? Slope of the tangent is zero. So we've got a little flat line segment right here. We could come to the point three, three, if I can find it, right here. The slope of the tangent is zero. So you notice some similarities as you work your way up. If the x and the y value are the same and we subtract one from the other, we should expect to get zero. So there's the flat places on this graph. So zero, zero, it's flat. One, one, it's flat. So you see all these flat places all the way up the diagonal. What could the curve look like? It could look something like this, right? And we've got it asymptotic in that fashion to the line y equals x and a whole bunch of different curves that could be illustrated down here as well. So we do have a family of curves for the differential equation. All right, one more of these, and we'll talk about how we can use Euler's method to approximate solutions. So here's one where the derivative of y with respect to x is the x value divided by the y value. Let's just pick another number other than zero. Where would the slope be? Negative one, okay? One, negative one, negative one, one. So in general, those are some specifics. In general, where would the slope be negative one? When x and y are equal. Right, so they're equal in magnitude. One that's positive and one is negative, right? The slope would be negative one. So if you check out some points like that, we had some examples. You'll see that the slope is negative one. Where is the slope positive one? Well, the x and the y value would have to be the same, right? So at the point two, two, we should expect the slope to be what? One, up one and over one. At the point negative two, two, we should expect the slope to be negative one. Where would the slope be zero? For a fraction to be zero, what has to be zero? The top. So as long as x is zero, the slope is zero, right? Now what about zero, zero? What about the solution that actually contains the origin? It's got an undefined slope, right? If the y value is zero, in fact, probably worse than that, isn't zero over zero worse than just good old-fashioned undefined? What is zero over zero? Eleven? Sure. Is that a word? Fourteen? Negative seven? It's whatever you want it to be, which is kind of worse than undefined. It's awfully defined. It's too defined. We've got way too many descriptions or definitions for zero over zero. What do you think? Do you think we're going to have a solution that goes through the origin? I don't know. What are you seeing when you look at this slope field? Everything's going away from it. Everything's kind of going away from it. So if we had a solution, let's say, that's up here, is that what you're seeing? And we maybe have its image down here. What is that? Hyperbola, right? So maybe we've got a family of hyperbolas. Do you think that's the only position that we could have in the plane? I guess we could have some over here, right? Maybe a hyperbola over here or a branch of it over here and its symmetric image over here. So this could very well be a family of hyperbolas where the slope of the tangent is the x value divided by the y value. Obviously we're not going to have both of these simultaneously because then we would be talking about something that's not a function. So if we had the green set, we would have its image but not these two. So we've got either a hyperbola with branches opening up and down or scrap that another hyperbola or a set of hyperbolas that open left and right. All right, we're going to have an approximating technique called Euler's Method to come up with a sketch of the real curve based on the differential equation. Euler's Method uses linear approximation. We're going to approximate what is going on along the curve by what's happening along a line that's tangent to the curve. Why would we want to use tangent lines having started with the differential equation? That's what the differential equation is, right? It's a description of the slope of the tangent. So we're not going to have the luxury all the time of having the exact curve, but let's say that the exact curve looks something like this. We know for a fact that the curve goes through this point. We're going to use the differential equation which is a description of the slope of the tangent to say I want to try to keep track of that curve, but I can only do so incrementally by going along the tangent line to the curve. Not quite increments like this big, so we're going to use the slope of the tangent and say I know I don't know where the curve itself is, but I know where the tangent to the curve is and if I use my increments small enough if I choose a point on the tangent line it's going to be pretty darn close to the actual curve itself. So we really want to choose way closer than what I'm going to do here, but we're going to come out here some delta x and we're going to say that this is our approximation. For where the curve actually is. Of course we have the luxury here of having the curve and we know that we're not on the curve we're on the tangent line to the curve which begins to separate from the curve. Then with Euler's method we reload we determine the slope of the tangent again so maybe the slope of the tangent now comes up here and instead of choosing a point on the curve because we don't know where the curve is we choose a point that is over delta x units along the tangent to the curve and you can see how they begin to separate because we're using an approximation to do a further approximation so we get further and further away from the actual curve but eventually we end up with something that has a similar shape to what the real curve looks like in absence of some exact method of solution this is not that. If you keep delta x small I'll put that in quotes because what is small for one problem may not be small enough for another problem. If the curve goes up very steeply this kind of changes what small is. We would need our increments to be very, very small because the curve changes so rapidly. If the curve is fairly flat we don't have to be quite so small with the delta x values. Here's some pictures of what it is we're going to do again we're not going to have the real curve the luxury of having the real curve in most cases. Here's the real solution curve we're going to approximate along a line that's tangent to the curve and we'll do that iteratively so we'll do that here reload, get a new tangent line go along the new tangent line reload, get a new tangent line again to look something like this. So what we have is a bunch of points that are on line segments but you could connect them and make a curve out of them. It ought to approximate the solution curve itself and we can compare and contrast once we get some methods to find the actual solution curve. In some cases we already know what it is. So how will we do that? How does Euler's method actually work? We start with some initial x value and some initial y value a starting point just like this point right here we know it's on the curve because we're forcing the curve to contain that point what we don't know is any other points that are necessarily on the solution curve. So we get our x0 and we get our y0 that's our starting point that's handed to us for the most part we start with that then we want to find our next x value so we're going to use the tangent line eventually to get to our next point well to get to our next x value we just simply add this change in x to it. That's easy. So each time you want to crawl along in terms of x add delta x to your previous x value and you're there. Here's what we really want where's the new y value that's the one we have to work at and that's the one we have to use the differential equation for. So we'll go back to our old y value and here's kind of Euler's method using the differential equation we're going to take what we know dy over dx to be that's going to be given to us the differential equation it'll be x over y or the x value x minus y we're going to use the derivative and we're going to multiply that by delta x so the new x is the old x plus the change in x the new y is the old y plus well it'd be nice if we knew the exact change in y, we don't so we have to approximate I don't know if this helps it helps me, I don't know if it helps you I'm going to think of that dx and that delta x kind of knocking each other out and then we're left with dy it kind of sounds like a change in y doesn't it dy is actually the change in y along the tangent to the curve not along the curve itself but this is our differential equation it gets plugged into that spot that's our slope, that's our dy over dx and we continue that process to get x2, we'll take our previous x value those are always easy just keep adding delta x to the previous x value to get y2, we'll take our previous y so this iterative process is called Euler's method it's flawed, it has its flaws we've seen it in the picture why is it flawed, because first of all we're using a tangent line to the curve and not the curve itself and we're using an approximated value to start to approximate further so we actually end up getting further and further away from the curve even though it probably has a somewhat similar shape so how far do we go with this it kind of depends on what we're directed to do or maybe we know the y of 0 is a certain value and they tell us to approximate until we get 1 or the y of 2 and how many increments we have how many steps we have along the way alright, first example pick one that we've already looked at let's start with this one I'm going to take this diagram away so we kind of have an idea what the finished picture is going to look like or might look like let's take the one that goes through the point I don't know let's pick one so we're going to pick this curve that's going to come through here so our differential equation pretty simple, it's just the y value now it's not the new y value it's the previous y value we're always using the previous data to generate new data and we want x sub 0 to be 0 and y sub 0 to be 1 and let's just pick the delta x in this problem to be 0.25 and let's just keep going until we get we want to see what the y value is when x is 1 so we want to go through 4 steps with this crawling along 0.25 each time we go in terms of x so we have our initial point what's our x1 quarter to it, that's easy old x is 0 plus 0.25 so the x value of our new point we hope is pretty close to the solution curve is 0.25 so our new y, y1 is the old y, y0 plus the derivative well what is the derivative on this problem it's the y value okay so the old y is 1 the derivative is the y value so we're pulling that directly from the differential equation that's given to us so the old y value is what we use all this data to generate x1, y1 so we're using x0, y0 to generate x1, y1 so what's the old y 1 is that right so there's the old y value there's y0 times delta x so we get 1.25 does that work so there's our new point because we're using we can't use the new y yet because we're trying to generate the new y so we have to use the previous data so we're going along the tangent to the curve to find a new point we don't know where that point is yet so we're using the old point as our starting point so we have no idea what y1 is so the only y value that we know anything about is this one the only x value we know anything about is this one so we use the old data to generate the new data all the way through the process mainly because we don't know the new y yet we're trying to find the new y so from our picture we've looked at the slope field we started out with the 0.01 now we have a new point that we think is pretty darn close to the solution curve it's over a quarter and up one and a quarter does that work so let's generate a new point so we want x2 x's are always easy previous x 0.25 we're going to add the change in x 0.5 y2 is y1 I'm going to go ahead and write the first derivative what is dy over dx it's the y value what y value the previous y value times this delta x value so really this becomes y1 plus the previous y value that's the slope of the tangent times delta x y1 is 1.25 plus this previous y value 1.25 times the change in x so this is 5 fourths times 1 fourth is 5 sixteenths added to one and a quarter that's it anybody got a calculator out and working so there's our x2 y2 no mystery about the x we started at 0, we went a quarter and then we went over another quarter so we're at 0.5 the y value so back to our picture we're now over here at a half and we're up 1.5625 is that kind of what we expected it's probably underneath where we should be but it's relatively close you don't have to write this out each time I'm just writing it out because it's our first example you can just add the increment each time to x what's the slope the slope is the y value times delta x so what is y2 0.5625 plus that same value since it is also the slope times the change in x Katie we're trusting your calculator here 0.9531 so there's our new point 0.75 1.9531 so we go back to our picture 0.75 1.95 so you can see that we're ending up with what we thought we would get not exactly now how do you know when to stop well we're going to be given something like this we want the y of 1 what is y when x is 1 which tells us to go one more step we want x4 in this case so we are at x equals 1 that tells us we're at the place we want to stop in terms of x we want y4 which is y3 which is the slope the slope is the y value so what was that number 1.9531 plus that same number which is the slope times delta x so that should be our approximation for the y value when x is 1 what's that is that alright with the process looks like euler's method he'd be offended I think if we called him euler let's look at one other alright little bit more to it we'll do a couple iterations through the slope this time is x minus y so it's not just the y value we've got to take the previous x minus the previous y that generates the slope we multiply that by delta x let's see what we want this to look like let's make it go through the point so let's make that now that's actually on the final solution curve when we get to choose the point that's the one we want the curve to go through now from this point though we're going to approximate what we think the curve does based on this initial point let's just get a couple of iterations it's probably all we have time for today so delta x I don't know the smaller we make delta x the better we're going to get I don't know if I showed this earlier have I showed that yet? these are approximations to a curve you can see the solution curve which is the top one up here and as you choose different values for delta x you do a better job of approximating so if we let delta x be smaller you can see the difference in the proximity to the actual solution curve if delta x is chosen fairly wisely or sometimes we don't have the choice it's just given to us so let's say that just to make it different let's say it's 0.2 what's x1? 1.2? so the beginning x, x0 is 1 we're going to add delta x to that so it's 1.2 in fact we're just going to add 0.2 all the way through to the x so the new y is the old y what's our slope this time? isn't the slope x minus y? new differential equation we're going to take that times delta x what are the numbers for that? y0 is 2 so we're going to use the previous point to generate this new point so the previous x minus corresponding y value so that's what? 1 minus 2 there's the slope times delta x which is 0.2 so what do we get? this one's not increasing it's decreasing isn't it? 1.8 so x1 y1 we went over 0.2 in terms of x but the y value fell from 2 to 1.8 let's do one more x2 previous x plus delta x that's 1.2 plus 0.2 y2 is y1 plus slope slope here is x minus y y1 1.8 aren't we using x1 y1 to generate y2 we're using the previous values to generate our new value so x 1.2 minus y 1.8 times delta x we're using x1 y1 to generate x2 y2 so let's see what we have here there's a negative 0.6 times 0.2 which is negative 0.12 is that right? 1.68 so our new value which will be our last value today now would we expect these values to be falling let's see let's see if we're right here so we started out at the 0.2 no at the 0.12 which is somewhere in here shouldn't we expect according to what the slope field says shouldn't we expect our y values to fall for a while and then for them to pick back up right? so it seems to be matching what the slope field actually looks like alright we'll continue with this section some circuit problems tomorrow and I will see you then