1
00:00:00 --> 00:00:06
2
00:00:20 --> 00:00:26
The topic for today is --
3
00:00:23 --> 00:00:29
4
00:00:32 --> 00:00:38
Today we're going to talk,
I'm postponing the linear
5
00:00:35 --> 00:00:41
equations to next time.
Instead, I think it's a good
6
00:00:38 --> 00:00:44
idea, since in real life,
most of the differential
7
00:00:42 --> 00:00:48
equations are solved by
numerical methods to introduce
8
00:00:45 --> 00:00:51
you to those right away.
Even when you see the compute
9
00:00:49 --> 00:00:55
where you saw the computer
screen, the solutions being
10
00:00:53 --> 00:00:59
drawn.
Of course, what really was
11
00:00:55 --> 00:01:01
happening was that the computer
was calculating the solutions
12
00:00:59 --> 00:01:05
numerically, and plotting the
points.
13
00:01:03 --> 00:01:09
So, this is the main way,
numerically,
14
00:01:05 --> 00:01:11
it is the main way differential
equations are actually solved,
15
00:01:09 --> 00:01:15
if they are of any complexity
at all.
16
00:01:12 --> 00:01:18
So, the problem is,
that initial value problem,
17
00:01:15 --> 00:01:21
let's write up the first-order
problem the way we talked about
18
00:01:20 --> 00:01:26
it on Wednesday.
And now, I'll specifically add
19
00:01:23 --> 00:01:29
to that, the starting point that
you used when you did the
20
00:01:27 --> 00:01:33
computer experiments.
And, I'll write the starting
21
00:01:32 --> 00:01:38
point this way.
So, y of x0 should be y0.
22
00:01:35 --> 00:01:41
So, this is the initial
23
00:01:38 --> 00:01:44
condition, and this is the
first-order differential
24
00:01:42 --> 00:01:48
equation.
And, as you know,
25
00:01:44 --> 00:01:50
the two of them together are
called an IVP,
26
00:01:48 --> 00:01:54
an initial value problem,
which means two things,
27
00:01:51 --> 00:01:57
the differential equation and
the initial value that you want
28
00:01:56 --> 00:02:02
to start the solution at.
Okay, now, the method we are
29
00:02:03 --> 00:02:09
going to talk about,
the basic method of which many
30
00:02:08 --> 00:02:14
others are merely refinements in
one way or another,
31
00:02:14 --> 00:02:20
is called Euler's method.
Euler, who did,
32
00:02:19 --> 00:02:25
of course, everything in
analysis, as far as I know,
33
00:02:25 --> 00:02:31
didn't actually use it to
compute solutions of
34
00:02:30 --> 00:02:36
differential equations.
His interest was theoretical.
35
00:02:36 --> 00:02:42
He used it as a method of
proving the existence theorem,
36
00:02:40 --> 00:02:46
proving that solutions existed.
But, nowadays,
37
00:02:44 --> 00:02:50
it's used to calculate the
solutions numerically.
38
00:02:47 --> 00:02:53
And, the method is very simple
to describe.
39
00:02:51 --> 00:02:57
It's so naive that you probably
think that if you that living
40
00:02:55 --> 00:03:01
300 years ago,
you would have discovered it
41
00:02:59 --> 00:03:05
and covered yourself with glory
for all eternity.
42
00:03:04 --> 00:03:10
So, here is our starting point,
(x0, y0).
43
00:03:07 --> 00:03:13
Now, what information do we
have?
44
00:03:10 --> 00:03:16
At that point all we have is
the little line element,
45
00:03:14 --> 00:03:20
whose slope is given by f of
(x, y).
46
00:03:18 --> 00:03:24
So, if I start the solution,
47
00:03:21 --> 00:03:27
the only way the solution could
possibly go would be to start
48
00:03:26 --> 00:03:32
off in that direction,
since I have no other
49
00:03:30 --> 00:03:36
information.
At least it has the correct
50
00:03:35 --> 00:03:41
direction at (x0,
y0).
51
00:03:36 --> 00:03:42
But, of course,
it's not likely to have the
52
00:03:40 --> 00:03:46
correct direction anywhere else.
Now, what you do,
53
00:03:43 --> 00:03:49
then, is choose a step size.
I'll try just two steps of the
54
00:03:48 --> 00:03:54
method.
That's, I think,
55
00:03:50 --> 00:03:56
good enough.
Choose a uniform step size,
56
00:03:53 --> 00:03:59
which is usually called h.
And, you continue that solution
57
00:03:57 --> 00:04:03
until you get to the next point,
which will be x0 + h,
58
00:04:02 --> 00:04:08
as I've drawn it on the
picture.
59
00:04:06 --> 00:04:12
So, we get to here.
We stop at that point,
60
00:04:09 --> 00:04:15
and now you recalculate what
the line element is here.
61
00:04:12 --> 00:04:18
Suppose, here,
the line element,
62
00:04:15 --> 00:04:21
now, through this point goes
like that.
63
00:04:18 --> 00:04:24
Well, then, that's the new
direction that you should start
64
00:04:22 --> 00:04:28
out with going from here.
And so, the next step of the
65
00:04:26 --> 00:04:32
process will carry you to here.
That's two steps of Euler's
66
00:04:30 --> 00:04:36
method.
Notice it produces a broken
67
00:04:33 --> 00:04:39
line approximation to the
solution.
68
00:04:36 --> 00:04:42
But, in fact,
you only see that broken line
69
00:04:39 --> 00:04:45
if you are at a computer if you
are looking at the computer
70
00:04:43 --> 00:04:49
visual, for example,
whose purpose is to illustrate
71
00:04:47 --> 00:04:53
for you Euler's method.
In actual practice,
72
00:04:50 --> 00:04:56
what you see is,
the computer is simply
73
00:04:53 --> 00:04:59
calculating this point,
that point, and the succession
74
00:04:57 --> 00:05:03
of points.
And, many programs will just
75
00:04:59 --> 00:05:05
automatically connect those
points by a smooth looking curve
76
00:05:04 --> 00:05:10
if that's what you prefer to
see.
77
00:05:08 --> 00:05:14
Well, that's all there is to
the method.
78
00:05:11 --> 00:05:17
What we have to do now is
derive the equations for the
79
00:05:15 --> 00:05:21
method.
Now, how are we going to do
80
00:05:18 --> 00:05:24
that?
Well, the essence of it is how
81
00:05:21 --> 00:05:27
to get from the nth step to the
n plus first
82
00:05:26 --> 00:05:32
step?
So, I'm going to draw a picture
83
00:05:29 --> 00:05:35
just to illustrate that.
So, now we are not at x0.
84
00:05:34 --> 00:05:40
But let's say we've already
gotten to (xn,
85
00:05:37 --> 00:05:43
yn).
How do I take the next step?
86
00:05:40 --> 00:05:46
Well, I take the line element,
and it goes up like that,
87
00:05:44 --> 00:05:50
let's say, because the slope is
this.
88
00:05:47 --> 00:05:53
I'm going to call that slope A
sub n.
89
00:05:51 --> 00:05:57
Of course, A sub n is the value
of the right hand side at the
90
00:05:56 --> 00:06:02
point (xn, yn),
and we will need that in the
91
00:05:59 --> 00:06:05
equation, --
-- but I think it will be a
92
00:06:03 --> 00:06:09
little bit clearer if I just
give it a capital letter at this
93
00:06:08 --> 00:06:14
point.
Now, this is the new point,
94
00:06:10 --> 00:06:16
and all I want to know is what
are its coordinates?
95
00:06:14 --> 00:06:20
Well, the x n plus one
is there.
96
00:06:17 --> 00:06:23
The y n plus one is here.
97
00:06:19 --> 00:06:25
Clearly I should draw this
triangle, complete the triangle.
98
00:06:23 --> 00:06:29
This side of the triangle,
the hypotenuse has slope An.
99
00:06:27 --> 00:06:33
This side of the triangle has
length h.
100
00:06:30 --> 00:06:36
h is the step size.
Perhaps I'd better indicate
101
00:06:33 --> 00:06:39
that, actually put that up so
that you know the word step.
102
00:06:39 --> 00:06:45
It's the step size on the
x-axis, how far you have to go
103
00:06:44 --> 00:06:50
to get from each x to the next
one.
104
00:06:47 --> 00:06:53
What's this?
Well, if that slope has this,
105
00:06:51 --> 00:06:57
the slope An,
this is h.
106
00:06:53 --> 00:06:59
Then this must be h times An,
the length of that side,
107
00:06:58 --> 00:07:04
in order that the ratio of the
height to this width should be
108
00:07:03 --> 00:07:09
An.
And, that gives us the method.
109
00:07:07 --> 00:07:13
How do I get from,
clearly, to get from xn to x n
110
00:07:12 --> 00:07:18
plus one,
I simply add h.
111
00:07:16 --> 00:07:22
So, that's the trivial part of
it.
112
00:07:19 --> 00:07:25
The interesting thing is,
how do I get the new
113
00:07:24 --> 00:07:30
y n plus one?
And so, the best way to write
114
00:07:28 --> 00:07:34
it as, that y n plus one minus
yn divided by h,
115
00:07:32 --> 00:07:38
well, sorry,
y n plus one minus yn is this
116
00:07:36 --> 00:07:42
line, the same as the line h
times An.
117
00:07:43 --> 00:07:49
So, that's the way to write it.
Or, since the computer is
118
00:07:47 --> 00:07:53
interested in calculating y n
plus one itself,
119
00:07:52 --> 00:07:58
put this on the other side.
You take the old yn,
120
00:07:56 --> 00:08:02
the previous one,
and to it, you add h times An.
121
00:08:00 --> 00:08:06
And, what, pray tell,
122
00:08:03 --> 00:08:09
is An?
Well, the computer has to be
123
00:08:07 --> 00:08:13
told that An is the value of f.
So, now, with that,
124
00:08:11 --> 00:08:17
let's actually write the Euler
program, not the program,
125
00:08:15 --> 00:08:21
but the Euler-- the Euler
method equations,
126
00:08:19 --> 00:08:25
let's just call it the Euler
equations.
127
00:08:22 --> 00:08:28
What will they be?
First of all,
128
00:08:24 --> 00:08:30
the new x is the old x plus h.
129
00:08:28 --> 00:08:34
The new y is just what I've
written there,
130
00:08:31 --> 00:08:37
the old y plus h times a
certain number,
131
00:08:34 --> 00:08:40
An, and finally,
132
00:08:38 --> 00:08:44
An has the value--
It's the slope of the line
133
00:08:43 --> 00:08:49
element here,
and therefore by definition,
134
00:08:47 --> 00:08:53
that's f of (xn,yn).
135
00:08:50 --> 00:08:56
So, if these three equations
which define Euler's method.
136
00:08:55 --> 00:09:01
I assume in 1.00 you must be
asked to, at some point,
137
00:09:00 --> 00:09:06
as an exercise in the term at
one point to program the
138
00:09:05 --> 00:09:11
computer in C or whatever
they're using,
139
00:09:08 --> 00:09:14
Java, now, I guess,
to do Euler's method.
140
00:09:14 --> 00:09:20
And, these would be the
recursive equations that you
141
00:09:20 --> 00:09:26
would put in to do that.
Okay, let's try an example,
142
00:09:27 --> 00:09:33
then.
So, what would be a good color
143
00:09:32 --> 00:09:38
for Euler?
Well, a purple.
144
00:09:35 --> 00:09:41
I assume nobody can see purple.
Is that correct?
145
00:09:40 --> 00:09:46
Can anyone in the back of the
room see that that's purple?
146
00:09:46 --> 00:09:52
Okay.
Sit closer.
147
00:09:48 --> 00:09:54
So, let's calculate.
The example,
148
00:09:52 --> 00:09:58
I'll use a simple example,
but it's not entirely trivial.
149
00:10:00 --> 00:10:06
My example is going to be the
equation, x squared minus y
150
00:10:03 --> 00:10:09
squared on the
right hand side.
151
00:10:07 --> 00:10:13
And, let's start with y of zero
equals one,
152
00:10:10 --> 00:10:16
let's say.
And so, this is my initial
153
00:10:13 --> 00:10:19
value problem,
that pair of equations.
154
00:10:16 --> 00:10:22
And, I have to specify a step
size.
155
00:10:18 --> 00:10:24
So, let's take the step size to
0.1.
156
00:10:20 --> 00:10:26
You choose the step size,
or the computer does.
157
00:10:24 --> 00:10:30
We'll have to talk about that
in a few minutes.
158
00:10:27 --> 00:10:33
Now, what do you do?
Well, I say this is a
159
00:10:31 --> 00:10:37
nontrivial equation because this
equation, as far as I know,
160
00:10:36 --> 00:10:42
cannot be solved in terms of
elementary functions.
161
00:10:39 --> 00:10:45
So, this equation would be,
in fact, a very good candidate
162
00:10:43 --> 00:10:49
for a numerical method like
Euler's.
163
00:10:46 --> 00:10:52
And, you had to use it,
or maybe it was the other way
164
00:10:50 --> 00:10:56
around, I forget.
On your problem set,
165
00:10:53 --> 00:10:59
you drew a picture of the
direction field and answered
166
00:10:57 --> 00:11:03
some questions about the
isoclines, how the solutions
167
00:11:01 --> 00:11:07
behave.
Now, the main thing I want you
168
00:11:04 --> 00:11:10
to get, this is not just for
Euler's, talking about Euler's
169
00:11:08 --> 00:11:14
equations.
But in general,
170
00:11:10 --> 00:11:16
for the calculations you have
to do in this course,
171
00:11:13 --> 00:11:19
it's extremely important to be
systematic because if you are
172
00:11:17 --> 00:11:23
not systematic,
you know, if you just scribble,
173
00:11:20 --> 00:11:26
scribble, scribble,
scribble, scribble,
174
00:11:22 --> 00:11:28
you can do the work,
but it becomes impossible to
175
00:11:25 --> 00:11:31
find mistakes.
You must do the work in a form
176
00:11:28 --> 00:11:34
in which it can be checked,
which you can look over it and
177
00:11:32 --> 00:11:38
find, and try to see where
mistakes are if,
178
00:11:35 --> 00:11:41
in fact, there are any.
So, I strongly suggest,
179
00:11:39 --> 00:11:45
this is not a suggestion,
this is a command,
180
00:11:43 --> 00:11:49
that you make a little table to
do Euler's method by hand,
181
00:11:48 --> 00:11:54
I'd only ask you for a step or
two, but since I'm just trying
182
00:11:53 --> 00:11:59
to make sure you have some idea
of these equations and where
183
00:11:58 --> 00:12:04
they come from.
So, first, the value of n,
184
00:12:02 --> 00:12:08
then the value of xn,
then the value of the yn,
185
00:12:06 --> 00:12:12
and then, a couple of more
columns which tell you how to do
186
00:12:11 --> 00:12:17
the calculation.
You are going to need the value
187
00:12:15 --> 00:12:21
of the slope,
and it's probably a good idea,
188
00:12:18 --> 00:12:24
also, because otherwise you'll
forget it, to put in h An
189
00:12:23 --> 00:12:29
because that occurs in the
formula.
190
00:12:26 --> 00:12:32
All right, let's start doing
it.
191
00:12:30 --> 00:12:36
The first value of n is zero.
That's the starting point.
192
00:12:34 --> 00:12:40
At the starting point,
(x0, y0), x has the value zero,
193
00:12:38 --> 00:12:44
and y has the value one,
so, zero and one.
194
00:12:42 --> 00:12:48
In other words,
starting, I'm carrying out
195
00:12:45 --> 00:12:51
exactly what I drew pictorially
only now I'm doing it
196
00:12:49 --> 00:12:55
arithmetically using a table and
substituting into the formulas.
197
00:12:55 --> 00:13:01
Okay, the next thing we have to
calculate is An.
198
00:13:00 --> 00:13:06
Well, since An is the value of
the right hand side,
199
00:13:03 --> 00:13:09
at the point zero one,
you have to plug that in.
200
00:13:07 --> 00:13:13
The right-hand side is x
squared minus y squared.
201
00:13:11 --> 00:13:17
So, it's 0 squared minus 1
squared.
202
00:13:14 --> 00:13:20
The value of the slope,
203
00:13:17 --> 00:13:23
there, is minus one,
negative one.
204
00:13:20 --> 00:13:26
Now, I have to multiply that by
H.
205
00:13:22 --> 00:13:28
h is 0.1.
So, it's negative,
206
00:13:24 --> 00:13:30
I'll never learn that.
The way you learn to talk in
207
00:13:28 --> 00:13:34
kindergarten is the way you
learn to talk the rest of your
208
00:13:32 --> 00:13:38
life, unfortunately.
In kindergarten,
209
00:13:37 --> 00:13:43
we said minus.
Negative 0.1.
210
00:13:40 --> 00:13:46
n is one now.
What's the value of xn?
211
00:13:45 --> 00:13:51
Well, to the old value I add
1/10.
212
00:13:48 --> 00:13:54
What's the value of y?
Well, at this point,
213
00:13:53 --> 00:13:59
you have to do the calculation.
It's the old value of y.
214
00:13:59 --> 00:14:05
To get this new value,
it's the old value plus this
215
00:14:05 --> 00:14:11
number.
Well, that's this plus that
216
00:14:11 --> 00:14:17
number is nine-tenths.
An, now I have to calculate the
217
00:14:16 --> 00:14:22
new slope at this point.
Okay, that is one-tenth squared
218
00:14:23 --> 00:14:29
minus nine-tenths squared.
That's 0.01 minus 0.81,
219
00:14:28 --> 00:14:34
which makes minus 0.80,
I hope.
220
00:14:31 --> 00:14:37
221
222
00:14:38 --> 00:14:44
Check it on your calculators.
Whip them out and press the
223
00:14:43 --> 00:14:49
buttons.
I now multiply that by h,
224
00:14:46 --> 00:14:52
which means it's going to be
minus 0.08, perhaps with a zero
225
00:14:51 --> 00:14:57
after.
I didn't tell you how many
226
00:14:54 --> 00:15:00
decimal places.
Let's carry it out to two
227
00:14:58 --> 00:15:04
decimal places.
I think that will be good
228
00:15:02 --> 00:15:08
enough.
And finally,
229
00:15:05 --> 00:15:11
the last step,
2, here, add another one-tenth,
230
00:15:10 --> 00:15:16
so the value of x is now
two-tenths.
231
00:15:15 --> 00:15:21
And finally,
what's the value of y?
232
00:15:18 --> 00:15:24
Well, I didn't tell you where
to stop.
233
00:15:22 --> 00:15:28
Let's stop at y of 0.2
because there's no
234
00:15:28 --> 00:15:34
more room on the blackboard.
About approximately how big is
235
00:15:34 --> 00:15:40
that?
In other words,
236
00:15:36 --> 00:15:42
this is, then,
this is going to be the old y
237
00:15:41 --> 00:15:47
plus this number,
which seems to be 0.82 to me.
238
00:15:48 --> 00:15:54
So, the answer is,
the new value is 0.82.
239
00:15:51 --> 00:15:57
Okay, we got a number.
We did what we are supposed to
240
00:15:55 --> 00:16:01
do.
We got a number.
241
00:15:56 --> 00:16:02
Next question?
Now, let's ask a few questions.
242
00:16:00 --> 00:16:06
One of the first,
most basic things is,
243
00:16:03 --> 00:16:09
you know, how right is this?
How can I answer such a
244
00:16:07 --> 00:16:13
question if I have no explicit
formula for that solution?
245
00:16:11 --> 00:16:17
That's the basic problem with
numerical calculation.
246
00:16:15 --> 00:16:21
In other words,
I have to wander around in the
247
00:16:18 --> 00:16:24
dark to some extent,
and yet have some idea when
248
00:16:21 --> 00:16:27
I've arrived at the place that I
want to go.
249
00:16:24 --> 00:16:30
Well, the first question I'd
like to answer,
250
00:16:28 --> 00:16:34
is this too high or too low?
Is Euler, sorry,
251
00:16:32 --> 00:16:38
he'll forgive me in heaven,
I will use him.
252
00:16:36 --> 00:16:42
By this, I mean,
is the result,
253
00:16:38 --> 00:16:44
let me just say something
first, and that I'll criticize
254
00:16:43 --> 00:16:49
it.
Is Euler too high or too low?
255
00:16:46 --> 00:16:52
In other words,
is the result of using Euler's
256
00:16:50 --> 00:16:56
method, i.e.
is this number too high or too
257
00:16:53 --> 00:16:59
low?
Is it higher than the right
258
00:16:56 --> 00:17:02
answer, what it should be?
Or, is it lower than the right
259
00:17:02 --> 00:17:08
answer?
Or, God forbid,
260
00:17:05 --> 00:17:11
is it exactly right?
Well, it's almost never exactly
261
00:17:09 --> 00:17:15
right.
That's not an option.
262
00:17:12 --> 00:17:18
Now, how will we answer that
question?
263
00:17:16 --> 00:17:22
Well, let's answer it
geometrically.
264
00:17:19 --> 00:17:25
Basically, if the solution were
a straight line,
265
00:17:24 --> 00:17:30
then the Euler method would be
exactly right all the time.
266
00:17:29 --> 00:17:35
But, it's not a line.
Then it's a curve.
267
00:17:34 --> 00:17:40
Well, the critical question is,
is it curved?
268
00:17:38 --> 00:17:44
Is the solution?
So, here's a solution.
269
00:17:41 --> 00:17:47
Let's call it y1 of x,
and let's say here
270
00:17:45 --> 00:17:51
was the starting point.
Here, the solution is convex.
271
00:17:49 --> 00:17:55
And, here the solution is
concave, right?
272
00:17:52 --> 00:17:58
Concave up or concave down,
if you learn those words,
273
00:17:57 --> 00:18:03
but I think those have,
by now, I hope pretty well
274
00:18:01 --> 00:18:07
disappeared from the curriculum.
Call it, if you haven't up
275
00:18:06 --> 00:18:12
until now, what mathematicians
call it, convex is that,
276
00:18:10 --> 00:18:16
and the other one is concave.
Well, how do Euler's solutions
277
00:18:13 --> 00:18:19
look?
Well, I'll just sketch.
278
00:18:15 --> 00:18:21
I think from this you can see
already, when you start out on
279
00:18:19 --> 00:18:25
the Euler's solution,
it's going to go like that.
280
00:18:22 --> 00:18:28
Now you are too low.
Well, let's suppose after that,
281
00:18:25 --> 00:18:31
the line element here is
approximately the same as what
282
00:18:28 --> 00:18:34
it is there, or roughly
parallel.
283
00:18:32 --> 00:18:38
After all, they are not too far
apart.
284
00:18:34 --> 00:18:40
And, the direction field is
continuous.
285
00:18:37 --> 00:18:43
That is, the directions don't
change drastically from one
286
00:18:40 --> 00:18:46
point to another.
But now, you see it's still too
287
00:18:43 --> 00:18:49
low.
It's even lower as it
288
00:18:45 --> 00:18:51
pathetically tries to follow.
It's losing territory,
289
00:18:49 --> 00:18:55
and that's basically because
the curve is convex.
290
00:18:52 --> 00:18:58
Exactly the opposite what would
happen if the curve were
291
00:18:55 --> 00:19:01
concave, if the solution curve
were concave.
292
00:19:00 --> 00:19:06
Now it's too high,
and it's not going to be able
293
00:19:04 --> 00:19:10
to correct that as long as the
solution curve stays concave.
294
00:19:09 --> 00:19:15
Well, that's probably too
optimistic.
295
00:19:13 --> 00:19:19
It's probably more like this.
So, in other words,
296
00:19:17 --> 00:19:23
in this case,
if the curve is convex,
297
00:19:21 --> 00:19:27
Euler is going to be too high,
sorry, too low.
298
00:19:25 --> 00:19:31
Let's put E for Euler.
How about that?
299
00:19:30 --> 00:19:36
Euler is too low.
If it's concave,
300
00:19:32 --> 00:19:38
then Euler is too high.
Okay, that's great.
301
00:19:36 --> 00:19:42
There's just one little problem
left, namely,
302
00:19:40 --> 00:19:46
if we don't have a formula for
the solution,
303
00:19:44 --> 00:19:50
and we don't have a computer
that's busy drawing the picture
304
00:19:49 --> 00:19:55
for us, in which case we
wouldn't need any of this
305
00:19:54 --> 00:20:00
anyway, how are we supposed to
tell if it's convex or concave?
306
00:20:01 --> 00:20:07
Back to calculus.
Calculus to the rescue!
307
00:20:04 --> 00:20:10
When is a curve convex?
A curve is convex if its second
308
00:20:08 --> 00:20:14
derivative is positive because
the first to be convex means the
309
00:20:12 --> 00:20:18
first derivative is increasing
all the time.
310
00:20:16 --> 00:20:22
And therefore,
the second derivative,
311
00:20:18 --> 00:20:24
which is the derivative of the
first derivative,
312
00:20:22 --> 00:20:28
should be positive.
Just the opposite here;
313
00:20:25 --> 00:20:31
the curve, the slope is,
the first derivative,
314
00:20:29 --> 00:20:35
is decreasing all the time and
therefore the second derivative
315
00:20:33 --> 00:20:39
is negative.
So, all we have to do is decide
316
00:20:38 --> 00:20:44
what the second derivative of
the solution is.
317
00:20:41 --> 00:20:47
We should probably call it a
solution.
318
00:20:43 --> 00:20:49
y of x is a little too
vague.
319
00:20:46 --> 00:20:52
y1 means the solution started
at this point.
320
00:20:49 --> 00:20:55
So, in fact,
probably it would have been
321
00:20:52 --> 00:20:58
better from the beginning to
call that y1,
322
00:20:54 --> 00:21:00
except there's no room,
y1, let's say.
323
00:20:57 --> 00:21:03
That means the solution which
started out at the point,
324
00:21:01 --> 00:21:07
(0, 1).
So, I'm still talking about at
325
00:21:04 --> 00:21:10
a solution like that.
All right, so I want to know if
326
00:21:08 --> 00:21:14
this is positive,
the second derivative is
327
00:21:10 --> 00:21:16
positive at the starting point,
zero, or it's negative.
328
00:21:14 --> 00:21:20
Now, again, how you can
regulate the second derivative,
329
00:21:17 --> 00:21:23
if you don't know what the
solution is explicitly,
330
00:21:20 --> 00:21:26
then the answer is you can do
it from the differential
331
00:21:24 --> 00:21:30
equation itself.
How do I do that?
332
00:21:26 --> 00:21:32
Well: easy.
y prime equals x squared minus
333
00:21:29 --> 00:21:35
y squared.
Okay, that tells me how to
334
00:21:34 --> 00:21:40
calculate y prime if I
know the value of x and y,
335
00:21:39 --> 00:21:45
in other words,
the 0.01.
336
00:21:41 --> 00:21:47
What would be the value of y
double prime?
337
00:21:45 --> 00:21:51
Well, differentiate the
equation.
338
00:21:48 --> 00:21:54
It's two x minus two y y prime.
339
00:21:52 --> 00:21:58
Don't forget to use the chain
rule.
340
00:21:55 --> 00:22:01
So, if I want to calculate at
(0, 1), in other words,
341
00:22:00 --> 00:22:06
if my starting point is that
curve convex or concave,
342
00:22:04 --> 00:22:10
well, let's calculate.
y of zero equals one.
343
00:22:10 --> 00:22:16
Okay, what's y prime of zero?
344
00:22:12 --> 00:22:18
Well, I don't have to repeat
345
00:22:15 --> 00:22:21
that calculation.
Using this, I've already
346
00:22:18 --> 00:22:24
calculated that it was negative
one.
347
00:22:20 --> 00:22:26
And now, the new thing,
what's y double prime of zero?
348
00:22:24 --> 00:22:30
Well, it is this.
349
00:22:26 --> 00:22:32
I'll write it out.
It's two times zero minus two
350
00:22:29 --> 00:22:35
times negative y,
which is one,
351
00:22:31 --> 00:22:37
two times one times y prime,
which is negative one.
352
00:22:36 --> 00:22:42
You want to see we are pulling
353
00:22:41 --> 00:22:47
ourselves up by our own boot
straps, which is impossible.
354
00:22:45 --> 00:22:51
But, it is not impossible
because we are doing it.
355
00:22:49 --> 00:22:55
So, what's the answer?
Zero here, two,
356
00:22:52 --> 00:22:58
I've calculated without having
the foggiest idea of what the
357
00:22:57 --> 00:23:03
solution is or how it looks.
I've calculated that its second
358
00:23:03 --> 00:23:09
derivative at the starting point
is two.
359
00:23:07 --> 00:23:13
Therefore, my solution is
convex at the starting point.
360
00:23:13 --> 00:23:19
And therefore,
this Euler approximation,
361
00:23:17 --> 00:23:23
if I don't carry it out too
far, will be too low.
362
00:23:22 --> 00:23:28
So, it's convex Euler,
too low.
363
00:23:25 --> 00:23:31
Now, you could argue,
yeah, well, what about this?
364
00:23:32 --> 00:23:38
[LAUGHTER] So,
you could go like this,
365
00:23:36 --> 00:23:42
and then you can see it catches
up.
366
00:23:39 --> 00:23:45
Well, of course,
if the curve changes from
367
00:23:44 --> 00:23:50
convex to concave,
then it's really impossible to
368
00:23:49 --> 00:23:55
make any prediction at all.
That's a difficulty.
369
00:23:54 --> 00:24:00
So, all this analysis is only
if you stay very nearby.
370
00:24:02 --> 00:24:08
However, I wanted to show you,
the main purpose of it in my
371
00:24:06 --> 00:24:12
mind was to show you how do you
use, it's these equations,
372
00:24:11 --> 00:24:17
how to use the differential
equation itself to get
373
00:24:14 --> 00:24:20
information about the solutions,
without actually being able to
374
00:24:19 --> 00:24:25
calculate the solutions?
Now, so that's the method,
375
00:24:23 --> 00:24:29
and that's how to find out
something about it.
376
00:24:27 --> 00:24:33
And now, what I'd like to talk
about is errors.
377
00:24:32 --> 00:24:38
How do I handle,
right?
378
00:24:34 --> 00:24:40
So, in a sense,
I've started the error
379
00:24:38 --> 00:24:44
analysis.
In other words,
380
00:24:40 --> 00:24:46
the error, by definition, the
error is this difference, e.
381
00:24:46 --> 00:24:52
So, in other words,
382
00:24:48 --> 00:24:54
what I'm asking here,
is the error positive?
383
00:24:52 --> 00:24:58
It depends which we measure it.
Usually, you take this minus
384
00:24:59 --> 00:25:05
that.
So, here, the error would be
385
00:25:03 --> 00:25:09
considered positive,
and here it would be considered
386
00:25:07 --> 00:25:13
negative, although I'm sure
there's a book somewhere in the
387
00:25:13 --> 00:25:19
world, which does the opposite.
Most hedge by just using the
388
00:25:18 --> 00:25:24
absolute value of the error plus
a statement that the method is
389
00:25:23 --> 00:25:29
producing answers which are too
low or too high.
390
00:25:27 --> 00:25:33
The question,
then, is, naturally,
391
00:25:30 --> 00:25:36
this is not the world's best
method.
392
00:25:35 --> 00:25:41
It's not as bad as it seems.
It's not the world's best
393
00:25:38 --> 00:25:44
method because that convexity
and concavity means that you are
394
00:25:42 --> 00:25:48
automatically introducing a
systematic error.
395
00:25:45 --> 00:25:51
If you can predict which way
the error is going to be by just
396
00:25:49 --> 00:25:55
knowing whether the curve is
convex or concave,
397
00:25:51 --> 00:25:57
it's not what you want.
I mean, you want to at least
398
00:25:55 --> 00:26:01
have a chance of getting the
right answer,
399
00:25:57 --> 00:26:03
whereas this is telling you
you're definitely going to get
400
00:26:01 --> 00:26:07
the wrong answer.
All it tells you is,
401
00:26:03 --> 00:26:09
and it's telling you whether
your answer is going to be too
402
00:26:07 --> 00:26:13
high or too low.
We've like a better chance of
403
00:26:12 --> 00:26:18
getting the right answer.
Now, so the question is,
404
00:26:17 --> 00:26:23
how do you get a better method?
A search is for a better
405
00:26:23 --> 00:26:29
method.
Now, the first method,
406
00:26:26 --> 00:26:32
which will occur,
I'm sure, to anyone who looks
407
00:26:30 --> 00:26:36
at that picture,
is, look, if you want this
408
00:26:35 --> 00:26:41
yellow line to follow the white
one, the white solution,
409
00:26:40 --> 00:26:46
more accurately,
for heaven's sake,
410
00:26:43 --> 00:26:49
don't take such big steps.
Take small steps,
411
00:26:50 --> 00:26:56
and then it will follow better.
All right, let's draw a
412
00:26:59 --> 00:27:05
picture.
Excuse me.
413
00:27:02 --> 00:27:08
My little box of treasures,
here.
414
00:27:08 --> 00:27:14
[LAUGHTER]
So, use a smaller step size.
415
00:27:13 --> 00:27:19
And the picture,
roughly, which is going to
416
00:27:17 --> 00:27:23
justify that,
will look like this.
417
00:27:21 --> 00:27:27
If the solution curve looks
like this, then with a big step
418
00:27:26 --> 00:27:32
size, I'm liable to have
something that looks like that.
419
00:27:33 --> 00:27:39
But, if I take a smaller step
size, suppose I have the step
420
00:27:38 --> 00:27:44
size.
How's it going to look,
421
00:27:40 --> 00:27:46
then?
Well, I better switch to a
422
00:27:43 --> 00:27:49
different color.
If I have the step size,
423
00:27:47 --> 00:27:53
I'll get a littler,
goes like that.
424
00:27:50 --> 00:27:56
And now it's following closer.
Of course, I'm stacking the
425
00:27:55 --> 00:28:01
deck, but see how close it
follows?
426
00:28:00 --> 00:28:06
I'm definitely not to be
trusted on this.
427
00:28:02 --> 00:28:08
Okay, let's do the opposite,
make really big steps.
428
00:28:05 --> 00:28:11
Suppose instead of the yellow
ones I used the green one of
429
00:28:08 --> 00:28:14
double step size.
Well, what would have happened
430
00:28:11 --> 00:28:17
then?
Well, I've started out,
431
00:28:13 --> 00:28:19
but now I've gone all the way
to there.
432
00:28:15 --> 00:28:21
And now, on my way up,
of course, it has a little
433
00:28:18 --> 00:28:24
further to go.
But, if for some reason,
434
00:28:21 --> 00:28:27
I stop there,
you could see,
435
00:28:22 --> 00:28:28
I would be still lower.
In other words,
436
00:28:24 --> 00:28:30
the bigger the steps size,
the more the error.
437
00:28:29 --> 00:28:35
And, where are the errors that
we are talking about?
438
00:28:33 --> 00:28:39
Well, the way to think of the
errors, this is the error,
439
00:28:38 --> 00:28:44
that number the error.
You can make it positive,
440
00:28:42 --> 00:28:48
negative, or just put it
automatically an absolute value
441
00:28:47 --> 00:28:53
sign around it.
That's not so important.
442
00:28:51 --> 00:28:57
So, in other words,
the conclusion is,
443
00:28:54 --> 00:29:00
that the error e,
the difference between the true
444
00:28:59 --> 00:29:05
value that I should have gotten,
and the Euler value that the
445
00:29:04 --> 00:29:10
calculation produced,
that the error e,
446
00:29:08 --> 00:29:14
depends on the step size.
Now, how does it depend on the
447
00:29:14 --> 00:29:20
step size?
Well, it's impossible to give
448
00:29:17 --> 00:29:23
an exact formula,
but there's an approximate
449
00:29:20 --> 00:29:26
answer, which is,
by and large,
450
00:29:22 --> 00:29:28
true.
So, the answer is,
451
00:29:24 --> 00:29:30
e is going to be a function of
h.
452
00:29:27 --> 00:29:33
What function?
Well, asymptotically,
453
00:29:30 --> 00:29:36
which is another way of putting
quotation marks around,
454
00:29:34 --> 00:29:40
what did I say?
It's going to be a constant,
455
00:29:37 --> 00:29:43
some constant,
times H.
456
00:29:40 --> 00:29:46
[LAUGHTER]
It looks like this,
457
00:30:12 --> 00:30:18
and for this reason it's called
a first order,
458
00:30:17 --> 00:30:23
the Euler is a first-order
method.
459
00:30:21 --> 00:30:27
And now, first-order does not
refer to the first order of the
460
00:30:28 --> 00:30:34
differential equation.
It's not the first order
461
00:30:34 --> 00:30:40
because it's y prime equals f of
(x, y).
462
00:30:38 --> 00:30:44
The first order means the fact
463
00:30:41 --> 00:30:47
that h occurs to the first
power.
464
00:30:44 --> 00:30:50
The way people usually say this
is since the normal way of
465
00:30:49 --> 00:30:55
decreasing the step size,
as you'll see as is you try to
466
00:30:53 --> 00:30:59
use a computer visual that deals
with the Euler method,
467
00:30:58 --> 00:31:04
which I highly recommend,
by the way, so highly
468
00:31:02 --> 00:31:08
recommended that you have to do
it, is that the way to say it,
469
00:31:07 --> 00:31:13
each new step has the step
size.
470
00:31:12 --> 00:31:18
That's the usual way to do it.
If you have the step size,
471
00:31:20 --> 00:31:26
since this is a constant,
if I have the step size,
472
00:31:27 --> 00:31:33
I have the error,
approximately.
473
00:31:33 --> 00:31:39
Have the step size,
have the error.
474
00:31:36 --> 00:31:42
That tells you how the error
varies with step size for
475
00:31:42 --> 00:31:48
Euler's method.
Please understand,
476
00:31:46 --> 00:31:52
that's what people say,
and please understand the
477
00:31:51 --> 00:31:57
grammatical construction.
Since everyone in the math
478
00:31:56 --> 00:32:02
department has a cold these days
except me for the moment,
479
00:32:03 --> 00:32:09
everyone goes around chanting
this mantra.
480
00:32:09 --> 00:32:15
This is totally irrelevant.
This whole mantra,
481
00:32:13 --> 00:32:19
feed a cold,
starve a fever.
482
00:32:15 --> 00:32:21
And if you asked them what it
means, they say eat a lot if you
483
00:32:21 --> 00:32:27
have a cold.
And if you have a fever,
484
00:32:24 --> 00:32:30
don't eat very much,
which is not what it means at
485
00:32:28 --> 00:32:34
all.
Grammatically,
486
00:32:30 --> 00:32:36
it's exactly the same
construction as this.
487
00:32:33 --> 00:32:39
What this means is if you have
the step size,
488
00:32:37 --> 00:32:43
you will have the error.
That's what feed a cold,
489
00:32:40 --> 00:32:46
starve a fever means.
And, remember this for the rest
490
00:32:44 --> 00:32:50
of your life.
If you feed a cold,
491
00:32:46 --> 00:32:52
if you eat too much when you
have a cold, you will get a
492
00:32:50 --> 00:32:56
fever and end up still having to
starve yourself because,
493
00:32:54 --> 00:33:00
of course, nobody,
when you have a fever,
494
00:32:57 --> 00:33:03
nobody feels like eating,
so they don't eat anything.
495
00:33:02 --> 00:33:08
All right, you got that?
Good.
496
00:33:06 --> 00:33:12
I want all of you to go home
and tell that to your mothers.
497
00:33:14 --> 00:33:20
You know, that's the way we
always used to speak.
498
00:33:21 --> 00:33:27
Grimmer ones:
spare the rod,
499
00:33:25 --> 00:33:31
spoil the child does not mean
that you should not hit your
500
00:33:33 --> 00:33:39
kid.
It means that if you fail to
501
00:33:39 --> 00:33:45
hit your kid,
he or she will be spoiled,
502
00:33:44 --> 00:33:50
whatever that means.
So, you don't want to do that.
503
00:33:50 --> 00:33:56
I guess the mantra today would
be, I don't know.
504
00:33:56 --> 00:34:02
Okay, so the first line of
defense is simply to keep having
505
00:34:03 --> 00:34:09
the step size in Euler.
And, what people do is,
506
00:34:08 --> 00:34:14
if they don't want to use
anything better than Euler's
507
00:34:11 --> 00:34:17
method, is you keep having the
step size until the curve
508
00:34:15 --> 00:34:21
doesn't seem to change anymore.
And then you say,
509
00:34:18 --> 00:34:24
well, that must be the
solution.
510
00:34:20 --> 00:34:26
And, I asked you on the
problems set,
511
00:34:22 --> 00:34:28
how much would you continue to
have to have the step size in
512
00:34:26 --> 00:34:32
order for that good thing to
happen?
513
00:34:30 --> 00:34:36
However, there are more
efficient methods which get the
514
00:34:35 --> 00:34:41
results faster.
So if that's our good method,
515
00:34:39 --> 00:34:45
let's call this our still
better method.
516
00:34:43 --> 00:34:49
The better methods aim at being
better.
517
00:34:47 --> 00:34:53
They keep the same idea as
Euler's method,
518
00:34:51 --> 00:34:57
but they say,
look, let's try to improve that
519
00:34:55 --> 00:35:01
slope, An.
In other words,
520
00:34:59 --> 00:35:05
since the slope,
An, that we start with is
521
00:35:01 --> 00:35:07
guaranteed to be wrong if the
curve is convex or concave,
522
00:35:05 --> 00:35:11
can we somehow correct it?
So, for example,
523
00:35:08 --> 00:35:14
instead of immediately aiming
there, can't we somehow aim it
524
00:35:12 --> 00:35:18
so that by luck,
we just, at the next step just
525
00:35:15 --> 00:35:21
lands us back on the curve
again?
526
00:35:17 --> 00:35:23
In other words,
with sort of looking for the
527
00:35:20 --> 00:35:26
short path, a shortcut path,
which by good luck will end us
528
00:35:24 --> 00:35:30
up back on the curve again.
And, all the simple
529
00:35:27 --> 00:35:33
improvements on the Euler
method, and they are the most
530
00:35:31 --> 00:35:37
stable in ways to solve
differential equations
531
00:35:34 --> 00:35:40
numerically, aim at finding a
better slope.
532
00:35:39 --> 00:35:45
So, they find a better value
for a better slope,
533
00:35:43 --> 00:35:49
find a better value than An.
Try to improve that slope that
534
00:35:48 --> 00:35:54
you found.
Now, once you have the idea
535
00:35:52 --> 00:35:58
that you should look for a
better slope,
536
00:35:55 --> 00:36:01
it's not very difficult to see
what, in fact,
537
00:35:59 --> 00:36:05
you should try.
Again, I think most of you
538
00:36:03 --> 00:36:09
would say, hey,
I would have thought of that.
539
00:36:07 --> 00:36:13
And, you would be closer in
time, since these methods were
540
00:36:11 --> 00:36:17
only found about around the turn
of the last century is when I
541
00:36:15 --> 00:36:21
place them, mostly by some
German mathematicians interested
542
00:36:20 --> 00:36:26
in solving equations
numerically.
543
00:36:22 --> 00:36:28
All right, so what is the
better method?
544
00:36:25 --> 00:36:31
Our better slope,
what should we look for in our
545
00:36:28 --> 00:36:34
better slope?
Well, the simplest procedure
546
00:36:33 --> 00:36:39
is, once again,
we are starting from there,
547
00:36:36 --> 00:36:42
and the Euler slope would be
the same as a line element.
548
00:36:41 --> 00:36:47
So, the line element looks like
this.
549
00:36:44 --> 00:36:50
And, our yellow slope,
A, and I'll still continue to
550
00:36:48 --> 00:36:54
call it An, goes like that,
gets to here.
551
00:36:51 --> 00:36:57
Okay, now if it were convex,
if the curve were convex,
552
00:36:55 --> 00:37:01
this would be too low.
And therefore,
553
00:36:58 --> 00:37:04
the next step would be,
I'm going to draw this next
554
00:37:02 --> 00:37:08
step in pink.
Well, let's continue in here,
555
00:37:07 --> 00:37:13
would be going up like that.
I'll call this Bn,
556
00:37:10 --> 00:37:16
just because it's the next step
of Euler's method.
557
00:37:14 --> 00:37:20
It could be called An prime
or something like that.
558
00:37:19 --> 00:37:25
But this will do.
And now what you do is,
559
00:37:22 --> 00:37:28
let me put an arrow on it to
indicate parallelness,
560
00:37:26 --> 00:37:32
go back to the beginning,
draw this parallel to Bn.
561
00:37:31 --> 00:37:37
So, here is Bn.
Again, just a line of that same
562
00:37:35 --> 00:37:41
slope.
And now, what you should use as
563
00:37:38 --> 00:37:44
the simplest improvement on
Euler's method,
564
00:37:42 --> 00:37:48
is take the average of these
two because that's more likely
565
00:37:48 --> 00:37:54
to hit the curve than An will,
which is sure to be too low if
566
00:37:54 --> 00:38:00
the curve is convex.
In other words,
567
00:37:57 --> 00:38:03
use this instead.
Use that.
568
00:37:59 --> 00:38:05
So, this is our better slope.
Okay, what will we call that
569
00:38:06 --> 00:38:12
slope?
We don't have to call it
570
00:38:08 --> 00:38:14
anything.
What were the equations for the
571
00:38:11 --> 00:38:17
method be?
Well, x n plus one
572
00:38:14 --> 00:38:20
is gotten by adding the step
size.
573
00:38:17 --> 00:38:23
So, here's my step size just as
it was before.
574
00:38:20 --> 00:38:26
Just as it was before,
the new thing is how to get the
575
00:38:25 --> 00:38:31
new value of y.
So, y n plus one
576
00:38:28 --> 00:38:34
should be the old yn,
plus h times not this crummy
577
00:38:32 --> 00:38:38
slope, An, but the better,
the pink slope.
578
00:38:37 --> 00:38:43
What's the formula for the pink
slope?
579
00:38:39 --> 00:38:45
Well, let's do it in two steps.
It's the average of An and Bn.
580
00:38:44 --> 00:38:50
Hey, but you didn't tell me,
or I didn't tell you what Bn
581
00:38:48 --> 00:38:54
was.
So, you now must tell the
582
00:38:50 --> 00:38:56
computer, oh yes,
by the way, you remember that
583
00:38:54 --> 00:39:00
An was what it always was.
The interesting thing is,
584
00:38:58 --> 00:39:04
what is Bn?
Well, to get Bn,
585
00:39:01 --> 00:39:07
Bn is the slope of the line
element at this new point.
586
00:39:05 --> 00:39:11
Now, what am I going to call
that new point?
587
00:39:08 --> 00:39:14
I don't want to call this y
value, y n plus one,
588
00:39:12 --> 00:39:18
because that's,
it's this up here that's going
589
00:39:16 --> 00:39:22
to be the y n plus one.
All this is,
590
00:39:18 --> 00:39:24
is a temporary value used to
make another calculation,
591
00:39:22 --> 00:39:28
which will then be combined
with the previous calculations
592
00:39:27 --> 00:39:33
to get the right value.
Therefore, give it a temporary
593
00:39:31 --> 00:39:37
name.
That point, we'll call it,
594
00:39:34 --> 00:39:40
it's not going to be the final,
the real y n plus one.
595
00:39:38 --> 00:39:44
We'll call it y n plus one
596
00:39:40 --> 00:39:46
twiddle, y n plus one temporary.
And, what's the formula for it?
597
00:39:44 --> 00:39:50
Well, it's just going to be
what the original Euler formula;
598
00:39:48 --> 00:39:54
it's going to be y n plus what
you would have gotten if you had
599
00:39:52 --> 00:39:58
calculated, in other words,
it's the point that the Euler
600
00:39:56 --> 00:40:02
method produced,
but it's not,
601
00:39:57 --> 00:40:03
finally, the point that we
want.
602
00:40:01 --> 00:40:07
Now, do I have to say anything
else?
603
00:40:04 --> 00:40:10
Yeah, I didn't tell the
computer what Bn was.
604
00:40:08 --> 00:40:14
Okay, Bn is the slope of the
direction field at the point n
605
00:40:14 --> 00:40:20
plus one.
And the computer knows what
606
00:40:19 --> 00:40:25
that is.
And, this point,
607
00:40:21 --> 00:40:27
y n plus one temporary.
608
00:40:24 --> 00:40:30
So, you make a temporary choice
of this, calculate that number,
609
00:40:31 --> 00:40:37
and then go back,
and as it were,
610
00:40:34 --> 00:40:40
correct that value to this
value by using this better
611
00:40:39 --> 00:40:45
slope.
Now, that's all there is to the
612
00:40:44 --> 00:40:50
method, except I didn't give you
its name.
613
00:40:48 --> 00:40:54
Well, it has three names,
four names in fact.
614
00:40:52 --> 00:40:58
Which one shall I give you?
I don't care.
615
00:40:56 --> 00:41:02
Okay, the shortest name is
Heun's method.
616
00:41:00 --> 00:41:06
But nobody pronounces that
correctly.
617
00:41:05 --> 00:41:11
So, it's Heun's method.
It's called,
618
00:41:09 --> 00:41:15
also, the Improved Euler
method.
619
00:41:13 --> 00:41:19
It's called Modified Euler,
very expressive word,
620
00:41:19 --> 00:41:25
Modified Euler's method.
And, it's also called RK2.
621
00:41:25 --> 00:41:31
I'm sure you'll like that name
best.
622
00:41:31 --> 00:41:37
It has a Star Wars sort of
sound.
623
00:41:33 --> 00:41:39
RK stands for Runge-Kutta,
and the reason for the two is
624
00:41:38 --> 00:41:44
not that it uses,
well, it is that it uses two
625
00:41:42 --> 00:41:48
slopes, but the real reason for
the two is that it is a
626
00:41:46 --> 00:41:52
second-order method.
So, that's the most important
627
00:41:50 --> 00:41:56
thing to put down about it.
It's a second-order method,
628
00:41:55 --> 00:42:01
whereas Euler's was only a
first-order method.
629
00:42:00 --> 00:42:06
So, Heun's method,
or RK2, let's write it,
630
00:42:03 --> 00:42:09
is the shortest thing to write,
is a second-order method,
631
00:42:08 --> 00:42:14
meaning that the error varies
with the step size like some
632
00:42:13 --> 00:42:19
constant, it will not be the
same as the constant for Euler's
633
00:42:19 --> 00:42:25
method, times h squared.
634
00:42:22 --> 00:42:28
That's a big saving because it
now means that if you have the
635
00:42:28 --> 00:42:34
step size, you're going to
decrease the error by a factor
636
00:42:33 --> 00:42:39
of one quarter.
You will quarter the error.
637
00:42:38 --> 00:42:44
Now, you say,
hey, why should anyone use
638
00:42:40 --> 00:42:46
anything else?
Well, think a little second.
639
00:42:44 --> 00:42:50
The real thing which determines
how slowly one of these methods
640
00:42:48 --> 00:42:54
run is you look at the hardest
step of the method and ask how
641
00:42:53 --> 00:42:59
long does the computer take,
how many of those hardest steps
642
00:42:57 --> 00:43:03
are there?
Now, the answer is,
643
00:42:59 --> 00:43:05
the hardest step is always the
evaluation of the function
644
00:43:04 --> 00:43:10
because the functions that are
common use are not x squared
645
00:43:08 --> 00:43:14
minus y squared.
They take half a page and have,
646
00:43:14 --> 00:43:20
as coefficients,
you know, ten decimal place
647
00:43:17 --> 00:43:23
numbers, whatever the engineers
doing it, whatever their
648
00:43:22 --> 00:43:28
accuracy was.
So, the thing that controls how
649
00:43:25 --> 00:43:31
long a method runs is how many
times the slope,
650
00:43:29 --> 00:43:35
the function,
must be evaluated.
651
00:43:33 --> 00:43:39
For Euler, I only have to
evaluate it once.
652
00:43:37 --> 00:43:43
Here, I have to evaluate it
twice.
653
00:43:40 --> 00:43:46
Now, roughly speaking,
the number of function
654
00:43:44 --> 00:43:50
evaluations will each give you
the exponent.
655
00:43:48 --> 00:43:54
The method that's called
Runge-Kutta fourth order will
656
00:43:53 --> 00:43:59
require four evaluations of
slope, but the accuracy will be
657
00:43:59 --> 00:44:05
like h to the fourth:
very accurate.
658
00:44:05 --> 00:44:11
You have the step size,
and it goes down by a factor of
659
00:44:10 --> 00:44:16
16.
Great.
660
00:44:10 --> 00:44:16
But you had to evaluate the
slope four times.
661
00:44:14 --> 00:44:20
Suppose, instead,
you have four times this thing.
662
00:44:19 --> 00:44:25
And, what would you have done?
You would have decreased it to
663
00:44:24 --> 00:44:30
1/16th to what it was.
You still would increase the
664
00:44:29 --> 00:44:35
number of function evaluations
you needed by four,
665
00:44:34 --> 00:44:40
and you would have decreased
the error by a 16th.
666
00:44:40 --> 00:44:46
So, in some sense,
it really doesn't matter
667
00:44:43 --> 00:44:49
whether you use a very fancy
method, which requires more
668
00:44:47 --> 00:44:53
function evaluations.
That's true.
669
00:44:50 --> 00:44:56
The error goes down faster,
but you are having to more work
670
00:44:54 --> 00:45:00
to get it.
So, anyway, nothing is free.
671
00:44:57 --> 00:45:03
Now, there is an RK4.
I think I'll skip that,
672
00:45:01 --> 00:45:07
since I wouldn't dare to ask
you any questions about it.
673
00:45:06 --> 00:45:12
But, let me just mention it,
at least, because it's the
674
00:45:10 --> 00:45:16
standard.
It uses four evaluations.
675
00:45:13 --> 00:45:19
It's the standard method,
if you don't want to do
676
00:45:17 --> 00:45:23
anything fancier.
It's rather inefficient,
677
00:45:20 --> 00:45:26
but it's very accurate,
standard method,
678
00:45:23 --> 00:45:29
accurate, and you'll see when
you use the programs,
679
00:45:27 --> 00:45:33
it's, in fact,
a program which is drawing
680
00:45:30 --> 00:45:36
those curves,
the numerical method which
681
00:45:33 --> 00:45:39
draws all those curves that you
believe in on the computer
682
00:45:38 --> 00:45:44
screen is the RK4 method.
The Runge-Kutta,
683
00:45:43 --> 00:45:49
I should give them their names.
Runge-Kutta,
684
00:45:47 --> 00:45:53
fourth-order method.
Two mathematicians,
685
00:45:51 --> 00:45:57
I believe both German
mathematicians around the turn
686
00:45:55 --> 00:46:01
of the last century,
Runge-Kutta fourth-order method
687
00:46:00 --> 00:46:06
requires four slopes,
requires you to calculate four
688
00:46:05 --> 00:46:11
slopes.
I won't bother telling you what
689
00:46:09 --> 00:46:15
you do, but it's a procedure
like that.
690
00:46:11 --> 00:46:17
It's just a little bit more
elaborate.
691
00:46:14 --> 00:46:20
And you take two of these,
you make up a weighted average
692
00:46:17 --> 00:46:23
for the super slope.
You use weighted average.
693
00:46:20 --> 00:46:26
What should I divide that by to
get the right...?
694
00:46:23 --> 00:46:29
Six.
695
00:46:24 --> 00:46:30
Why six?
Well, because if all these
696
00:46:26 --> 00:46:32
numbers were the same,
I'd want it to come out to be
697
00:46:29 --> 00:46:35
whatever that common value was.
Therefore, in a weighted
698
00:46:35 --> 00:46:41
average, you must always divide
by the sum of the coefficients.
699
00:46:40 --> 00:46:46
So, this is the super-slope.
And, if you plug that
700
00:46:44 --> 00:46:50
super-slope into here,
you will be using the
701
00:46:47 --> 00:46:53
Runge-Kutta method,
and get the best possible
702
00:46:51 --> 00:46:57
results.
Now, I wanted to spend the last
703
00:46:54 --> 00:47:00
three minutes talking about
pitfalls of numerical
704
00:46:58 --> 00:47:04
computation in general.
One pitfall I am leaving you on
705
00:47:04 --> 00:47:10
the homework to discover for
yourself.
706
00:47:08 --> 00:47:14
Don't worry,
it won't cause you any grief.
707
00:47:12 --> 00:47:18
It'll just destroy your faith
in these things for the rest of
708
00:47:18 --> 00:47:24
your life, which is probably a
good thing.
709
00:47:22 --> 00:47:28
So, pitfalls,
number one, you find,
710
00:47:25 --> 00:47:31
you'll find.
Let me talk,
711
00:47:27 --> 00:47:33
instead, briefly about number
two, which I am not giving you
712
00:47:33 --> 00:47:39
an exercise in.
Number two is illustrated by
713
00:47:37 --> 00:47:43
the following equation.
What could be simpler?
714
00:47:40 --> 00:47:46
This is a very bad equation to
try to solve numerically.
715
00:47:44 --> 00:47:50
Now, why?
Well, because if I separate
716
00:47:47 --> 00:47:53
variables, why don't I save a
little time?
717
00:47:49 --> 00:47:55
I'll just tell you what the
solution is, okay?
718
00:47:53 --> 00:47:59
You obviously separate
variables.
719
00:47:55 --> 00:48:01
Maybe you can do it in your
head.
720
00:47:57 --> 00:48:03
The solution will be,
the solutions will have an
721
00:48:00 --> 00:48:06
arbitrary constant in them,
and they won't be very
722
00:48:03 --> 00:48:09
complicated. They will be
one over c minus x.
723
00:48:08 --> 00:48:14
C is an arbitrary constant,
724
00:48:10 --> 00:48:16
and as you give different
values, you get,
725
00:48:13 --> 00:48:19
now, what do those guys look
like?
726
00:48:15 --> 00:48:21
Okay, so here I am.
I start out at the point,
727
00:48:18 --> 00:48:24
one.
And, I start out,
728
00:48:19 --> 00:48:25
I tell the computer,
compute for me the value of the
729
00:48:23 --> 00:48:29
solution at one starting out at
one.
730
00:48:25 --> 00:48:31
And, it computes and computes a
little while.
731
00:48:28 --> 00:48:34
But the solution,
how does this curve actually
732
00:48:31 --> 00:48:37
look?
So, in other words,
733
00:48:34 --> 00:48:40
suppose I say that y of zero
equals one.
734
00:48:38 --> 00:48:44
Find me y of two.
In other words,
735
00:48:41 --> 00:48:47
take a nice small step size.
Use the Runge-Kutta
736
00:48:44 --> 00:48:50
fourth-order method.
Calculate a little bit,
737
00:48:48 --> 00:48:54
and tell me,
I just want to know what y of
738
00:48:51 --> 00:48:57
two is.
Well, what is y of two?
739
00:48:53 --> 00:48:59
Well, unfortunately,
how does that curve look?
740
00:48:56 --> 00:49:02
The curve looks like this.
At that point,
741
00:49:01 --> 00:49:07
it drops to infinity in a
manner of speaking,
742
00:49:04 --> 00:49:10
and then sort of comes back up
again like that.
743
00:49:07 --> 00:49:13
What is the value of y?
This is the point,
744
00:49:11 --> 00:49:17
one.
What is the value of y of two?
745
00:49:13 --> 00:49:19
Is it here?
746
00:49:15 --> 00:49:21
Is it this?
Well, I don't know,
747
00:49:17 --> 00:49:23
but I do know that the computer
will not find it.
748
00:49:20 --> 00:49:26
The computer will follow this
along, and get lost in eternity,
749
00:49:25 --> 00:49:31
in infinity,
and see no reason whatever why
750
00:49:28 --> 00:49:34
it should start again on this
branch of the curve.
751
00:49:34 --> 00:49:40
Okay, well, can't we predict
that that's going to happen
752
00:49:38 --> 00:49:44
somehow, avoid what I should
have.
753
00:49:40 --> 00:49:46
The whole difficulty is,
this is called a singular
754
00:49:44 --> 00:49:50
point.
The solution has a singularity,
755
00:49:47 --> 00:49:53
in other words,
a single place where it goes to
756
00:49:51 --> 00:49:57
infinity or becomes
discontinuous,
757
00:49:53 --> 00:49:59
maybe as a jump discontinuity.
It has a singularity at x
758
00:49:57 --> 00:50:03
equals c.
This, in particular,
759
00:50:00 --> 00:50:06
at x equals one here,
but from the differential
760
00:50:04 --> 00:50:10
equation, where is that c?
There is no way of predicting
761
00:50:10 --> 00:50:16
it.
Each solution,
762
00:50:11 --> 00:50:17
in other words,
to this differential equation,
763
00:50:15 --> 00:50:21
has its own,
private singularity,
764
00:50:17 --> 00:50:23
which only it knows about,
and where it's going to blow
765
00:50:21 --> 00:50:27
up, and there's no way of
telling from the differential
766
00:50:25 --> 00:50:31
equation where that's going to
be.
767
00:50:28 --> 00:50:34
That's one of the things that
makes numerical calculation
768
00:50:32 --> 00:50:38
difficult, when you cannot
predict where things are going
769
00:50:37 --> 00:50:43
to go bad in advance.