WEBVTT mathematics/differential-equations/murray
00:00:00.000 --> 00:00:04.000
Hi and welcome back to the differential equations lectures here on educator.com .
00:00:04.000 --> 00:00:12.000
My name is well Murray, and we are studying numerical techniques right now, we are about to learn about the Runge-Kutta method.
00:00:12.000 --> 00:00:27.000
Now, this is also known as the improved Euler method so, you might also, see it called the improved Euler method this is to be distinguished from the sort of basic Euler method and we had another whole lecture on the basic Euler method.
00:00:27.000 --> 00:00:43.000
That is the previous lecture here on educator.com so, if you are looking for the basic Euler method and that is the previous lecture if you are looking for the improved Euler method, that is this lecture right here keep watching so, find out what that is all about.
00:00:43.000 --> 00:00:56.000
The Runge-Kutta method, also known as the improved Euler method is a way to find numerical approximations for initial value problems that we cannot solve analytically.
00:00:56.000 --> 00:01:09.000
So, the idea here is that we have some differential equation and some initial condition and we cannot solve it analytically so, we use these techniques of numerical approximation instead.
00:01:09.000 --> 00:01:20.000
The Runge-Kutta method is more sophisticated than Euler’s method that is what it sometimes called the improved Euler method, it is actually the method that is built into the programming packages.
00:01:20.000 --> 00:01:40.000
If you use commercial software to solve differential equations so, it is things like Mathematics or Matlab, then the when you solve differential equations numerically on those software packages still be running some version of the Runge-Kutta method in the background.
00:01:40.000 --> 00:02:00.000
So, we are going to learn the order to run Dakota method , that wins it is already pretty complicated what the F professional software packages uses something called the order for even more sophisticated methods and that is a little too collocated for us to go into by hand.
00:02:00.000 --> 00:02:06.000
But we will learn the order to run Dakota method annual see him get a flavor of how it works.
00:02:06.000 --> 00:02:20.000
So, let us check that out and get down systems actual algorithms so, you start with it an initial value problem you will have Y′ of T = some function of T and Y .
00:02:20.000 --> 00:02:35.000
They also, have an initial value Y T = Y not and shall choose a step size and usually when you are studying differential equations the step size will be given to you it would not be your own choice to choose the step size.
00:02:35.000 --> 00:02:44.000
So, that will usually be given of course in real life you get to choose your own step size depending on how accurate of an answer you want and how much work you want to do.
00:02:44.000 --> 00:03:04.000
So, you start at T0Y0 and you make iterative steps to me fill in this the T N+ 1 it is just the same as it was for the Euler method it is just TN +8 so, just stepping over in horizontal steps of size H
00:03:04.000 --> 00:03:25.000
Y MT TN +1 so, this is Y and + 1 Y N + 1 is the same as Y TN +1 now, this is much more complicated than it was for Euler’s method so, let me show the steps for this carefully.
00:03:25.000 --> 00:03:43.000
It is Y N+ now, H instead of just H x F of TN YN that was the Euler’s method formula its H x K-1 + K2 over 2 see what they did this is an average because it is and what is it an average out.
00:03:43.000 --> 00:04:07.000
Let me explain what these that this K-1 and K2 are so, K-1 is just F of T and Y so, that is what we had that is the same as it was for Euler’s method the K2 is different K2 is F of now, for TU plug-in TN + H and for Y you plug-in Y and + H x K1.
00:04:07.000 --> 00:04:25.000
So, that is quite a bit more complicated so, what will do each time is will calculate this will calculate this K1 and will calculate this K2 and plug them back into this formula here and will find Y N+1.
00:04:25.000 --> 00:04:43.000
So, and will step along will find T1 and Y 1 in T2 and Y 2 and keep going along by these little steps until you arrive at the value of T that you want to as that you want to use for your approximation of Y of T.
00:04:43.000 --> 00:04:55.000
So, we will see how that works out it is a little complicated but it is it is it is not sort of theoretically difficult is just a matter sort of following these formulas through.
00:04:55.000 --> 00:05:18.000
So, let us try that out in a first example really is run Dakota was step size H = .01 to estimate Y .01 in the initial value problem Y′ = 1+ T - Y and Y0 = 1 so, let me remind you of the Runge-Kutta formulas.
00:05:18.000 --> 00:06:09.000
They run Dakota formula said TN + 1 = TN + H and Y N+1 = Y N+ H x K-1 + K2 /2 and K-1 was F T and YN and K2 that is the complicated 1 that is F of TN + H and Y N+ H K1 .
00:06:09.000 --> 00:06:33.000
So, let us go ahead and try to figure those out here we have this the F is this function right here it is always Y′ = F of TY so, F of TY must be 1 + T - T - Y and we get our T01Y0 from the initial condition .
00:06:33.000 --> 00:07:13.000
T0 is 0 and Y0 = 1 and so, now, let us start calculating T1 is T0 + H T0+0.1 which is 0.1 and out to find Y 1 we are to need to find these this K1 and K2 so, what is worked that out K1 is F of T0Y0 so, that is F of 0, 1 which is 1+0-1 which is 0 very convenient.
00:07:13.000 --> 00:07:38.000
K2 is F TN + H so, that is F0.1 and YN + H x K1 so, YN was Y061 + H is 0.1 and K1 is all that is just 0 .
00:07:38.000 --> 00:08:30.000
So, this is F of 0.1 and 1+0 so, just 1 and so, that is 1 + T - Y so, 1 +0.1 T -1 which is .1 so, that is our K-1 and K2 and now, we can find our Y1 is Y0 + H x K-1 + K2 /2 which is worth Y0Y0 was 1 + H0.1 .
00:08:30.000 --> 00:08:57.000
Now, my K-1 was 0 my K2 was 0.1 /2 so, that is 0.1 / 2 is .05×.1 is .005 and so, I got 1 + that and so, he got 1.005.
00:08:57.000 --> 00:09:22.000
So, my T1Y1 are 0.1 that comes from there and 1.005 and since I have already arrived at the value of T that I was looking for the stop and say that is my estimate for Y1 .005.
00:09:22.000 --> 00:09:39.000
So, let me go back and recap here first I just copied the formulas from the beginning of the lecture that is what we found out at the beginning of the lecture for our new formulas, for TN + 1YN + 1 in terms of K-1 and K2 .
00:09:39.000 --> 00:10:03.000
Now, the F comes from the differential equation that is F of T Y there my T0Y0, from the initial condition and my T1 is always just T0 + H so, that is 0.1 and then to find Y 1 I need my values of case so, unplugging everything into the appropriate F.
00:10:03.000 --> 00:10:36.000
So, that is my K-1 that is my K2 playing everything into this formula for K2 that F is 0.11 and number this was my F so, it is 1 + T - Y1 +0.1-1 simplifies down to .1 so, now, I use my formula for Y 1 so, I get Y0 + H x the average of K-1 and K2 drop in what I figured out for my K2 and my K-1 was just 0 .
00:10:36.000 --> 00:10:55.000
So, that is without 0 and out .1 come from work out there is a check I get Y 1 is 1.005 and since I already arrived at the value of T that I was asked for I got a Y value as an approximation.
00:10:55.000 --> 00:11:08.000
So, example 2 works in any keep going with the previous example so, you definitely want to have watched example 1 before you try out this example is working to use our answer from example 1.
00:11:08.000 --> 00:12:05.000
Reuse run Dakota was step size H = .01 0.1 to estimate Y .2 in the initial value problem is the same initial value problem we had for example 1 so, let me record first of all the formulas for Runge-Kutta our TN + 1 = TN + H our YN +1 = Y N+ H x this average K1 + K2 over 2 where the K-1is are given by K1 is just F of TN YN and K2 is more complicated F of TN + H T x T sub N + H and YN + H x case of 1 .
00:12:05.000 --> 00:12:23.000
So, we are going to use our example from our answer from example 1 so, let me remind you what the answer from example 1 was if you have just watched it probably worth going back and looking at example 1.
00:12:23.000 --> 00:12:38.000
Example 1 we figured out that T1 was 0.1 and our Y1 we figure this out before was 1.005 so, much as calculating those are coming from example 1 and so, let us go ahead and take it from there.
00:12:38.000 --> 00:13:13.000
So, T 2 is T1 + H T1 0.1 H is 0.1 so, T2 0.2 and Y 2 our Y2 is before figure out Y to me go ahead and figure out what the case should be so, I will find K1 is F of TN Y Nthat is F of T1Y1 which is F of 0.1 and 1.005 .
00:13:13.000 --> 00:13:49.000
Getting those numbers from example 1 and so, now, my F is this function right here 1 + T - Y so, 1 +0.1-1.005 and if I simplify that down it turns into 0.095 .095 so, now, I need to find my K2 its F of TN + H so, .1+ H is is .2 0.2 .
00:13:49.000 --> 00:14:09.000
And now, Y N where was my Y N, that is 1.005 that is Y 1 + H0.1 x K-1 is 0.95 so, let us simplify that down in 2.095.
00:14:09.000 --> 00:14:41.000
Sorry I put my decimal point the wrong place it is 0.95 .095 and so, if I multiply by .1 I get 2 0s .0095 and if we add that to 1.005 forget F of 0.2 and then 1.005 and .0095 so, 1.0145.
00:14:41.000 --> 00:15:10.000
Now, my F function that is F right there so, it is 1 + the T value .2 - the Y value 1.0145 and so, that simplifies down .2-.0145 is .0 .1855 .
00:15:10.000 --> 00:15:50.000
Sounds K2 and now, going to use my formula here to find Y2 Y2 is Y N Y 1 + H x K-1 + K2 /2 now, where is my Y1 there is 1.005 1.005+ my H is 0.1 K-1 was .095 and K2 is 0.1855 /2 .
00:15:50.000 --> 00:16:25.000
And now, those are a bunch of decimals that I can just go ahead and throw into my calculator .095+ .1855÷2 x .1+1.005 and I see that when this all settles down I get 1.019025 .
00:16:25.000 --> 00:16:51.000
And I can stop there the reason I can stop is because I have gotten to achieve value of 0.2 which is the goal T value that we are asked for the problem so, stop there and summarize T2Y2Y is T value is 0.2 and the Y value was 1.019025 .
00:16:51.000 --> 00:17:09.000
So, that Y value right there is my estimate for Y of 0.2 and that is what we are asked for in this problem so, we remind you how all the steps worked out there.
00:17:09.000 --> 00:17:26.000
I start out with the generic Runge-Kutta order to formulas also, known as approved Euler’s portals such as copies formulas overfill beginning of the lecture and those K1 and K2is are also, part of those formulas from the beginning of today's lecture .
00:17:26.000 --> 00:17:48.000
This is the same initial value problem that we had for example 1 we did the first step of it in example 1 we found T1 and Y 1 so, example 2 here this can keep going with those values and so, I get my T2 is T1 + H which is 0.2 .
00:17:48.000 --> 00:18:12.000
I am going to find K1 and K2 using my F function which I get from the differential equation so, there that is 1 + T - Y so, I plug-in T1 and Y 1 get .095 for K-1 for K2 I have apply my F function here .
00:18:12.000 --> 00:18:38.000
I am reading off this formula right here and then plug in all the values TN + H there is my Y1 there is my H there is my K1 those simplify down 2.2 and 1.0145 and now, again using the F function appear so, I get 1 + T - Y simplifies down 2.1855 .
00:18:38.000 --> 00:19:13.000
And then I played back into my main Runge-Kutta formula here sets run getting this line , and I just drop in all the numbers my Y1 my H and K1 and K2 worked out all those decimals on my calculator got 1.019025 and so, my T2 was 0.2 and that is my Y to write there and that is what I am stopping in the reason I am stopping there is because I have a Y .2 in the requirement for the problem.
00:19:13.000 --> 00:19:41.000
So, since I party got into T = .2 then I take that Y value and I offer it as my approximation and as my final answer to that problem so, keep this problem in mind and also, keep this answer in mind because in the next example over to do is resolve this differential equation analytically and never go to compare our answer from the analytic solution with the estimate that we just made using the Runge-Kutta method.
00:19:41.000 --> 00:19:53.000
So, let us see how those 2 answers compare so, example 3 we are to solve the initial value problem Y′ = 1 +2 - Y and Y0 = 1.
00:19:53.000 --> 00:20:08.000
Resolve this initial value problem analytically in order to calculate how Y of .2 and really see how close the answer is to the estimate that we use in the previous example.
00:20:08.000 --> 00:20:22.000
So, I cannot can have to do very much work in this problem because I have done this 1 before this is the same initial value problem that we did for example 2in the previous lecture on Euler’s methods.
00:20:22.000 --> 00:20:48.000
So, if you do not remember that what you might want to do is go back and check out 2 to from the previous lecture on Euler’s methods so, from the Euler’s method lecture and we found the answer analytically there.
00:20:48.000 --> 00:21:07.000
Remind you what was we found the answer was Y = C+E -T so, that is coming from the previous lecture not working that out on the spot here but if you have no idea where that is coming from just check out the previous lecture is example 2 on the Euler’s method lecture.
00:21:07.000 --> 00:22:16.000
And so, now, we are going to compute Y of 0.25 0.2 = that if T0 .2+ E -0.2 and try that to signify that of course that is been recently used by calculator for 2130 So, 0.2+ E -.2 and I see I get 1.01873 that is approximation there so, that is my guess for Y0 .2 and that is really the answer given by an analytic solutions. 2203 They should think of that is essentially being an exact solution now, we also, solve this equation using the Runge-Kutta method and that was in example 2 of this lecture.
00:22:16.000 --> 00:22:50.000
So, example 2 of this lecture so, that should be just above this 1 of this lecture we used the Runge-Kutta method to estimate Y of 0.2 and I am just a copy of the answer that we had back there got so, 1.019025 .
00:22:50.000 --> 00:23:08.000
Sure that I am copying the right number there now, got 1.019025 using the Runge-Kutta estimation technique and we now, know, that the true solution is 1.0187.
00:23:08.000 --> 00:23:36.000
So, let me just subtract those to show you how close we got there .0187 not cannot bother keeping track of decimal places after that because I see that is not 190 - hundred and 87 is 3 so, .0003 is our error there.
00:23:36.000 --> 00:24:03.000
0.0003 is our error so, what you should really see here the new lesson you should take away from this is that the Runge-Kutta estimation technique is extremely accurate the true solution is 1.0187 our Runge-Kutta solution we figured out the previous example is 1.0190.
00:24:03.000 --> 00:24:27.000
Very close the difference between those two answers is 0.0003 that is 1000 thousand 10,003 10,000 off from each other so, those answers are really very close so, even though it is a lot of work to calculate that Runge-Kutta solution the payoff is we get an answer that is very close to being the true solution is extremely accurate.
00:24:27.000 --> 00:24:50.000
So, let us do a little more practice with calculating some Runge-Kutta answers in example 4 we are going to use Runge-Kutta was step size H = .0 .1 to estimate Y of 0.1 in the initial value problem Y′ = T-² + Y ² and Y001.
00:24:50.000 --> 00:25:25.000
So, let me remind you of the Runge-Kutta formulas we have TN + 1 = TN + H and Y N+ 1 = Y N+ H + H x K1 + K2 over to this copying these back from the first slide of this as was the second slide of this lecture .
00:25:25.000 --> 00:25:51.000
So, if you have not looked at the first couple size of this lecture that is where I am getting these formulas from where the K1 was F TN Y N and the K2 is as of TN + H and Y N+ H x K-1 .
00:25:51.000 --> 00:26:22.000
So, let us apply those in this case Our F of TY that is just what you get from the differential equation so, that is T-² + Y ² and we start off at the initial condition that we are given so, that is Y 0s equal 1 so, Y01 start with T0, T0 = 0 and Y0 = 1 .
00:26:22.000 --> 00:26:46.000
So, let me go ahead and plug all those numbers into the Runge-Kutta formulas so, TN +1 T1 is just T0 + H and that 0+0.1 so, that is 0.1 and now, I want to find Y 1 but in order to do that I need to know, my K1 and my K2 .
00:26:46.000 --> 00:27:44.000
So, I got a fine K1 is F of TN Y N so, that is aft of T0Y001 and so, that is 0 ² +1 ² that is my F function 0 ² +1 ² is 1 my K2 is F of TN + H so, that is 0.10+.1 and Y N is 1 + H is .01 x K-1 is 1 so, that is 0.1 ² + now, 1 +.1 is 1.1 ² .
00:27:44.000 --> 00:28:30.000
So, that is myself little more space here 0.01+1.21 so, that is 1.2 to select my K2 and out my Y1 is Y0 + H x K1 + K2 /2 now, my Y0 there it is this 1 by H is still 0.1 my K1 is 1 my K2 is 1.22 over 2 .
00:28:30.000 --> 00:28:49.000
And if I just worked that out this 1 point this is 2.22 over 270.1×1.11 and so, that is .111 & get 1.111 .
00:28:49.000 --> 00:29:22.000
And I can stop here because I got a T 1 of 0.1 I got a Y1 1.111 which is the T value is the T value those asked for the prompt for the problem so, stop there and summarize T1Y1 = 0.1 and 1.111 and so, that 1.111 that is my estimate for Y of 0.1.
00:29:22.000 --> 00:29:38.000
So, that is what I would offer is my answer to the problem so, may I remind you where everything came from there for so, I just copy down these equations for the Runge-Kutta method to copy those down from the initial slide of the lecture 2nd slide lecture .
00:29:38.000 --> 00:29:56.000
Then I identify what my F of T Y was that is just dysfunction that that we had for Y′ and then I identified T0 Y0 that came from the initial condition here and I started running through the equations.
00:29:56.000 --> 00:30:25.000
T1 is T0 + H we are that is my H here so, that 0.1 my K1is F01 so, that is 0 ² +1 ² my K2 is F of this more complicated expression of getting that from up here by the way and I filled in all the numbers there so, that is T1 that is Y 0 that is H and that is K1 .
00:30:25.000 --> 00:30:53.000
Filled in all those numbers get and plug it into my F function T² + Y ² simplify that down to 1.22 and finally use this YN +1 formula so, Y 0+ H x K1 + K2 over 2 there is Y 0 there is H there is K1 there is K2 and then I justify the decimals down to get 1.111.
00:30:53.000 --> 00:31:16.000
So, my T1 and Y1 there is T1 came from their there is my Y1 and in a stop there and the reason I am been a stop is because I was asked to estimate Y of 0.1 and so, I am going to give my Y 1 as my estimate for Y of 0.1
00:31:16.000 --> 00:31:35.000
The end of this example we are going to use these this same initial value problem and the same computations as the first step of the next example 5 so, hang onto these numbers and can be the same initial value problem will take it 1 more step in example 5 .
00:31:35.000 --> 00:31:54.000
So, in example 5 reuse Runge-Kutta was step size H = 0.1 to estimate Y in 0.2 in the initial value problem Y′ = T² + Y ² and Y 0s equal 1.
00:31:54.000 --> 00:32:14.000
Now, once you remember this is the same initial value problem that we studied in example 4 so, we are going to use our answer from example 4 to solve this if you have not just watched example 4 just go back and check that out and you will see where we are getting our starting point for this for this example 5 .
00:32:14.000 --> 00:32:46.000
So, let me remind you of our Runge-Kutta equations TN + 1 = TN + H YN +1 = Y N+ H x K1 + K2 /2and my K-1 = F of TN YN.
00:32:46.000 --> 00:33:08.000
My K2 = TN + H and Y N+ H x K1 so, we are going to run this algorithm for this initial value problem but we party did the first step back in example 4.
00:33:08.000 --> 00:33:20.000
So, go ahead and copy down the answers we had from example 4 might calculate those from scratch if you want to see where they came from just go back and watch example for you will see everything there.
00:33:20.000 --> 00:33:35.000
So, what we had there is T1 we already figured it out back in example 4 T1 was 0.1 and our Y1 figure out last time was 1.111 .
00:33:35.000 --> 00:34:06.000
So, really use those to take this out 1 more step so, our T2 is T1 + H so, that is 0.2 find my K1 K2 so, K1 is F of TN Y is that 0.1 and 1.111 now, my F function is given by the differential equation right here T² + Y ² that is F rate there .
00:34:06.000 --> 00:34:28.000
And so, this is point .1 ² +1.111 ² and I do not think I want to do that plug that into my calculator so, .1 ² +1.111 ² is 1.244321 .
00:34:28.000 --> 00:34:57.000
All say that as a number in my calculator K2 is F of TN + H so, 0.2 and now, my YN that is Y once a 1.111+ H is 0.1 x K-1 which is 1.244321 .
00:34:57.000 --> 00:35:29.000
So, this is F of 0.2 and do some calculations right there so, looks like 1.235 here so, about 1.235 here and if I plug that into F I got .2 ² +1.235 ² .
00:35:29.000 --> 00:36:11.000
And again I am going to calculate that out on my calculator and I see I get 1.566 for my K2 number ready to drop all those numbers and my formula for YN +1 find myself a Y2 is Y 1 + H x K1 + K2 over 2 and so, my Y 1 that is 1.111111.
00:36:11.000 --> 00:36:37.000
H is still 0.1 and my K1 is 1.244 my K2 is 1.566 got all those numbers saved in my calculator now, and now, I am just going to simplify the decimals of them definitely do that on my calculator .
00:36:37.000 --> 00:37:11.000
So, + 1.244321÷2 x .1+1.111 so, what I am getting on my calculator is 1.25153, in there some more decimal places after that but let me summarize here.
00:37:11.000 --> 00:37:29.000
T2Y2 according to what we just figured out where is T2 right there, Y2 is right there so, T2 is 0.2 and Y2 is 1.25153.
00:37:29.000 --> 00:37:52.000
And that is my answer as my estimate for Y of 0.2 and that is what we are being asked for the problem check this back out so, that is that means I am time of the problem below me go ahead and go back and make sure that all the steps are totally clear there.
00:37:52.000 --> 00:38:09.000
We started out with the generic Runge-Kutta formulas copy those down from the second slide a lecture TN + 1YN +1 and K1 K2 complicated but not too bad and remember that this is the same differential equation we had for example 4.
00:38:09.000 --> 00:38:31.000
We already did the first step of Runge-Kutta in example 4 so, that is what I am doing right here is just taking my answers from example 4 back watch example 4 and see where they came from and they we are to run with those answers and run 1 more step to get to get 2.2 .
00:38:31.000 --> 00:39:00.000
So, T2 is just T1 +8 that is 0.2 and then I found K1 K2 using these formulas here K1 K2 and I plug in all the values that is T1 that is Y 1 that is T1 + H and that is Y 1 that was my H and this was K1.
00:39:00.000 --> 00:39:14.000
And then to calculate F of those values running T² + Y ² so, that is Y doing .1 ² +1.111 ² and here I am doing.2 ² +1.235 ² .
00:39:14.000 --> 00:39:38.000
So, calculate out those decimals and I get K1 K2 the drop those in the formula for Y 2 drop those in right there multiplied by Hs 0.1 and I still have my Y1 so, there is Y 1 there is H run using this formula right here to figure out Y 2 .
00:39:38.000 --> 00:39:47.000
Drop in all those decimals and I justify those decimals of my calculator I did not think there is any reason to do that on the screen.
00:39:47.000 --> 00:40:18.000
So, we get 1.25153 that is my T2 is 0.2 my Y2 is 1.25153 and so, since I have gotten to the value of T that I was asked to find in the in a prompt that are rather that I was asked to find my estimate at I am just to take the Y value at that point and offer that as my estimate of Y is 0.2.
00:40:18.000 --> 00:40:35.000
So, my final estimate there is 1.25153 since the end of this lecture on Runge-Kutta order 2 techniques also, known as the improved Euler’s method if you seen it called that maybe in a class or in a different textbook.
00:40:35.000 --> 00:40:47.000
That also, wraps up our chapter on numerical techniques when you cannot solve the differential equation analytically you try to use 1 of these numerical techniques Euler’s method or Runge-Kutta methods.
00:40:47.000 --> 00:40:57.000
So, that wraps up this chapter and that puts another chapter of differential equations into the books so, I really appreciate your watching.
00:40:57.000 --> 00:41:04.000
You have been watching the differential equations lecture here on educator.com. My name is Will Murray, thanks for joining us, bye bye.