WEBVTT
1
00:00:00.000 --> 00:00:24.800
The topic for today is
2
00:00:30.000 --> 00:00:37.000
I'm posting the linear equations the next time.
3
00:00:37.000 --> 00:00:49.000
Instead, I think it's a good idea since in real life most of the differential equations are solved by numerical methods to introduce you to those right away.
4
00:00:49.000 --> 00:01:04.000
Even when you see the computer screen, the solution is being drawn.
5
00:01:04.000 --> 00:01:15.000
This is the main way.
6
00:01:15.000 --> 00:01:25.000
The problem is an initial value problem. Let's write it a first order problem the way we talked about it on Wednesday.
7
00:01:25.000 --> 00:01:32.000
Now I'll add to that the starting point that you used when you did the computer experiments.
8
00:01:32.000 --> 00:01:37.000
I'll write the starting point this way. The y of x0 should be y0.
9
00:01:37.000 --> 00:01:42.000
This is the initial condition and this is the first order differential equation.
10
00:01:42.000 --> 00:02:01.000
The two of them together are called an IVP, an initial value problem, which means two things, the differential equation and the initial value that you want to start the solution at.
11
00:02:01.000 --> 00:02:26.000
Now the method we're going to talk about, the basic method of which many others are merely refinements in one way or another is called Euler's method.
12
00:02:26.000 --> 00:02:38.000
Euler, who did of course everything in analysis, didn't, as far as I know, didn't actually use it to compute solutions of differential equations. His interest was theoretical.
13
00:02:38.000 --> 00:02:45.000
He used it as a method of proving the existence theorem, proving that solutions existed.
14
00:02:45.000 --> 00:03:05.000
Nowadays it's used to calculate the solutions numerically. The method is very simple to describe. It's so naive. If you probably think that if you were been living 300 years ago, you would have discovered it and covered yourself with glory for all eternity.
15
00:03:05.000 --> 00:03:22.000
So here is our starting point, x0 y0. Now what information do we have? At that point, all we have is the little line element whose slope is given by f of xy.
16
00:03:22.000 --> 00:03:42.000
So if I start the solution, the only way the solution could possibly go would be to start off in that direction, since I have no other information. At least it has the correct direction at x0 y0, but of course it's not likely to have the correct direction anywhere else.
17
00:03:42.000 --> 00:03:52.000
Now what you do then is choose a step size. I'll draw just a few two steps of the method. That's I think good enough.
18
00:03:52.000 --> 00:04:07.000
Choose a step size, a uniform step size, which is usually called h. And you continue that solution until you get to the next point, which will be x0 plus h, as I've drawn it on the picture.
19
00:04:07.000 --> 00:04:26.000
We get to here, we stop at that point, and now you recalculate what the line element is here. Suppose here the line element now through this point goes like that. Well, then that's the new direction that you should start out with going from here.
20
00:04:26.000 --> 00:04:41.000
And so the next step of the process will carry you to here. That's two steps of Euler's method. Notice it produces a broken line approximation to the solution. But in fact, you only see that broken line.
21
00:04:41.000 --> 00:05:00.000
So you're at a computer, if you're looking at the computer visual, for example, which is whose purpose is to illustrate for Euler's method. In actual practice, what you see is just the computer is simply calculating this point, that point, that point, and the succession of points.
22
00:05:00.000 --> 00:05:09.000
And many programs will just automatically connect those points by a smooth looking curve, if that's what you prefer to see.
23
00:05:09.000 --> 00:05:27.000
Well, that's all there is to the method. What we have to do now is derive the equations for the method. Now how are we going to do that? Well, the essence of it is how to get from the end step to the n plus first step.
24
00:05:27.000 --> 00:05:50.000
So I'm going to draw the picture just to illustrate that. So now we're not at x0, but let's say we've already gotten to xn, yn. How do I take the next step? Well, I take the line element, and it goes up like that, let's say, because the slope is this.
25
00:05:50.000 --> 00:06:06.000
I'm going to call that slope a sub n. Of course, a sub n is the value of the right hand side at the point xn, yn, and we'll need that in the equation. But I think it will be a little clearer if I just give it a capital letter at this point.
26
00:06:06.000 --> 00:06:24.000
Now, now this is the new point, and all I want to know is what are its coordinates? Well, the xn plus one is there. The yn plus one is here. Clearly, I should draw this triangle, complete the triangle.
27
00:06:24.000 --> 00:06:47.000
This side of the triangle, the hypotenuse has slope a n. This side of the triangle has length h. h is the step size. Perhaps I better indicate that. Actually put that up so that you know the word step size. It means how it's the step size on the x axis. How far you have to go to get from each x to the next one.
28
00:06:47.000 --> 00:07:06.000
What's this? Well, if that slope has this, the slope, an, this is h, then this must be h times an. The length of that side. Right? In order that the ratio of the height to this width should be an.
29
00:07:06.000 --> 00:07:22.000
That gives us the method. What's the? How do I get from clearly to get from xn to xn plus one? I simply add h. So that's the trivial part of it. The interesting thing is how do I get the new yn plus one?
30
00:07:22.000 --> 00:07:48.000
So the best way to write it as that yn plus one minus yn divided by h. Well, yn, sorry, yn plus one minus yn is, is this line the same as the line h times a n. So that's the way to write it.
31
00:07:48.000 --> 00:08:08.000
Or since the computer is interested in calculating yn plus one itself, put it this on the other side. You take the old yn, the previous one, and to it you add h times a n. And what pretel is a n? Well, the computer has to be told that a n is the value of f.
32
00:08:08.000 --> 00:08:27.000
So now with that, let's actually write the Euler program, not the program, but the Euler, the Euler method equations. Let's just call it the Euler equations. What will they be? First of all, the new x is the old x plus h.
33
00:08:27.000 --> 00:08:50.000
The new y is just what I've written there. The old y plus h times a certain number, a n. And finally, a n has the value. It's the slope of the line element here. And therefore, by definition, that's f of x and yn.
34
00:08:50.000 --> 00:09:14.000
So it's these three equations, which define Euler's method. If I assume in 100 surely, you must be asked to at some point as an exercise in the term at one point to calculate, to program the computer and see or whatever they're using Java now, I guess, to do Euler Euler's method.
35
00:09:14.000 --> 00:09:21.000
And these are the equations you would, these would be the recursive equations that you would put into do that.
36
00:09:21.000 --> 00:09:30.000
Okay, let's try an example then.
37
00:09:30.000 --> 00:09:45.000
It's what would be a good taller for Euler. Well, purple. I assume nobody can see purple. Is that correct? Can anyone in the back of the room see that purple?
38
00:09:45.000 --> 00:10:06.000
So let's calculate the example. I'll use a simple example, but it's not entirely trivial. My example is going to be the equation x squared minus y squared on the right hand side.
39
00:10:06.000 --> 00:10:23.000
And let's start with y of zero equals one, let's say. And so this is my initial value problem, that pair of equations. And I have to specify a step size. Let's take the step size to be point one.
40
00:10:23.000 --> 00:10:33.000
You choose the step size or the computer does. We'll have to talk about that in a few minutes. Now what do you do? Well,
41
00:10:33.000 --> 00:10:48.000
I say this is a non-trivial equation because this equation as far as I know cannot be solved in terms of elementary functions. So this equation v, in fact, the very good candidate for numerical method like Euler's.
42
00:10:48.000 --> 00:11:01.000
And you how to use it or maybe with the other way around, I forget. On your problem set, you drew a picture of the direction field and answered some questions about the isoclines.
43
00:11:01.000 --> 00:11:27.000
How the solutions behave. All right. Now, the main thing I want you to get this is not just for Euler's talking about Euler's equations, but in general, for the calculations you have to do in this course, it's extremely important to be systematic because if you are not systematic, you know, if you just scribble, scribble, scribble, scribble, scribble, you can do the work, but it comes impossible to find mistakes.
44
00:11:27.000 --> 00:11:53.000
You must do the work in a form in which you can check, in which it can be checked, which you can look over it, find and try to see where the mistakes are, if in fact there are any. So I strongly suggest, this is not a suggestion, this is a command that you make a little tape to do Euler's method by hand. I'd only ask you for a step or two.
45
00:11:53.000 --> 00:12:14.000
I'm just trying to make sure you have some idea of these equations and where they come from. So first, the value of n, then the value of xn, then the value of the yn, and then a couple of more columns, which tell you what the calculation, how to do the calculation.
46
00:12:14.000 --> 00:12:29.000
So I'm going to need the value of the slope, and it's probably a good idea also because otherwise you'll forget it to put in h, a, n because that occurs in the formula.
47
00:12:29.000 --> 00:12:45.000
So I'm doing it. Well, the first value of n is zero, that's the starting point. At the starting point, x0, y0, x has the value zero, and y has the value one. So zero and one.
48
00:12:45.000 --> 00:13:06.000
In other words, I'm starting, I'm carrying out exactly what I drew pictorially, only now I'm doing it, arithmetically using a table, and substituting into the formulas. Okay, the next thing we have to calculate is an. Well, that's since an is the value of the right hand side.
49
00:13:06.000 --> 00:13:20.000
At the point zero one, you have to plug that in the right hand side is x squared minus y squared. So it's zero squared minus one squared. The value of the slope there is minus one. Negative one.
50
00:13:20.000 --> 00:13:30.000
Now, I have to multiply that by h, h is point one. So it's minus, sorry, negative. I'll never learn that.
51
00:13:30.000 --> 00:13:37.000
The way you learn to talk in kindergarten is the way you learn to talk the rest of your life, unfortunately.
52
00:13:37.000 --> 00:13:48.000
kindergarten, we said minus. Negative point one.
53
00:13:48.000 --> 00:14:05.000
It is one now. What's the value of xn? Well, to the old one, I add one tenth. What's the value of y? Well, at this point, you have to do the calculation. It's the old value of y to get this new value.
54
00:14:05.000 --> 00:14:16.000
It's the old value plus this number. Well, that's this plus that number is nine tenths.
55
00:14:16.000 --> 00:14:34.000
And now I have to calculate the new slope at this point. Okay, that is one tenth squared minus nine tenths squared. That's point oh one minus point eighty one, which makes minus point eighty.
56
00:14:34.000 --> 00:14:38.000
I hope.
57
00:14:38.000 --> 00:14:53.000
Check it on your calculators. Whip them out and press the buttons. I now multiply that by h, which means it's going to be minus point oh eight.
58
00:14:53.000 --> 00:15:05.000
Perhaps with a zero after. I didn't tell you how many decimal places. Let's carry it out to two decimal places. I think that'll be good enough.
59
00:15:05.000 --> 00:15:20.000
Finally, the last step to here. Add one at another one tenth so that value of x is now two tenths. And finally, what's the value of y? Well, I didn't tell you where to stop. Let's stop at y of point.
60
00:15:20.000 --> 00:15:27.000
Let's stop at y point two because there's no more room on the blackboard. It seems like an excellent.
61
00:15:27.000 --> 00:15:49.000
So, ultimately, how big is that? In other words, then this is going to be. This, the old y plus this number, which seems to be point eighty two to me.
62
00:15:49.000 --> 00:16:00.000
The new value is point eighty two. Okay, well, we got a number. We did what we were supposed to do. We got a number next question. Well, let's ask a few questions.
63
00:16:00.000 --> 00:16:14.000
One of the first most basic thing is, you know, how right is this? How can I answer such a question if I can count if I have no explicit formula for that solution?
64
00:16:14.000 --> 00:16:27.000
The basic problem with numerical calculation. In other words, I have to wander around in the dark to some extent and yet have some idea when I've arrived at the place that I want to go.
65
00:16:27.000 --> 00:16:41.000
Well, the first question I'd like to answer question is, is this too high or too low? Is Euler? Sorry, he will forgive me in heaven. I will use him by this. I mean, is the result?
66
00:16:41.000 --> 00:16:55.000
Let me say something first and then I'll criticize it. Is Euler too high or too low? In other words, is the result of using Euler's method?
67
00:16:55.000 --> 00:17:13.000
Is this number too high or too low? Is it higher than the right answer, what it should be, or is it lower than the right answer or God forbid is it exactly right? It's almost never exactly right. That's not an option.
68
00:17:13.000 --> 00:17:32.000
Let me answer that question. Well, let's answer it geometrically. If the solution were aligned, then the Euler method would be exactly right all the time.
69
00:17:32.000 --> 00:17:51.000
But it's not a line. Then it's a curve. Well, the critical question is, is the solution? So here's the solution. Let's call it y1 of x. Let's say here was the starting point. Here the solution is convex.
70
00:17:51.000 --> 00:18:12.000
And here the solution is concave. Concave up, concave down if you learn those words. I think those by now pretty, I hope pretty well disappeared from the curriculum. Call it if you have enough on now what mathematicians call it convex is that and the other one is concave.
71
00:18:12.000 --> 00:18:31.000
Well, how do the Euler solutions look? Well, I'll just sketch. I think from this you can see already. When you start out on the Euler solution, it's going to go like that. Now you're too low. Well, let's suppose after that the line element here is approximately the same as what it is there.
72
00:18:31.000 --> 00:18:43.000
You know, roughly parallel after all they're not too far apart. And the direction field is continuous. That is the directions don't change drastically from one point to another. Well, then it will sort of.
73
00:18:43.000 --> 00:18:55.000
But now you see it's still too low. It's even lower. As it pathetically tries to follow. It's losing territory. And that's basically because the curve is convex.
74
00:18:55.000 --> 00:19:05.000
Exactly the opposite would happen if the curve were concave, if the solution curve were concave. Now it's too high. And it's not going to be able to correct that.
75
00:19:05.000 --> 00:19:15.000
As long as the solution curve stays concave. Well, that's probably too optimistic is probably more like this.
76
00:19:15.000 --> 00:19:28.000
So in other words, in this case, if the curve is convex, the Euler is going to be too high. Sorry, too low.
77
00:19:28.000 --> 00:19:37.000
Let's put E for Euler. How about that? Euler is too low. If it's concave, then Euler is too high.
78
00:19:37.000 --> 00:20:01.000
Okay, that's great. There's just one little problem left. Namely, if we don't have a formula for the solution and we don't have a computer that's busy drawing the picture for us, in which case we wouldn't need any of this anyway, how will we supposed to tell if it's concave or concave?
79
00:20:01.000 --> 00:20:21.000
Back to calculus, calculus to the rescue. When is it a curve convex? A curve is convex if its second derivative is positive because the first to be convex means the first derivative is increasing all the time.
80
00:20:21.000 --> 00:20:35.000
And therefore, the second derivative, which is the derivative of the first derivative, should be positive. Just the opposite here, the curve, the slope is, the first derivative is decreasing all the time, and therefore, the second derivative is negative.
81
00:20:35.000 --> 00:20:42.000
So all we have to do is decide what the first and second derivative of this solution is.
82
00:20:42.000 --> 00:20:57.000
We should probably call it a solution to, y of x is a little too vague. y1 means the solution that started at this point. So, in fact, probably it would have been better from the beginning to call that y1, except there's no room.
83
00:20:57.000 --> 00:21:14.000
y1, let's say. That means the solution which started out at the point zero one. So, I'm still talking about a solution like that. All right. So, I want to know if this is positive, the second derivative is positive at the starting point zero, or it's negative.
84
00:21:14.000 --> 00:21:29.000
Now, again, how do you calculate the second derivative if you can't even, if you don't know what the solution is explicitly. And the answer is, you can do it from the differential equation itself. How do I do that? Well, easy.
85
00:21:29.000 --> 00:21:47.000
y prime equals x squared minus y squared. Okay. That tells me how to calculate y prime, if I know the value of x and y, in other words, the point zero one. What would be the value of y double prime? Well, differentiate the equation.
86
00:21:47.000 --> 00:22:11.000
It's 2x minus 2y, y prime. Don't forget to use the chain rule. So, if I want to calculate at zero one. In other words, my starting point is that curve convex or concave. Well, let's calculate y of zero equals one.
87
00:22:11.000 --> 00:22:20.000
Okay. What's y prime of zero? Well, I don't have to repeat that calculation using this. I already calculated that it was negative one.
88
00:22:20.000 --> 00:22:35.000
And now the new thing is what's y double prime of zero? Well, it is this. It is, I'll write it out. It's 2 times zero minus 2 times negative y, which is one.
89
00:22:35.000 --> 00:22:50.000
You want to see what pulling ourselves up our own bootstraps, which is impossible, but it is not impossible because we're doing it.
90
00:22:50.000 --> 00:23:09.000
So, what's the answer? Zero here, two. I've calculated without having the foggiest idea of what the solution is or how it looks. I've calculated that it's second derivative at the starting point is two. Therefore, my solution is convex at the starting point.
91
00:23:09.000 --> 00:23:29.000
And therefore, this oil approximation, if I don't carry it out too far, will be 2 low. So, it's convex, oil or 2 low. Now, you can argue.
92
00:23:29.000 --> 00:23:56.000
So, what about this? Suppose it. Yeah, we would move here. So, you go like this, but then it catches up. Well, of course, if the curve changes from convex to concave, then it's really impossible to make any prediction at all. That's a difficulty.
93
00:23:56.000 --> 00:24:23.000
So, all this analysis is only if you stay very nearby. However, I wanted to show you the main purpose of it in my mind was to show you how to use the different, it's these equations. How to use the differential equation itself to get information about the solutions without actually being able to calculate the solutions.
94
00:24:23.000 --> 00:24:50.000
Now, so that's the method, and that's how to find out something about it. And now, what I'd like to talk about is errors. How do I handle? Oh. Right. So, I mean, that's an in a sense, I've started the error analysis. In other words, the error by definition of the error is this difference.
95
00:24:50.000 --> 00:25:13.000
The error between, so in other words, I'm asking here is the error positive. It depends which way you measure it. Usually you take this minus that. So, here the error. The error would be considered positive, and here would be considered negative, although I'm sure there's a book somewhere in the world, which does the opposite.
96
00:25:13.000 --> 00:25:28.000
Most hedge by just using the absolute value of the error. Plus the statement that the method is producing answers, which are too low or too high.
97
00:25:28.000 --> 00:25:48.000
The question then is, naturally, this is not the world's best method. It's not as bad as it seems. It's not the world's best method, because that convexity and concavity means that you're automatically introducing a systematic error.
98
00:25:48.000 --> 00:26:06.000
And predict which way the error is going to be by just knowing what the curve is convex or concave, then that's, it's not what you want. I mean, you want to at least have a chance of getting the right answer, whereas this is telling you you're definitely going to get the wrong answer.
99
00:26:06.000 --> 00:26:35.000
So, the question is, how do you get a better method? A search is for a better method. Now, the first method which will occur, I'm sure, to anyone who looks at that picture is,
100
00:26:35.000 --> 00:26:50.000
look, if you want this yellow line to follow the white one, the white solution, more accurately, to heaven's sake, don't take such big steps. Take small steps, and then it will follow better.
101
00:26:50.000 --> 00:27:11.000
Alright, let's draw a picture. I'm just kidding. My little box of treasure here. Take it any way, good way.
102
00:27:11.000 --> 00:27:33.000
So, use a smaller step size. And the picture roughly, which is going to justify that, will look like this. If the solution curve looks like this, then with a big step size, I'm liable to have something that looks like that.
103
00:27:33.000 --> 00:27:52.000
But if I take a smaller step size, suppose I have the step size, how is it going to look then? Well, I better switch to a different color. If I have the step size, I'll get a littler, goes like that. And now it's following closer.
104
00:27:52.000 --> 00:28:04.000
Of course, I'm stacking the deck. But see how close it follows? I'm definitely not to be trusted on this, but there.
105
00:28:04.000 --> 00:28:25.000
Okay, let's do the opposite and make a really big step. Suppose instead of the yellow one, I'd use the green one. Well, a double step size. Well, what would have happened then? Well, I started out, but now I've gone all the way to there. And now on my way up, of course, it has a little further to go. But if the sun reason I stopped there, you could see I would be still lower.
106
00:28:25.000 --> 00:28:39.000
In other words, the bigger the step size, the more the error. And where are the errors that we're talking about? Well, the way to think of the errors, this is the error.
107
00:28:39.000 --> 00:28:49.000
That number, the error, and you can make it a positive negative or just put it automatically, an absolute value sign around it. That's not so important.
108
00:28:49.000 --> 00:29:12.000
Of course, the conclusion is that the error, that the error, e, the difference between the true value that I should have gotten and the Euler value that the calculation produced, the error, e depends on the step size.
109
00:29:12.000 --> 00:29:24.000
Well, how does it depend on the step size? Well, it's impossible to give an exact formula, but there's an approximate answer, which is by and large, true.
110
00:29:24.000 --> 00:29:37.000
And the answer is, so e is going to be a function of h. What function? Well, asymptotically, which means there's another way of putting quotation marks around what I say.
111
00:29:37.000 --> 00:29:44.000
To be a constant, some constant, times h.
112
00:29:44.000 --> 00:30:13.000
It's pretty boyish. It looks like this.
113
00:30:13.000 --> 00:30:20.000
The first order, the Euler is a first-order method.
114
00:30:20.000 --> 00:30:35.000
And now, first order does not refer to the first order of the differential equation. It's not that use of the word first.
115
00:30:35.000 --> 00:30:45.000
It's not the first order because it's y prime equals f of x, y. The first order means the fact that h occurs to the first power.
116
00:30:45.000 --> 00:31:03.000
The way people usually stay this is, since the normal way of decreasing the step size, as you'll see as soon as you try to, use the computer visual of the deals with the Euler method, which I highly recommend, by the way, so highly recommended that you have to do it.
117
00:31:03.000 --> 00:31:15.000
The way to say it, since each new step has the step size, that's the usual way to do it.
118
00:31:15.000 --> 00:31:37.000
If you have the step size, since this is a constant, if I have the step size, I have the error approximately, have the step size, have the error.
119
00:31:37.000 --> 00:31:51.000
That tells you how the error varies with step size for Euler's method.
120
00:31:51.000 --> 00:32:09.000
So, please understand, that's what people say, and please understand the grammatical construction. Since every one of the math department has a cold these days, except me for the moment, everyone goes around chanting this mantra.
121
00:32:09.000 --> 00:32:13.000
This is totally irrelevant.
122
00:32:13.000 --> 00:32:32.000
So, if you ask the mantra, feed a cold star of a fever. And if you ask them what it means, they say, it means eat a lot if you have a cold, and if you have a fever, don't eat very much, which is not what it means at all.
123
00:32:32.000 --> 00:32:43.000
So, it's exactly the same construction as this. What this means is, if you have the step size, you will have the error.
124
00:32:43.000 --> 00:32:57.000
And that's what feed a cold star of a fever means. And remember this for the rest of your life. If you feed a cold, if you eat too much when you have a cold, you will get a fever and end up having to starve yourself.
125
00:32:57.000 --> 00:33:03.000
Because, of course, nobody, when you have a fever, nobody feels like eating, so they don't eat anything.
126
00:33:03.000 --> 00:33:08.000
You got that? You got that. Good.
127
00:33:08.000 --> 00:33:13.000
Go home.
128
00:33:13.000 --> 00:33:30.000
All of you to go home and tell that to your mothers. That's the way we always use to speak back. A grimmer wants to spare the rod and spoil the child.
129
00:33:30.000 --> 00:33:44.000
It does not mean that you should not hit your kid. It means that if you fail to hit your kid, he or she will be spoiled. Whatever that means.
130
00:33:44.000 --> 00:33:58.000
So, you don't want to do that. I guess the mantra today would be what? I don't know.
131
00:33:58.000 --> 00:34:18.000
Okay. So, the first line of defense is simply to keep having the step size in oiler. What people do is, if they don't want to use anything better than oiler's method, is you keep having the step size until the curve doesn't seem to change anymore.
132
00:34:18.000 --> 00:34:31.000
And then you say, well, that must be the solution. And I ask you on the problem said, how much would you continue to have the step size in order for that good thing to happen?
133
00:34:31.000 --> 00:34:37.000
However, there are more efficient methods, which gets the result faster.
134
00:34:37.000 --> 00:34:58.000
So, if that's our good method, let's call this a better, a still better method. The better methods aim at being better, they keep the same idea as oiler's method, but they say, look, let's try to improve that slope A n.
135
00:34:58.000 --> 00:35:19.000
In other words, since the slope A n that we start with is guaranteed to be wrong if the curve is convex or concave, can we somehow correct it so that, for example, instead of a, immediately aiming there, can't we somehow aim it so that by luck, we just, the next step just lands us back on the curve again.
136
00:35:19.000 --> 00:35:36.000
In other words, what's sort of looking for the short path, a shortcut path, which by good luck will end us up back on the curve again. And all the improvements, the simple improvements on oiler method, the method and they are the most stable in ways to do, solve differential equations numerically.
137
00:35:36.000 --> 00:35:54.000
Aim it finding a better slope. So they find a better value for, a better, a better slope. Find a better value for, then, a n. Try to improve that slope that you found.
138
00:35:54.000 --> 00:36:08.000
Now, once you have the idea that you should look for a better slope, it's not very difficult to see what, in fact, you should try. Again, I think most of you would say, hey, I would have thought of that.
139
00:36:08.000 --> 00:36:19.000
And you'd be closer in time since these methods were only found about maybe a hundred, around the turn of the last century is when I placed them.
140
00:36:19.000 --> 00:36:32.000
Mostly by some German mathematicians interested in solving equations numerically. All right. So what is the better method? Our better slope. What should we look for in our better slope?
141
00:36:32.000 --> 00:36:42.000
Well, the simplest procedure is, once again, we're starting from there. And the oiler slope would be the same as the line element.
142
00:36:42.000 --> 00:36:52.000
So the line element looks like this and our yellow slope, a n, I'll still continue to call it a n, goes like that and gets to here.
143
00:36:52.000 --> 00:37:04.000
Okay. Now, if it were convex, if the curve were convex, this would be too low. And therefore, the next step would be, I'm going to draw this next step in pinks.
144
00:37:04.000 --> 00:37:19.000
Well, let's continue in here. Would be going up like that. I'll call this bn just because it's the next step of oiler's method. It could be called a n prime or something like that.
145
00:37:19.000 --> 00:37:31.000
But this will do. And now what you do is, let me put an arrow on it to indicate parallelness. Go back to the beginning. Draw this parallel to bn.
146
00:37:31.000 --> 00:37:52.000
So here is bn, again, just a line of slope, that same slope. And now what you should use as the simplest improvement on oiler's method is take the average of these two because that's more likely to hit the curve than a n will, which is sure to be too low if the curve is convex.
147
00:37:52.000 --> 00:38:04.000
In other words, use this instead. Use that. So this is our better slope.
148
00:38:04.000 --> 00:38:17.000
Okay. What will we call that slope? We don't have to call it anything. What would the equations for the method b? Well, xn plus one is gotten by adding the step size.
149
00:38:17.000 --> 00:38:35.000
So here's my step size, just as it was before. Just as it was before, the new thing is how to get the new value of y. So yn plus one should be the old yn plus h times not this crummy slope, a n.
150
00:38:35.000 --> 00:38:59.000
So let's do it in two steps. It's the average of a n and bn. Hey, but you didn't tell me or I didn't tell you what bn was. So you now must tell the computer, oh yes, by the way, you remember that a n was what it always was.
151
00:38:59.000 --> 00:39:18.000
So what is bn? Well, to get bn, bn is the slope of the line element at this new point. Now, what am I going to call that new point? I don't want to call this y value, yn plus one because that's, it's this up here that's going to be the yn plus one.
152
00:39:18.000 --> 00:39:29.000
This is a temporary value used to make another calculation, which will then be combined with the previous calculations to get the right value.
153
00:39:29.000 --> 00:39:43.000
Therefore, give it a temporary name. That point will call it, it's not going to be the final, the real yn plus one. We'll call it yn plus one twittles, yn plus one temporary.
154
00:39:43.000 --> 00:39:54.000
And what's the formula for it? Well, it's just going to be what the Euler formula, original Euler formula, it's going to be yn plus what you would have gotten if you calculated.
155
00:39:54.000 --> 00:40:11.000
In other words, it's the point that the Euler method produced, but it's not finally the point that we want. Now, do I have to say anything else? Yeah, I didn't tell the computer what bn was. Okay, bn is the slope of the direction.
156
00:40:11.000 --> 00:40:28.000
The slope of the direction field at the point n plus one and the computer knows what that is. And this point yn plus one temporary.
157
00:40:28.000 --> 00:40:43.000
So, you make a temporary choice of this, calculate that number, and then go back and as it were correct that value to this value by using this better slope.
158
00:40:43.000 --> 00:40:52.000
Now, that's all there is to the method, except I didn't give you its name. Well, it has three names, four names, in fact.
159
00:40:52.000 --> 00:41:06.000
So, I'm going to give you a bunch of I give you. I don't care. Okay, the shortest name is Hoeyn's method, but nobody knows, pronounces that correctly.
160
00:41:06.000 --> 00:41:29.000
So, it's Hoeyn's method. It's called also the improved Euler method. It's called modified Euler. Very expressive word. Modified Euler's method. And it's also called RK2.
161
00:41:29.000 --> 00:41:47.000
I'm sure you'll like that name best. It has a star wars sort of sound to it. RK stands for Runga Kutta. And the reason for the two is not that it uses, well, it is that it uses two slopes.
162
00:41:47.000 --> 00:42:07.000
But the real reason for the two is that it is a second-order method. So, that's the most important thing to put down about it. It's a second-order method, whereas Euler was only a first-order method. So, this is a Hoeyn's method, or RK2, let's write it. That's the shortest thing to write.
163
00:42:07.000 --> 00:42:26.000
So, that's the second-order method, meaning that the error varies with the step size, like some constant. It won't be the same as the constant for Euler's method, times H squared.
164
00:42:26.000 --> 00:42:40.000
So, it's not the same thing because it now means that if you have the step size, you're going to decrease the error by a factor of 1-quarter. You will quarter the error.
165
00:42:40.000 --> 00:42:44.000
Now, you say, hey, great. Why should anyone use anything else?
166
00:42:44.000 --> 00:42:59.000
Think a little second. The real thing which determines how slowly one of these methods run is, you look at the hardest step of the method and ask how long does the computer take? How many of those hardest steps are there?
167
00:42:59.000 --> 00:43:24.000
Now, the answer is, the hardest step is always the evaluation of the slope, the evaluation of the function. Because the functions that are common use are not x squared minus y squared. They take half a page and have its coefficients, you know, ten decimal place numbers, whatever the guy, the engineer is doing it, you know, whatever their accuracy was.
168
00:43:24.000 --> 00:43:38.000
So, the thing that controls how long a method runs is how many times the slope, the function must be evaluated. For Euler, I only have to evaluate it once.
169
00:43:38.000 --> 00:43:52.000
Here, I have to evaluate it twice. Now, roughly speaking, the number of function evaluations will give you the exponent.
170
00:43:52.000 --> 00:44:10.000
The method that's called rung or cut of fourth order will require four evaluations of slope, but the accuracy will be like h to the fourth. Very accurate. You have the step size and it goes down by a factor of 16. Great.
171
00:44:10.000 --> 00:44:29.000
You had to evaluate the slope four times. Suppose instead you had four times this thing, what would you have done? You would have decreased it to one sixteenth of what it was.
172
00:44:29.000 --> 00:44:49.000
Still, you would increase the number of functions evaluations you needed to four and you would have decreased the error by a sixteenth. So, in some sense, it really doesn't matter whether you use a very fancy method, which requires more function evaluations.
173
00:44:49.000 --> 00:45:05.000
So, the error goes down faster, but you're having to do more work to get it. So, anyway, nothing is free. Now, I was, there is an rk four. I think I'll skip that since I wouldn't dare to ask you any questions about it.
174
00:45:05.000 --> 00:45:25.000
Let me just mention it at least because it's the standard. It uses four evaluation. It's the standard method if you don't want to do anything fancier. It's rather inefficient, but it's very accurate. Standard method, accurate.
175
00:45:25.000 --> 00:45:44.000
And you'll see when you use the programs, it's in fact the program which is drawing those curves, the numerical method which draws all those curves that you believe in on the computer screen is the rk four method. The runga cut up, I should give them their names.
176
00:45:44.000 --> 00:46:05.000
Runga cut up, fourth order method. Two mathematicians, I believe both German mathematicians around the turn of last century. Runga cut up, fourth order method requires four slopes.
177
00:46:05.000 --> 00:46:18.000
It requires you to calculate four slopes. I won't bother telling you what to do, but it's a procedure like that. It's just a little more elaborate. And you take two of these, you make up a weighted average for the super slope.
178
00:46:18.000 --> 00:46:34.000
You use weighted average, what should I divide that by to get the right six? Well, six, well, because if all these numbers were the same, I'd want it to come out to be whatever that common value was.
179
00:46:34.000 --> 00:46:54.000
Therefore, you always must divide by, in a weighted average, you must always divide by the sum of the coefficients. So this is the super slope. And if you plug that super slope in to here, you will be using the wrong a cut of method and get the best possible results.
180
00:46:54.000 --> 00:47:09.000
Now, I wanted to spend the last three minutes talking about pitfalls and numerical computation in general. One pitfall, I'm leaving you on the homework to discover for yourself.
181
00:47:09.000 --> 00:47:24.000
Don't worry, it won't cause you any grief. Just, it'll just destroy your faith in these things for the rest of your life, which is probably a good thing. So pitfalls.
182
00:47:24.000 --> 00:47:36.000
Number one, you find, you'll find. Let me talk instead briefly about number two, which I'm not giving you an exercise in.
183
00:47:36.000 --> 00:47:57.000
Number two is illustrated by the following equation. What could be simpler? This is a very bad equation to try to solve numerically. Now, why? Well, because if I separate variables, why don't I say a little time? I'll just tell you what the solution is.
184
00:47:57.000 --> 00:48:10.000
Obviously, you separate variables, maybe you can do it in your head. The solution will be, the solutions will have an arbitrary constant in them and they won't be very complicated. They will be one over c minus x.
185
00:48:10.000 --> 00:48:29.000
C is an arbitrary constant and as you give different values, you can, now what do those guys look like? Okay, so here I am. I'm start out at the point one and I start out, I tell the computer compute for me the value of the solution at one, starting out at one.
186
00:48:29.000 --> 00:48:51.000
I say that the computer computes a little while, but the solution, how does this curve actually look? So in other words, suppose I say that y of zero equals one, find me y of two. In other words, take a nice small step size, use the wrong account of fourth order method, calculate a little bit and tell me I just want to know what y of two is.
187
00:48:51.000 --> 00:49:09.000
Well, what is y of two? Well, unfortunately, how does that curve look? The curve looks like this. At that point it drops to infinity in a manner of speaking and then sort of comes back up again like that.
188
00:49:09.000 --> 00:49:24.000
What is the value of y? This is the point one. What is the value of y of two? Is it here? Is it this? Well, I don't know, but I do know that the computer will not find it.
189
00:49:24.000 --> 00:49:35.000
The computer will follow this along and get lost in eternity and see no reason whatever it's just why it should start again on this branch of the curve.
190
00:49:35.000 --> 00:49:52.000
Well, we should, can't we predict that that's going to happen somehow and avoid it? What I should have, you know, the whole difficulty is this is called a singular point. This, this solution has a singularity.
191
00:49:52.000 --> 00:50:21.000
Where it's a place where it goes to infinity or becomes discontinuous, maybe has a jump discontinuity. It has a singularity at x equals c. This in particular at x equals 1 here. But from the differential equation, where is that c? There is no way of predicting it. Each solution, in other words, to this differential equation has its own private singularity, which only it knows about and where it's going to blow up.
192
00:50:21.000 --> 00:50:35.000
And there's no way of telling from the differential equation where that's going to be. That's what makes numerical, one of the things that makes numerical calculation difficult. When you cannot predict where things are going to go bad in advance.