 We're doing, so I guess I should remind you that there's a web assign due Wednesday. You know, you know it's last Wednesday. Okay, so what we're doing, we were talking about Euler's method. And this is a way to, if you have a differential equation. So this, so we have a differential equation and we have an initial condition then we can numerically construct a solution. So the way this works is we just pick, so our differential equation looks something like, I don't know, y prime is, I don't know, some function. That's y. So if we write our differential equation like that and we have some initial condition like y of zero is some number. So we have something like that. And what we do is we just follow the slope field. So we pick some ratio that we like. Sometimes this will be told to you. Sometimes you just pick something which is, so we pick a step size h, which is the fraction of the derivative that you're going to pay attention to. So you could take h equals one and this usually gives you a fairly bad solution because you're not following very closely. You could take h very small. The drawback of doing h small is it will be, it will follow closely, but it will be a lot of work because you have to do a lot of steps. And then you just start going. So you just take your initial x, I guess this should really be, it doesn't have to be zero to be x naught, but we'll just start with our initial x to be zero and our initial y is whatever it is. No, it's not a. And then we can look at what is y prime of x naught by plugging these guys in. And then that gives us, now we're going to move x ahead a little bit. It's the previous guy plus we add a little step of h and then assuming that everything else is true, then we take our next y to be what we had before and then we add on some small fraction of what we got in the derivative last time. And then we just keep going in this way. So y2 will be what we calculate here, y prime of x prime. And y2 is what we got last time plus h times whatever the derivative was from last time and so on. We just keep going until we get as far as we want. So all we're doing here in terms of a picture, if we have our differential equation here, at our starting point we look at the derivative vector and we go some distance along it. This gives us our next y value at our next step size h. And then from that one we look at the derivative vector, we go some part along it to get our next y value. And then if that one we look at the derivative vector, maybe it goes this way, we go some distance along it and we just keep following where it tells us to go. We're just looking at the slow field, but just in the place we're going. We could just plug this into a little machine. Very easy to write a computer program to do others method if you know how to program it all. Okay, so let me do an example of this. I'm going to estimate a couple of things in this example. So suppose I have like a block of clay or something and it's at say 50 degrees Fahrenheit and I'm going to put it in a kiln at 100 degrees Fahrenheit and I'm going to bake it. And I want to know how hot will it be. So I suppose I know I check after one hour if the block is at 100 degrees. But now I don't want to keep checking it every hour and I want to go to sleep. So I want to know what will the temperature be in 6 hours. If you didn't think very hard, you might say, oh well it's going to go up 300 degrees because 6 hours goes up 50 degrees an hour. So 6 times 50 is 300 so it will be 400 degrees in 6 hours. Do you think that's right? No. So you have to know a little bit of let's say physics. So Newton's law of cooling says that the change, if I have something, if I have something at one temperature in an ambient area that's another temperature, then this is some constant which depends on the thing times the difference in temperatures. So in this case it's, let's do it this way, T of H minus the ambient temperature. So this differential equation, in this case I guess it's Newton's law of heating, but this is, and we can solve this differential equation and get an explicit formula for what the solutions look like but let's not do that yet. So now let's just use this and use Euler's method to estimate what the temperature will be in 6 hours. Okay? So is it clear what to do now? That's good. If it was clear to you then we could just leave since it's not clear. So let me go through this and just for simplicity I'm going to take a step size of 1. So we need to know a couple of things. We need to figure out what is this K and we need to figure out how to use this to go ahead 6 hours in time. Okay? So first we have to guess K. Well we have to use the information we have to estimate K. This estimate will be wrong but it won't be too bad. So this is not a very good solution but it's a solution. Sorry? So K depends on how quickly the thing absorbs heat. If it's a block of clay it will absorb heat less quickly than say a metal. So if it's something that heats very slowly K will be different than if it's something that heats fast. Right? So this depends on the material. It also I guess depends on the oven. Whether the oven is filled with air or filled with water well you can't have water at 500 degrees. It could be filled with superheated steam. You know. So it's something that depends on the situation. Okay so first how would we guess how would we estimate K? I claim that most of the information needed is not assumed that we solved it yet. You should be able to get an idea. Is K a tenth? Is it a hundred? Is it negative six? What would we use to figure it out? Yeah. Use the two temperatures. Right. So looking at the two temperatures what do they tell us? We know T of zero is 15 and T of one is 100. Why does that tell us anything about K? I'm sorry. Find the difference? So T prime of zero is just about 50. Maybe it's 60, maybe it's 49 but it's like 50. So this tells us that T prime of zero is kind of like T of one minus T of zero over one. I mean this is the difference quotient that you will take you to the limit of remember that back in the dark ages so this is 100 minus 50 over one which is 50. It went up about 50 degrees in an hour. So using that we should be able to figure out what K is because now we know everything here. We're saying that T prime of zero is about 50 which is K times there's too many 50s on the board but oh well T of zero minus 500 so T of zero is 50 so that means that 50 is K times negative 450 so K now it seems to be a ninth doesn't it? Huh negative K I don't know how I got an eighth before because I did T of one well whatever so K is about 50 over negative 450 which is a ninth which is 0.111111 it's negative so let's just use 0.1 because all of this is just slop K is actually negative is log eight over log nine I mean log eight nines but we don't know that yet okay so using K to be negative 0.11111111 we can now use Euler's method to estimate what happens after six hours, five hours I don't know some number of hours so now I'm going to use so now my differential equation is T prime 10 hours is negative 0.11 enough ones negative a ninth of T of H minus 500 and so now I'm going to use Euler's method to guess, to estimate what's going to happen by T of six so T of zero we already know it's 50 T of one we already know we're going to write it so right this is unfortunately I have two H's here I have my step size H and I have my H for hours so unfortunately I need the same letter for the same thing but here my step is one so instead of writing H I'm just going to write one because I'm being lazy I'm using one so to guess what T of two is it's going to be just about T of one plus my step size which is one times the derivative at one well what's the derivative at one it's negative a ninth of the temperature at one minus 500 which is well I'm going to use 0.1 for a ninth so it's about 40 this is negative I'm going to forget about the values so T of two what did I do wrong this should be 450 because whatever method usually you use the previous X and Y because you don't necessarily know the next step so I want T prime of one yeah so I'm sorry this is right this is right that's okay because I did the 50 step already yeah whatever the number is it's still 40 okay it's like it's actually 44 well a ninth is 0.111111 so it's 44.444444 okay so this is 100 plus 44 is 144 and then the next step the temperature at three is going to be the temperature at two plus however fraction I'm taking one of the last temperature that I had the derivative at the last time I had so the derivative at the last time I had here is lost my place 144 plus 1 times so the derivative at the last time is I take these two values that I had 144 and 2 I don't need to and I plug them in here so 500 minus 144 is 56 56 yeah okay so that's 356 times 0.111111 is so it's 356 times 0.11 which is 39 call it 39 144 plus 39 is 143 plus 40 is 183 maybe I don't want to go all the way to 6 maybe you get the idea by now so T of 4 is T of 3 plus my step size times T prime of 3 T of 3 is 183 my step size is still 1 and now my derivative last time is 500 minus 183 is 317 so 317 times 0.1 is 31 34 35 okay is 200 should I keep going or are we good enough yeah T prime of 3 means I know my H is 3 and T of H and that's all I need for this so I looked at T of 3 I plugged it into the formula I got it I don't know and I just keep going the answer is after maybe you get the idea I can keep going but okay so after 4 hours instead of going up 200 degrees it only went up 168 degrees and so on so Euler's method is really very straightforward it's the most simple numerical way of solving a differential equation there is it's not very accurate essentially if you use a big step size like 1 if the step size gets teeny tiny then it gets more and more accurate it's very analogous to doing a numerical integral remember this stuff where we take the what side is that this side is left where we take the left side left hand rule it's almost exactly the same as doing the left hand rule and the step size H is choosing the width of the rectangles if we take a tiny with a rectangles you get a good answer but you have to do a lot of work there are other numerical methods I think we may come back to them there are other numerical methods but first off Simpson's rule was much more accurate for the amount of work there is something that can be here that's like Simpson's rule which is called Runge-Kutta Chris H there anyway, it's named after Mr. Runge and Mr. Kutta who came up with it and it's like Simpson's rule very close analogy between Simpson's rule and Runge-Kutta it's just numerical things so like in an engineering class where they have to solve a differential equation probably those people have to put there or they might use a slightly improved version called Runge-Kutta-Fellberg so later so this is like from I don't know the 1940s and then this is from like the 70s where we figured out how to make it a little better so there's these variations on Runge-Kutta which are now about 30-40 years old that people use to solve differential equations in computer programs or in engineering simulation and there's all sorts of there's an entire branch of mathematics devoted to doing this kind of stuff called numerical analysis okay so fine this is all good actually work on solving some differential equations coming up with formula you can't always come up with formula so like when I took this class we had electricity but just barely and we focused a lot on actually writing down solutions rather than thinking about what the solutions are the problem with that is for most differential equations you can't really write down the solutions just the ones that come up in class but for those that you can it's a good thing so let's work on coming up with some solutions and let's start with very easy differential equations so the easiest kind of differential equations to solve is called the separable and we have something that looks like y prime equals some function of x over some function of y so for example y prime equals let's make the simplest thing we can think of x over y the function of x could be a constant like one the function of y could be a constant like one so something like this then instead of writing it as y prime we write it as dy over dx and then we do something which is actually can be justified mathematically and I will but you just forget that it doesn't make any sense and you treat these things like fractions and you cross multiply so I treated dy dx like a fraction and I cross multiply mathematically this is just total crap but it works and actually I will justify it a little bit but you can do it because you really can't and then you just integrate both sides assuming you can do the integral and this gives you some function of y plus a constant and this gives me some function of x plus a constant that I solve for y and I'm done so let me do that in this case so in this case I think of this as dy dx equals x over y I separate the variables so this becomes y dy equals x dx then I integrate both sides if I integrate I get y squared over 2 equals x squared over 2 and then there's a constant floating around I only have to write one constant because we don't know the value of this constant so if I wrote plus c1 here and c2 here then I can just take my constant to be the difference of c1 and c2 so I can just put one constant for the whole equation and then I can solve and constants are magical I can just forget about constants times constants y squared equals x squared plus 2c but 2c is really some other k so the equate I think this would be a hit so the the solution to this then y squared equals x squared plus a constant or y equals well something like that maybe it's the plus square root so minus square root it depends on which c you take what your initial condition gets so that gives us our solution if we had an initial condition like we knew when x was 0 y was negative 1 so let's just augment this a little bit so I knew that y 0 is negative 1 then what would the solution be nobody knows how to figure that out so we can use this in this equation to figure out which one it is so y of 0 is negative 1 so that means negative 1 equals well it's a plus or it's minus square root of 0 squared plus some constant well obviously because this thing is always positive it better be the minus 1 and so c is 1 so my equation in this initial value is y of x is negative square root of x squared plus 1 let me do another version of this so let me actually just do one more equation and then I'll do another application maybe I'll do this one so is everybody okay with this this is really pretty straightforward pretty easy stuff the only place where it gets hard is sometimes the integrals get hard and you have to solve you have to pay attention a little bit oh maybe I should justify that it's okay let me do another example and then I'll justify so let's just change this just a little bit let's let's say dy dx is x squared y so this is separable because I can get all the y's over here get all the x's over here so divide both sides pi y and multiply through y dx should I put an initial condition on this do you want one no it doesn't matter so yeah so yeah so right so if you think about this picture when I have an initial condition it's telling me where to start there's lots of so if I give an initial condition see this is not a single curve this is a whole family of curves that look like things like this and I have to know which one I want so when I said when x is zero y is negative one that said I'm here and then I take this curve so that tells me which curve I want if I said when y is zero x is zero then that would give me one of these guys so x is zero doesn't really give me enough information to know whether I want the plus or the minus but if I said when y is one x is one that would tell me I was not at this point and so on so the initial condition nails down the constant integration to a specific value just like when I did this heating problem I told you it started at 50 degrees I would have a different answer if it started at negative 10 so back to this we integrate both sides and so when I integrate this what's the integral of dy over y so this is the log y and the integral of x squared is x cubed over 3 plus some constant and now we want to solve for y so I exponentiate both sides I can also so e to the log of y is the absolute value of y I can clean this up a little bit when I have a plus in the exponent it's the same as multiplying c is just some constant so e to the c is just some constant it's positive now so I can call it actually a so I have absolute value of y is some constant a times e to the x cubed over 3 that means y is plus or minus some constant a times e to the x cubed over 3 but a is positive so plus or minus some positive number is a positive number or a negative number so this is just something times e to the x cubed over 3 so k is any number could be plus, could be minus a is only positive here but k could be a if we have an initial condition we can figure out the value of k I told you when x was 2 y was 3 then we could figure out what a was let me do these are very easy I don't know, is anybody baffled by this at all? so the only time this gets hard is when the integrals get hard if you have a nasty integral then sometimes integrals are hard to do so should I do another example with some words about it like voltage in a circuit or oh yeah, I was supposed to prove something so I want to show that this actually is a reasonable thing to do so why does this make sense so we have something like dy dx is f of x over g of x which is the same thing as saying oops I guess this was a y g of y dy dx is so that's just rewriting it there's nothing wrong here what was wrong is sort of putting the dx over here so suppose that we know that the integral of g of y ui is the same as the integral of f of x dx because that's what we got out of that this process here all right, we do the integrals and they're going to be equal well what if we take the derivative of both sides of this equation so if I take the derivative so I'm also knowing y is some function that depends on x because that was the whole set y is some function depending on x I don't know what it is but it depends on x and it satisfies this relationship so what if I take the derivative of both sides of this with respect to x so if I take the derivative of this thing g of y dy and better equal the derivative with respect to x of the integral of f of x dx because these two things were equal well this is just f of x and if I take the derivative of the integral of g of y with respect to x I mean this thing is going to be g of y but I have to use the chain rule y is a function of x so this is dx of y so g of y is the derivative of y g of y times the derivative of y is x in other words it solves the equation because that's what I started so even though this looks like cheating in fact this cheating gives you the right answer because of the chain rule sometimes cheating doesn't give you the right answer it's sitting behind somebody who's not so smart but this looks like we're doing something not okay but in fact it is okay I was going to do a problem with yeah I was going to do a problem with a circuit and finding the voltage in a circuit do you want me to do that? yes? so I'm not going to exactly derive the differential equation I'll wave my hands about it so if we have a circuit that looks like so we have a battery here and we have a resistor here and we have a capacitor here and we have a switch so this is the battery so this gives me a charge this has a resistor which slows stuff down this is a capacitor this is a switch so Ohm's law says that voltage incidence times resistance and also using Kirchhoff's law using Ohm's law so I'm sorry this gives me R this gives me voltage this gives me inductance so if I mess around and use Kirchhoff's law then wait where did L come from is inductance yeah so why did I call it I? I don't know well anyway L and I are related well so anyway if I get so I mess around and I get that in such a circuit L times change in inductance plus the resistance times the inductance is going to be equal something's wrong here so this is the differential equation that describes and I seem to have extra stuff this is the differential equation that describes the current in the circuit when I close this okay so when I have such a thing so suppose I had this where this is 12 and this is yeah why do I have it on then this is for one of these entries I put a 60 volt battery over here then I can figure out what's so I is in the amps and I want to figure out how this goes so using this I can plug this jump together with that differential equation to figure out what's going to happen to the voltage so this is E what's going to happen to the voltage in this system I mean to the amps in this system so it'll describe it'll describe the change so we can write this in this case so we know L, L is 4 I we don't know or the derivative of I we don't know R is well that equals 60 so we don't have to check that all of the units match up but of course they do because we always use the right minutes in math and so let me actually write this as di ft just to emphasize that it's a differential equation and in fact we can separate everything we can just put all of the I's here and we get a very easy differential equation so 60 over 4 is the number I should know 15 so we have I prime is 15 minus 3 I and so I have to swap it back so di over 15 minus 3 I equals dt because it's separable I have this equation so I can put the T's over here and the I's over there and it's a 1 there so that I can solve I just integrate both sides to get that T is the log of 15 minus 3 I except I have to divide by minus 1 third because I'm really making the substitution mu equals 15 minus 3 I so du is minus 3 di so I have to divide by minus 3 so that means that the log of 15 minus 3 I minus 3T plus a constant exponentiate 15 minus 3 I is some constant e to the minus 3T and so we're solving for I so minus 3 I A is now plus or minus equals 15 minus A e to the minus 3 T something's wrong if my side's wrong this is a plus so I is that I is 5 minus B e to the minus 3T so that means that if we let it run for a long time the voltage will tend to 5 and I didn't give an initial condition but if we had an initial condition where it was after 1 second then we would have an explicit solution without constant e there these things are relatively easy and straightforward another kind of problem that you can do in this which I don't really have time for right now I lost track is you have like a vat of stuff you have a big vat of margaritamins and people are still drinking it so you want to know how strong it is and you can calculate the concentration as it goes I'll do one of those and then we'll move on to the next part