WEBVTT

00:00:20.000 --> 00:00:33.665
The topic for today is --
Today we're going to talk,

00:00:33.665 --> 00:00:36.200
I'm postponing the linear
equations to next time.

00:00:36.200 --> 00:00:40.220
Instead, I think it's a good
idea, since in real life,

00:00:40.220 --> 00:00:42.375
most of the
differential equations

00:00:42.375 --> 00:00:46.315
are solved by numerical methods
to introduce you to those right

00:00:46.315 --> 00:00:46.815
away.

00:00:46.815 --> 00:00:49.444
Even when you see
the compute where

00:00:49.444 --> 00:00:53.333
you saw the computer screen,
the solutions being drawn.

00:00:53.333 --> 00:00:55.444
Of course, what
really was happening

00:00:55.444 --> 00:00:59.000
was that the computer was
calculating the solutions

00:00:59.000 --> 00:01:03.000
numerically, and
plotting the points.

00:01:03.000 --> 00:01:05.000
So, this is the main
way, numerically,

00:01:05.000 --> 00:01:09.000
it is the main way differential
equations are actually solved,

00:01:09.000 --> 00:01:12.000
if they are of any
complexity at all.

00:01:12.000 --> 00:01:15.000
So, the problem is, that
initial value problem,

00:01:15.000 --> 00:01:18.744
let's write up the first
order problem the way

00:01:18.744 --> 00:01:21.125
we talked about it on Wednesday.

00:01:21.125 --> 00:01:24.665
And now, I'll specifically add
to that, the starting point

00:01:24.665 --> 00:01:28.428
that you used when you did
the computer experiments.

00:01:28.428 --> 00:01:32.900
And, I'll write the
starting point this way.

00:01:32.900 --> 00:01:35.000
So, y of x0 should be y0.

00:01:35.000 --> 00:01:38.500
So, this is the
initial condition,

00:01:38.500 --> 00:01:42.400
and this is the first order
differential equation.

00:01:42.400 --> 00:01:45.776
And, as you know,
the two of them

00:01:45.776 --> 00:01:49.500
together are called an IVP,
an initial value problem,

00:01:49.500 --> 00:01:52.000
which means two things,
the differential

00:01:52.000 --> 00:01:55.500
equation and the
initial value that you

00:01:55.500 --> 00:01:59.180
want to start the solution at.

00:01:59.180 --> 00:02:05.000
Okay, now, the method we
are going to talk about,

00:02:05.000 --> 00:02:08.666
the basic method of
which many others

00:02:08.666 --> 00:02:14.000
are merely refinements
in one way or another,

00:02:14.000 --> 00:02:16.856
is called Euler's method.

00:02:16.856 --> 00:02:22.000
Euler, who did, of course,
everything in analysis,

00:02:22.000 --> 00:02:26.250
as far as I know,
didn't actually

00:02:26.250 --> 00:02:32.000
use it to compute solutions
of differential equations.

00:02:32.000 --> 00:02:36.000
His interest was theoretical.

00:02:36.000 --> 00:02:40.000
He used it as a method of
proving the existence theorem,

00:02:40.000 --> 00:02:42.664
proving that solutions existed.

00:02:42.664 --> 00:02:46.500
But, nowadays, it's used
to calculate the solutions

00:02:46.500 --> 00:02:47.000
numerically.

00:02:47.000 --> 00:02:51.000
And, the method is very
simple to describe.

00:02:51.000 --> 00:02:53.331
It's so naive that
you probably think

00:02:53.331 --> 00:02:56.500
that if you that
living 300 years ago,

00:02:56.500 --> 00:03:00.875
you would have discovered
it and covered yourself

00:03:00.875 --> 00:03:04.000
with glory for all eternity.

00:03:04.000 --> 00:03:07.000
So, here is our starting
point, (x0, y0).

00:03:07.000 --> 00:03:10.000
Now, what information
do we have?

00:03:10.000 --> 00:03:14.444
At that point all we have is
the little line element, whose

00:03:14.444 --> 00:03:18.000
slope is given by f of (x, y).

00:03:18.000 --> 00:03:22.248
So, if I start the
solution, the only way

00:03:22.248 --> 00:03:24.744
the solution could
possibly go would

00:03:24.744 --> 00:03:28.664
be to start off in
that direction, since I

00:03:28.664 --> 00:03:30.714
have no other information.

00:03:30.714 --> 00:03:36.000
At least it has the correct
direction at (x0, y0).

00:03:36.000 --> 00:03:40.750
But, of course, it's not likely
to have the correct direction

00:03:40.750 --> 00:03:41.500
anywhere else.

00:03:41.500 --> 00:03:45.304
Now, what you do, then,
is choose a step size.

00:03:45.304 --> 00:03:48.500
I'll try just two
steps of the method.

00:03:48.500 --> 00:03:50.856
That's, I think, good enough.

00:03:50.856 --> 00:03:55.000
Choose a uniform step size,
which is usually called h.

00:03:55.000 --> 00:03:57.768
And, you continue that
solution until you

00:03:57.768 --> 00:04:03.142
get to the next point, which
will be x0 + h, as I've

00:04:03.142 --> 00:04:06.000
drawn it on the picture.

00:04:06.000 --> 00:04:07.500
So, we get to here.

00:04:07.500 --> 00:04:09.900
We stop at that
point, and now you

00:04:09.900 --> 00:04:12.000
recalculate what the
line element is here.

00:04:12.000 --> 00:04:16.712
Suppose, here, the line
element, now, through this point

00:04:16.712 --> 00:04:18.000
goes like that.

00:04:18.000 --> 00:04:20.400
Well, then, that's
the new direction

00:04:20.400 --> 00:04:23.665
that you should start
out with going from here.

00:04:23.665 --> 00:04:28.178
And so, the next step of the
process will carry you to here.

00:04:28.178 --> 00:04:30.500
That's two steps
of Euler's method.

00:04:30.500 --> 00:04:36.000
Notice it produces a broken line
approximation to the solution.

00:04:36.000 --> 00:04:39.000
But, in fact, you only
see that broken line

00:04:39.000 --> 00:04:43.000
if you are at a computer if
you are looking at the computer

00:04:43.000 --> 00:04:47.000
visual, for example, whose
purpose is to illustrate

00:04:47.000 --> 00:04:48.712
for you Euler's method.

00:04:48.712 --> 00:04:51.500
In actual practice,
what you see is,

00:04:51.500 --> 00:04:53.500
the computer is
simply calculating

00:04:53.500 --> 00:04:57.570
this point, that point, and
the succession of points.

00:04:57.570 --> 00:04:59.555
And, many programs
will just automatically

00:04:59.555 --> 00:05:04.000
connect those points by
a smooth looking curve

00:05:04.000 --> 00:05:08.000
if that's what
you prefer to see.

00:05:08.000 --> 00:05:11.000
Well, that's all there
is to the method.

00:05:11.000 --> 00:05:15.375
What we have to do now is derive
the equations for the method.

00:05:15.375 --> 00:05:18.375
Now, how are we
going to do that?

00:05:18.375 --> 00:05:23.724
Well, the essence of it is
how to get from the nth step

00:05:23.724 --> 00:05:26.375
to the n plus first step?

00:05:26.375 --> 00:05:30.816
So, I'm going to draw a picture
just to illustrate that.

00:05:30.816 --> 00:05:34.000
So, now we are not at x0.

00:05:34.000 --> 00:05:37.375
But let's say we've
already gotten to (xn, yn).

00:05:37.375 --> 00:05:40.000
How do I take the next step?

00:05:40.000 --> 00:05:43.330
Well, I take the line
element, and it goes up

00:05:43.330 --> 00:05:47.000
like that, let's say,
because the slope is this.

00:05:47.000 --> 00:05:51.000
I'm going to call
that slope A sub n.

00:05:51.000 --> 00:05:55.329
Of course, A sub n is the
value of the right hand side

00:05:55.329 --> 00:05:59.400
at the point (xn, yn), and we
will need that in the equation,

00:05:59.400 --> 00:06:05.304
-- -- but I think it will be
a little bit clearer if I just

00:06:05.304 --> 00:06:08.285
give it a capital
letter at this point.

00:06:08.285 --> 00:06:12.178
Now, this is the new point,
and all I want to know

00:06:12.178 --> 00:06:14.000
is what are its coordinates?

00:06:14.000 --> 00:06:17.000
Well, the x n plus one is there.

00:06:17.000 --> 00:06:19.000
The y n plus one is here.

00:06:19.000 --> 00:06:21.664
Clearly I should
draw this triangle,

00:06:21.664 --> 00:06:23.000
complete the triangle.

00:06:23.000 --> 00:06:27.000
This side of the triangle,
the hypotenuse has slope An.

00:06:27.000 --> 00:06:30.000
This side of the
triangle has length h.

00:06:30.000 --> 00:06:31.665
h is the step size.

00:06:31.665 --> 00:06:33.500
Perhaps I'd better
indicate that,

00:06:33.500 --> 00:06:39.000
actually put that up so
that you know the word step.

00:06:39.000 --> 00:06:41.856
It's the step size
on the x axis,

00:06:41.856 --> 00:06:47.000
how far you have to go to get
from each x to the next one.

00:06:47.000 --> 00:06:48.000
What's this?

00:06:48.000 --> 00:06:53.000
Well, if that slope has this,
the slope An, this is h.

00:06:53.000 --> 00:06:58.000
Then this must be h times
An, the length of that side,

00:06:58.000 --> 00:07:02.224
in order that the ratio of
the height to this width

00:07:02.224 --> 00:07:03.571
should be An.

00:07:03.571 --> 00:07:07.000
And, that gives us the method.

00:07:07.000 --> 00:07:13.332
How do I get from, clearly, to
get from xn to x n plus one,

00:07:13.332 --> 00:07:16.000
I simply add h.

00:07:16.000 --> 00:07:19.000
So, that's the
trivial part of it.

00:07:19.000 --> 00:07:25.452
The interesting thing is, how
do I get the new y n plus one?

00:07:25.452 --> 00:07:30.331
And so, the best way to write
it as, that y n plus one

00:07:30.331 --> 00:07:32.800
minus yn divided
by h, well, sorry,

00:07:32.800 --> 00:07:40.662
y n plus one minus yn is this
line, the same as the line

00:07:40.662 --> 00:07:43.000
h times An.

00:07:43.000 --> 00:07:45.331
So, that's the way to write it.

00:07:45.331 --> 00:07:48.875
Or, since the computer is
interested in calculating

00:07:48.875 --> 00:07:54.178
y n plus one itself, put
this on the other side.

00:07:54.178 --> 00:07:57.089
You take the old yn,
the previous one,

00:07:57.089 --> 00:08:00.000
and to it, you add h times An.

00:08:00.000 --> 00:08:04.000
And, what, pray tell, is An?

00:08:04.000 --> 00:08:09.664
Well, the computer has to be
told that An is the value of f.

00:08:09.664 --> 00:08:11.888
So, now, with that,
let's actually

00:08:11.888 --> 00:08:15.000
write the Euler program,
not the program,

00:08:15.000 --> 00:08:19.000
but the Euler-- the
Euler method equations,

00:08:19.000 --> 00:08:22.000
let's just call it
the Euler equations.

00:08:22.000 --> 00:08:23.140
What will they be?

00:08:23.140 --> 00:08:28.000
First of all, the new
x is the old x plus h.

00:08:28.000 --> 00:08:31.000
The new y is just what
I've written there,

00:08:31.000 --> 00:08:38.000
the old y plus h times a
certain number, An, and finally,

00:08:38.000 --> 00:08:44.332
An has the value-- It's the
slope of the line element here,

00:08:44.332 --> 00:08:50.000
and therefore by definition,
that's f of (xn,yn).

00:08:50.000 --> 00:08:55.000
So, if these three equations
which define Euler's method.

00:08:55.000 --> 00:09:00.000
I assume in 1.00 you must
be asked to, at some point,

00:09:00.000 --> 00:09:04.576
as an exercise in the term
at one point to program

00:09:04.576 --> 00:09:09.500
the computer in C or whatever
they're using, Java, now,

00:09:09.500 --> 00:09:14.000
I guess, to do Euler's method.

00:09:14.000 --> 00:09:18.662
And, these would be
the recursive equations

00:09:18.662 --> 00:09:23.816
that you would
put in to do that.

00:09:23.816 --> 00:09:27.625
Okay, let's try
an example, then.

00:09:27.625 --> 00:09:33.200
So, what would be a
good color for Euler?

00:09:33.200 --> 00:09:35.000
Well, a purple.

00:09:35.000 --> 00:09:38.330
I assume nobody can see purple.

00:09:38.330 --> 00:09:40.000
Is that correct?

00:09:40.000 --> 00:09:46.000
Can anyone in the back of the
room see that that's purple?

00:09:46.000 --> 00:09:46.666
Okay.

00:09:46.666 --> 00:09:48.000
Sit closer.

00:09:48.000 --> 00:09:50.400
So, let's calculate.

00:09:50.400 --> 00:09:56.000
The example, I'll
use a simple example,

00:09:56.000 --> 00:10:00.000
but it's not entirely trivial.

00:10:00.000 --> 00:10:02.000
My example is going
to be the equation,

00:10:02.000 --> 00:10:07.000
x squared minus y squared
on the right hand side.

00:10:07.000 --> 00:10:10.750
And, let's start with y of
zero equals one, let's say.

00:10:10.750 --> 00:10:14.000
And so, this is my
initial value problem,

00:10:14.000 --> 00:10:16.000
that pair of equations.

00:10:16.000 --> 00:10:18.000
And, I have to
specify a step size.

00:10:18.000 --> 00:10:20.000
So, let's take the
step size to 0.1.

00:10:20.000 --> 00:10:24.000
You choose the step size,
or the computer does.

00:10:24.000 --> 00:10:27.000
We'll have to talk about
that in a few minutes.

00:10:27.000 --> 00:10:28.815
Now, what do you do?

00:10:28.815 --> 00:10:33.500
Well, I say this is a nontrivial
equation because this equation,

00:10:33.500 --> 00:10:38.500
as far as I know, cannot be
solved in terms of elementary

00:10:38.500 --> 00:10:39.000
functions.

00:10:39.000 --> 00:10:41.541
So, this equation
would be, in fact,

00:10:41.541 --> 00:10:46.000
a very good candidate for a
numerical method like Euler's.

00:10:46.000 --> 00:10:50.428
And, you had to use it, or maybe
it was the other way around,

00:10:50.428 --> 00:10:51.284
I forget.

00:10:51.284 --> 00:10:56.200
On your problem set, you drew a
picture of the direction field

00:10:56.200 --> 00:10:59.500
and answered some questions
about the isoclines,

00:10:59.500 --> 00:11:01.375
how the solutions behave.

00:11:01.375 --> 00:11:04.726
Now, the main thing
I want you to get,

00:11:04.726 --> 00:11:07.267
this is not just
for Euler's, talking

00:11:07.267 --> 00:11:08.500
about Euler's equations.

00:11:08.500 --> 00:11:10.900
But in general, for
the calculations

00:11:10.900 --> 00:11:14.200
you have to do in this course,
it's extremely important

00:11:14.200 --> 00:11:17.750
to be systematic because
if you are not systematic,

00:11:17.750 --> 00:11:21.500
you know, if you just scribble,
scribble, scribble, scribble,

00:11:21.500 --> 00:11:24.400
scribble, you can do
the work, but it becomes

00:11:24.400 --> 00:11:25.600
impossible to find mistakes.

00:11:25.600 --> 00:11:28.921
You must do the work
in a form in which it

00:11:28.921 --> 00:11:32.333
can be checked, which you
can look over it and find,

00:11:32.333 --> 00:11:37.220
and try to see where mistakes
are if, in fact, there are any.

00:11:37.220 --> 00:11:41.220
So, I strongly suggest,
this is not a suggestion,

00:11:41.220 --> 00:11:46.744
this is a command, that you make
a little table to do Euler's

00:11:46.744 --> 00:11:51.213
method by hand, I'd only
ask you for a step or two,

00:11:51.213 --> 00:11:53.832
but since I'm just
trying to make

00:11:53.832 --> 00:11:57.160
sure you have some
idea of these equations

00:11:57.160 --> 00:11:59.332
and where they come from.

00:11:59.332 --> 00:12:03.815
So, first, the value of
n, then the value of xn,

00:12:03.815 --> 00:12:06.768
then the value of
the yn, and then,

00:12:06.768 --> 00:12:09.840
a couple of more
columns which tell you

00:12:09.840 --> 00:12:11.888
how to do the calculation.

00:12:11.888 --> 00:12:15.999
You are going to need
the value of the slope,

00:12:15.999 --> 00:12:18.454
and it's probably
a good idea, also,

00:12:18.454 --> 00:12:23.000
because otherwise you'll
forget it, to put in h An

00:12:23.000 --> 00:12:26.000
because that occurs
in the formula.

00:12:26.000 --> 00:12:30.000
All right, let's start doing it.

00:12:30.000 --> 00:12:32.541
The first value of n is zero.

00:12:32.541 --> 00:12:34.000
That's the starting point.

00:12:34.000 --> 00:12:38.000
At the starting point, (x0,
y0), x has the value zero,

00:12:38.000 --> 00:12:42.000
and y has the value
one, so, zero and one.

00:12:42.000 --> 00:12:45.000
In other words, starting,
I'm carrying out

00:12:45.000 --> 00:12:47.800
exactly what I drew
pictorially only now

00:12:47.800 --> 00:12:51.664
I'm doing it arithmetically
using a table

00:12:51.664 --> 00:12:55.000
and substituting
into the formulas.

00:12:55.000 --> 00:13:00.000
Okay, the next thing we
have to calculate is An.

00:13:00.000 --> 00:13:03.000
Well, since An is the value
of the right hand side,

00:13:03.000 --> 00:13:07.000
at the point zero one,
you have to plug that in.

00:13:07.000 --> 00:13:11.000
The right hand side is x
squared minus y squared.

00:13:11.000 --> 00:13:14.000
So, it's 0 squared
minus 1 squared.

00:13:14.000 --> 00:13:20.000
The value of the slope, there,
is minus one, negative one.

00:13:20.000 --> 00:13:22.000
Now, I have to
multiply that by H.

00:13:22.000 --> 00:13:22.999
h is 0.1.

00:13:22.999 --> 00:13:25.452
So, it's negative,
I'll never learn that.

00:13:25.452 --> 00:13:28.333
The way you learn to
talk in kindergarten

00:13:28.333 --> 00:13:33.250
is the way you learn to
talk the rest of your life,

00:13:33.250 --> 00:13:34.500
unfortunately.

00:13:34.500 --> 00:13:38.800
In kindergarten, we said minus.

00:13:38.800 --> 00:13:40.000
Negative 0.1.

00:13:40.000 --> 00:13:42.220
n is one now.

00:13:42.220 --> 00:13:45.000
What's the value of xn?

00:13:45.000 --> 00:13:48.000
Well, to the old
value I add 1/10.

00:13:48.000 --> 00:13:50.775
What's the value of y?

00:13:50.775 --> 00:13:56.000
Well, at this point, you
have to do the calculation.

00:13:56.000 --> 00:13:59.000
It's the old value of y.

00:13:59.000 --> 00:14:06.000
To get this new value, it's
the old value plus this number.

00:14:06.000 --> 00:14:12.816
Well, that's this plus
that number is nine tenths.

00:14:12.816 --> 00:14:19.180
An, now I have to calculate
the new slope at this point.

00:14:19.180 --> 00:14:25.500
Okay, that is one tenth squared
minus nine tenths squared.

00:14:25.500 --> 00:14:38.000
That's 0.01 minus 0.81, which
makes minus 0.80, I hope.

00:14:38.000 --> 00:14:40.270
Check it on your calculators.

00:14:40.270 --> 00:14:43.428
Whip them out and
press the buttons.

00:14:43.428 --> 00:14:46.832
I now multiply that
by h, which means

00:14:46.832 --> 00:14:51.428
it's going to be minus 0.08,
perhaps with a zero after.

00:14:51.428 --> 00:14:55.000
I didn't tell you how
many decimal places.

00:14:55.000 --> 00:14:59.000
Let's carry it out to
two decimal places.

00:14:59.000 --> 00:15:03.000
I think that will
be good enough.

00:15:03.000 --> 00:15:10.000
And finally, the last step, 2,
here, add another one tenth,

00:15:10.000 --> 00:15:15.000
so the value of x
is now two tenths.

00:15:15.000 --> 00:15:18.000
And finally, what's
the value of y?

00:15:18.000 --> 00:15:22.000
Well, I didn't tell
you where to stop.

00:15:22.000 --> 00:15:27.328
Let's stop at y of
0.2 because there's

00:15:27.328 --> 00:15:31.000
no more room on the blackboard.

00:15:31.000 --> 00:15:34.500
About approximately
how big is that?

00:15:34.500 --> 00:15:37.816
In other words,
this is, then, this

00:15:37.816 --> 00:15:43.800
is going to be the old y
plus this number, which

00:15:43.800 --> 00:15:48.000
seems to be 0.82 to me.

00:15:48.000 --> 00:15:51.000
So, the answer is,
the new value is 0.82.

00:15:51.000 --> 00:15:52.665
Okay, we got a number.

00:15:52.665 --> 00:15:55.200
We did what we are
supposed to do.

00:15:55.200 --> 00:15:56.000
We got a number.

00:15:56.000 --> 00:15:57.000
Next question?

00:15:57.000 --> 00:16:00.000
Now, let's ask a few questions.

00:16:00.000 --> 00:16:02.625
One of the first,
most basic things

00:16:02.625 --> 00:16:04.998
is, you know, how right is this?

00:16:04.998 --> 00:16:09.800
How can I answer such a question
if I have no explicit formula

00:16:09.800 --> 00:16:11.000
for that solution?

00:16:11.000 --> 00:16:15.000
That's the basic problem
with numerical calculation.

00:16:15.000 --> 00:16:17.400
In other words, I
have to wander around

00:16:17.400 --> 00:16:19.800
in the dark to some
extent, and yet

00:16:19.800 --> 00:16:24.000
have some idea when I've arrived
at the place that I want to go.

00:16:24.000 --> 00:16:28.000
Well, the first question
I'd like to answer,

00:16:28.000 --> 00:16:30.800
is this too high or too low?

00:16:30.800 --> 00:16:36.000
Is Euler, sorry, he'll forgive
me in heaven, I will use him.

00:16:36.000 --> 00:16:38.500
By this, I mean,
is the result, let

00:16:38.500 --> 00:16:43.375
me just say something first,
and that I'll criticize it.

00:16:43.375 --> 00:16:46.000
Is Euler too high or too low?

00:16:46.000 --> 00:16:50.333
In other words, is the result
of using Euler's method,

00:16:50.333 --> 00:16:53.428
i.e. is this number
too high or too low?

00:16:53.428 --> 00:16:58.500
Is it higher than the right
answer, what it should be?

00:16:58.500 --> 00:17:02.750
Or, is it lower than
the right answer?

00:17:02.750 --> 00:17:06.776
Or, God forbid, is
it exactly right?

00:17:06.776 --> 00:17:09.600
Well, it's almost
never exactly right.

00:17:09.600 --> 00:17:12.000
That's not an option.

00:17:12.000 --> 00:17:16.000
Now, how will we
answer that question?

00:17:16.000 --> 00:17:19.000
Well, let's answer
it geometrically.

00:17:19.000 --> 00:17:24.454
Basically, if the solution
were a straight line, then

00:17:24.454 --> 00:17:29.000
the Euler method would be
exactly right all the time.

00:17:29.000 --> 00:17:31.775
But, it's not a line.

00:17:31.775 --> 00:17:34.000
Then it's a curve.

00:17:34.000 --> 00:17:38.000
Well, the critical
question is, is it curved?

00:17:38.000 --> 00:17:39.284
Is the solution?

00:17:39.284 --> 00:17:41.000
So, here's a solution.

00:17:41.000 --> 00:17:44.600
Let's call it y1
of x, and let's say

00:17:44.600 --> 00:17:46.776
here was the starting point.

00:17:46.776 --> 00:17:49.000
Here, the solution is convex.

00:17:49.000 --> 00:17:52.000
And, here the solution
is concave, right?

00:17:52.000 --> 00:17:57.000
Concave up or concave down,
if you learn those words,

00:17:57.000 --> 00:18:01.000
but I think those have,
by now, I hope pretty well

00:18:01.000 --> 00:18:03.000
disappeared from the curriculum.

00:18:03.000 --> 00:18:06.888
Call it, if you
haven't up until now,

00:18:06.888 --> 00:18:10.000
what mathematicians
call it, convex is that,

00:18:10.000 --> 00:18:11.632
and the other one is concave.

00:18:11.632 --> 00:18:13.400
Well, how do Euler's
solutions look?

00:18:13.400 --> 00:18:15.000
Well, I'll just sketch.

00:18:15.000 --> 00:18:18.684
I think from this you can see
already, when you start out

00:18:18.684 --> 00:18:22.000
on the Euler's solution,
it's going to go like that.

00:18:22.000 --> 00:18:23.500
Now you are too low.

00:18:23.500 --> 00:18:25.900
Well, let's suppose after
that, the line element

00:18:25.900 --> 00:18:29.998
here is approximately the
same as what it is there,

00:18:29.998 --> 00:18:32.000
or roughly parallel.

00:18:32.000 --> 00:18:34.000
After all, they are
not too far apart.

00:18:34.000 --> 00:18:37.000
And, the direction
field is continuous.

00:18:37.000 --> 00:18:39.331
That is, the directions
don't change drastically

00:18:39.331 --> 00:18:40.900
from one point to another.

00:18:40.900 --> 00:18:43.333
But now, you see
it's still too low.

00:18:43.333 --> 00:18:47.284
It's even lower as it
pathetically tries to follow.

00:18:47.284 --> 00:18:50.125
It's losing territory,
and that's basically

00:18:50.125 --> 00:18:52.000
because the curve is convex.

00:18:52.000 --> 00:18:53.800
Exactly the opposite
what would happen

00:18:53.800 --> 00:18:59.284
if the curve were concave,
if the solution curve were

00:18:59.284 --> 00:19:00.000
concave.

00:19:00.000 --> 00:19:02.904
Now it's too high,
and it's not going

00:19:02.904 --> 00:19:07.632
to be able to correct that
as long as the solution

00:19:07.632 --> 00:19:09.000
curve stays concave.

00:19:09.000 --> 00:19:13.000
Well, that's probably
too optimistic.

00:19:13.000 --> 00:19:15.220
It's probably more like this.

00:19:15.220 --> 00:19:21.000
So, in other words, in this
case, if the curve is convex,

00:19:21.000 --> 00:19:25.000
Euler is going to be too
high, sorry, too low.

00:19:25.000 --> 00:19:28.125
Let's put E for Euler.

00:19:28.125 --> 00:19:30.000
How about that?

00:19:30.000 --> 00:19:31.140
Euler is too low.

00:19:31.140 --> 00:19:34.500
If it's concave, then
Euler is too high.

00:19:34.500 --> 00:19:36.000
Okay, that's great.

00:19:36.000 --> 00:19:40.000
There's just one little
problem left, namely,

00:19:40.000 --> 00:19:44.000
if we don't have a
formula for the solution,

00:19:44.000 --> 00:19:47.178
and we don't have
a computer that's

00:19:47.178 --> 00:19:51.270
busy drawing the picture
for us, in which case

00:19:51.270 --> 00:19:54.583
we wouldn't need
any of this anyway,

00:19:54.583 --> 00:20:01.000
how are we supposed to tell
if it's convex or concave?

00:20:01.000 --> 00:20:02.284
Back to calculus.

00:20:02.284 --> 00:20:04.000
Calculus to the rescue!

00:20:04.000 --> 00:20:05.665
When is a curve convex?

00:20:05.665 --> 00:20:09.089
A curve is convex if its
second derivative is positive

00:20:09.089 --> 00:20:13.713
because the first to be convex
means the first derivative is

00:20:13.713 --> 00:20:16.000
increasing all the time.

00:20:16.000 --> 00:20:18.000
And therefore, the
second derivative,

00:20:18.000 --> 00:20:22.000
which is the derivative
of the first derivative,

00:20:22.000 --> 00:20:23.284
should be positive.

00:20:23.284 --> 00:20:26.000
Just the opposite
here; the curve,

00:20:26.000 --> 00:20:29.000
the slope is, the
first derivative,

00:20:29.000 --> 00:20:33.000
is decreasing all the time and
therefore the second derivative

00:20:33.000 --> 00:20:34.000
is negative.

00:20:34.000 --> 00:20:39.500
So, all we have to do is decide
what the second derivative

00:20:39.500 --> 00:20:41.000
of the solution is.

00:20:41.000 --> 00:20:43.000
We should probably
call it a solution.

00:20:43.000 --> 00:20:46.000
y of x is a little too vague.

00:20:46.000 --> 00:20:49.000
y1 means the solution
started at this point.

00:20:49.000 --> 00:20:51.625
So, in fact, probably
it would have

00:20:51.625 --> 00:20:54.856
been better from the beginning
to call that y1, except there's

00:20:54.856 --> 00:20:57.000
no room, y1, let's say.

00:20:57.000 --> 00:20:59.800
That means the solution
which started out

00:20:59.800 --> 00:21:01.750
at the point, (0, 1).

00:21:01.750 --> 00:21:05.332
So, I'm still talking about
at a solution like that.

00:21:05.332 --> 00:21:08.855
All right, so I want to
know if this is positive,

00:21:08.855 --> 00:21:12.220
the second derivative is
positive at the starting point,

00:21:12.220 --> 00:21:14.000
zero, or it's negative.

00:21:14.000 --> 00:21:17.000
Now, again, how you can
regulate the second derivative,

00:21:17.000 --> 00:21:20.000
if you don't know what the
solution is explicitly,

00:21:20.000 --> 00:21:24.070
then the answer is you can do it
from the differential equation

00:21:24.070 --> 00:21:24.570
itself.

00:21:24.570 --> 00:21:26.000
How do I do that?

00:21:26.000 --> 00:21:30.250
Well: easy. y prime equals
x squared minus y squared.

00:21:30.250 --> 00:21:34.416
Okay, that tells
me how to calculate

00:21:34.416 --> 00:21:39.000
y prime if I know
the value of x and y,

00:21:39.000 --> 00:21:41.000
in other words, the 0.01.

00:21:41.000 --> 00:21:45.000
What would be the value
of y double prime?

00:21:45.000 --> 00:21:48.000
Well, differentiate
the equation.

00:21:48.000 --> 00:21:52.000
It's two x minus two y y prime.

00:21:52.000 --> 00:21:55.000
Don't forget to
use the chain rule.

00:21:55.000 --> 00:22:00.000
So, if I want to calculate
at (0, 1), in other words,

00:22:00.000 --> 00:22:04.000
if my starting point is that
curve convex or concave,

00:22:04.000 --> 00:22:10.000
well, let's calculate.
y of zero equals one.

00:22:10.000 --> 00:22:12.000
Okay, what's y prime of zero?

00:22:12.000 --> 00:22:16.000
Well, I don't have to
repeat that calculation.

00:22:16.000 --> 00:22:18.333
Using this, I've
already calculated

00:22:18.333 --> 00:22:20.000
that it was negative one.

00:22:20.000 --> 00:22:24.000
And now, the new thing,
what's y double prime of zero?

00:22:24.000 --> 00:22:26.000
Well, it is this.

00:22:26.000 --> 00:22:27.200
I'll write it out.

00:22:27.200 --> 00:22:31.000
It's two times zero minus two
times negative y, which is one,

00:22:31.000 --> 00:22:36.000
two times one times y prime,
which is negative one.

00:22:36.000 --> 00:22:43.400
You want to see we are pulling
ourselves up by our own boot

00:22:43.400 --> 00:22:45.000
straps, which is impossible.

00:22:45.000 --> 00:22:49.000
But, it is not impossible
because we are doing it.

00:22:49.000 --> 00:22:50.712
So, what's the answer?

00:22:50.712 --> 00:22:54.000
Zero here, two, I've
calculated without having

00:22:54.000 --> 00:23:00.270
the foggiest idea of what the
solution is or how it looks.

00:23:00.270 --> 00:23:03.571
I've calculated that
its second derivative

00:23:03.571 --> 00:23:07.000
at the starting point is two.

00:23:07.000 --> 00:23:13.000
Therefore, my solution is
convex at the starting point.

00:23:13.000 --> 00:23:17.000
And therefore, this
Euler approximation,

00:23:17.000 --> 00:23:22.000
if I don't carry it out
too far, will be too low.

00:23:22.000 --> 00:23:25.000
So, it's convex Euler, too low.

00:23:25.000 --> 00:23:32.000
Now, you could argue, yeah,
well, what about this?

00:23:32.000 --> 00:23:36.000
[LAUGHTER] So, you
could go like this,

00:23:36.000 --> 00:23:39.000
and then you can
see it catches up.

00:23:39.000 --> 00:23:45.875
Well, of course, if the curve
changes from convex to concave,

00:23:45.875 --> 00:23:52.125
then it's really impossible
to make any prediction at all.

00:23:52.125 --> 00:23:54.000
That's a difficulty.

00:23:54.000 --> 00:24:02.000
So, all this analysis is
only if you stay very nearby.

00:24:02.000 --> 00:24:04.763
However, I wanted to show
you, the main purpose

00:24:04.763 --> 00:24:08.496
of it in my mind
was to show you how

00:24:08.496 --> 00:24:11.000
do you use, it's
these equations,

00:24:11.000 --> 00:24:14.000
how to use the differential
equation itself to get

00:24:14.000 --> 00:24:17.885
information about the solutions,
without actually being

00:24:17.885 --> 00:24:20.500
able to calculate the solutions?

00:24:20.500 --> 00:24:23.888
Now, so that's the
method, and that's

00:24:23.888 --> 00:24:27.000
how to find out
something about it.

00:24:27.000 --> 00:24:32.000
And now, what I'd like
to talk about is errors.

00:24:32.000 --> 00:24:34.000
How do I handle, right?

00:24:34.000 --> 00:24:38.500
So, in a sense, I've
started the error analysis.

00:24:38.500 --> 00:24:43.600
In other words, the error,
by definition, the error

00:24:43.600 --> 00:24:46.000
is this difference, e.

00:24:46.000 --> 00:24:50.000
So, in other words,
what I'm asking here,

00:24:50.000 --> 00:24:52.000
is the error positive?

00:24:52.000 --> 00:24:55.816
It depends which we measure it.

00:24:55.816 --> 00:24:59.571
Usually, you take
this minus that.

00:24:59.571 --> 00:25:04.000
So, here, the error would
be considered positive,

00:25:04.000 --> 00:25:07.600
and here it would be
considered negative,

00:25:07.600 --> 00:25:13.908
although I'm sure there's a book
somewhere in the world, which

00:25:13.908 --> 00:25:15.270
does the opposite.

00:25:15.270 --> 00:25:20.080
Most hedge by just using the
absolute value of the error

00:25:20.080 --> 00:25:23.888
plus a statement that the
method is producing answers

00:25:23.888 --> 00:25:27.000
which are too low or too high.

00:25:27.000 --> 00:25:30.714
The question, then,
is, naturally, this

00:25:30.714 --> 00:25:35.000
is not the world's best method.

00:25:35.000 --> 00:25:36.750
It's not as bad as it seems.

00:25:36.750 --> 00:25:39.600
It's not the world's best
method because that convexity

00:25:39.600 --> 00:25:42.600
and concavity means that
you are automatically

00:25:42.600 --> 00:25:45.000
introducing a systematic error.

00:25:45.000 --> 00:25:47.565
If you can predict
which way the error is

00:25:47.565 --> 00:25:50.250
going to be by just knowing
whether the curve is

00:25:50.250 --> 00:25:52.665
convex or concave,
it's not what you want.

00:25:52.665 --> 00:25:55.250
I mean, you want
to at least have

00:25:55.250 --> 00:25:57.000
a chance of getting
the right answer,

00:25:57.000 --> 00:25:59.800
whereas this is telling
you you're definitely

00:25:59.800 --> 00:26:01.750
going to get the wrong answer.

00:26:01.750 --> 00:26:04.332
All it tells you is,
and it's telling you

00:26:04.332 --> 00:26:09.000
whether your answer is going
to be too high or too low.

00:26:09.000 --> 00:26:14.220
We've like a better chance
of getting the right answer.

00:26:14.220 --> 00:26:20.227
Now, so the question is, how
do you get a better method?

00:26:20.227 --> 00:26:23.600
A search is for a better method.

00:26:23.600 --> 00:26:26.888
Now, the first
method, which will

00:26:26.888 --> 00:26:31.665
occur, I'm sure, to anyone
who looks at that picture,

00:26:31.665 --> 00:26:36.000
is, look, if you
want this yellow line

00:26:36.000 --> 00:26:40.000
to follow the white
one, the white solution,

00:26:40.000 --> 00:26:43.000
more accurately,
for heaven's sake,

00:26:43.000 --> 00:26:47.375
don't take such big steps.

00:26:47.375 --> 00:26:54.908
Take small steps, and then
it will follow better.

00:26:54.908 --> 00:27:00.000
All right, let's draw a picture.

00:27:00.000 --> 00:27:02.000
Excuse me.

00:27:02.000 --> 00:27:08.000
My little box of
treasures, here.

00:27:08.000 --> 00:27:13.000
[LAUGHTER] So, use
a smaller step size.

00:27:13.000 --> 00:27:18.332
And the picture, roughly,
which is going to justify that,

00:27:18.332 --> 00:27:21.000
will look like this.

00:27:21.000 --> 00:27:24.328
If the solution curve
looks like this, then

00:27:24.328 --> 00:27:29.500
with a big step size,
I'm liable to have

00:27:29.500 --> 00:27:33.000
something that looks like that.

00:27:33.000 --> 00:27:36.072
But, if I take a
smaller step size,

00:27:36.072 --> 00:27:38.333
suppose I halve the step size.

00:27:38.333 --> 00:27:40.428
How's it going to look, then?

00:27:40.428 --> 00:27:44.000
Well, I better switch
to a different color.

00:27:44.000 --> 00:27:50.000
If I halve the step size, I'll
get a littler, goes like that.

00:27:50.000 --> 00:27:52.500
And now it's following closer.

00:27:52.500 --> 00:27:55.714
Of course, I'm
stacking the deck,

00:27:55.714 --> 00:28:00.000
but see how close it follows?

00:28:00.000 --> 00:28:02.000
I'm definitely not to
be trusted on this.

00:28:02.000 --> 00:28:05.000
Okay, let's do the opposite,
make really big steps.

00:28:05.000 --> 00:28:06.500
Suppose instead
of the yellow ones

00:28:06.500 --> 00:28:09.125
I used the green one
of double step size.

00:28:09.125 --> 00:28:11.400
Well, what would
have happened then?

00:28:11.400 --> 00:28:15.000
Well, I've started out, but now
I've gone all the way to there.

00:28:15.000 --> 00:28:17.000
And now, on my
way up, of course,

00:28:17.000 --> 00:28:19.125
it has a little further to go.

00:28:19.125 --> 00:28:22.000
But, if for some reason, I
stop there, you could see,

00:28:22.000 --> 00:28:23.250
I would be still lower.

00:28:23.250 --> 00:28:29.000
In other words, the bigger the
steps size, the more the error.

00:28:29.000 --> 00:28:33.000
And, where are the errors
that we are talking about?

00:28:33.000 --> 00:28:36.744
Well, the way to think
of the errors, this

00:28:36.744 --> 00:28:39.776
is the error, that
number the error.

00:28:39.776 --> 00:28:42.555
You can make it
positive, negative,

00:28:42.555 --> 00:28:48.713
or just put it automatically an
absolute value sign around it.

00:28:48.713 --> 00:28:51.000
That's not so important.

00:28:51.000 --> 00:28:53.568
So, in other words,
the conclusion

00:28:53.568 --> 00:28:57.330
is, that the error
e, the difference

00:28:57.330 --> 00:29:01.496
between the true value
that I should have gotten,

00:29:01.496 --> 00:29:05.332
and the Euler value that
the calculation produced,

00:29:05.332 --> 00:29:10.500
that the error e,
depends on the step size.

00:29:10.500 --> 00:29:14.856
Now, how does it depend
on the step size?

00:29:14.856 --> 00:29:18.284
Well, it's impossible to
give an exact formula,

00:29:18.284 --> 00:29:20.999
but there's an approximate
answer, which is,

00:29:20.999 --> 00:29:22.400
by and large, true.

00:29:22.400 --> 00:29:27.000
So, the answer is, e is
going to be a function of h.

00:29:27.000 --> 00:29:28.500
What function?

00:29:28.500 --> 00:29:31.776
Well, asymptotically,
which is another way

00:29:31.776 --> 00:29:35.200
of putting quotation marks
around, what did I say?

00:29:35.200 --> 00:29:40.000
It's going to be a constant,
some constant, times H.

00:29:40.000 --> 00:30:14.220
[LAUGHTER] It looks like
this, and for this reason

00:30:14.220 --> 00:30:21.000
it's called a first order, the
Euler is a first order method.

00:30:21.000 --> 00:30:26.918
And now, first order does
not refer to the first order

00:30:26.918 --> 00:30:29.714
of the differential equation.

00:30:29.714 --> 00:30:35.776
It's not the first order
because it's y prime

00:30:35.776 --> 00:30:38.000
equals f of (x, y).

00:30:38.000 --> 00:30:41.856
The first order
means the fact that h

00:30:41.856 --> 00:30:44.000
occurs to the first power.

00:30:44.000 --> 00:30:46.912
The way people
usually say this is

00:30:46.912 --> 00:30:50.332
since the normal way of
decreasing the step size,

00:30:50.332 --> 00:30:54.500
as you'll see as is you
try to use a computer

00:30:54.500 --> 00:30:58.000
visual that deals
with the Euler method,

00:30:58.000 --> 00:31:01.108
which I highly
recommend, by the way,

00:31:01.108 --> 00:31:04.499
so highly recommended
that you have to do it,

00:31:04.499 --> 00:31:12.000
is that the way to say it, each
new step halves the step size.

00:31:12.000 --> 00:31:16.305
That's the usual way to do it.

00:31:16.305 --> 00:31:23.180
If you halve the step size,
since this is a constant,

00:31:23.180 --> 00:31:33.000
if I halve the step size, I
halve the error, approximately.

00:31:33.000 --> 00:31:36.000
Halve the step size,
halve the error.

00:31:36.000 --> 00:31:40.905
That tells you how the
error varies with step

00:31:40.905 --> 00:31:44.000
size for Euler's method.

00:31:44.000 --> 00:31:47.875
Please understand,
that's what people

00:31:47.875 --> 00:31:52.428
say, and please understand
the grammatical construction.

00:31:52.428 --> 00:31:56.636
Since everyone in
the math department

00:31:56.636 --> 00:32:03.000
has a cold these days
except me for the moment,

00:32:03.000 --> 00:32:09.000
everyone goes around
chanting this mantra.

00:32:09.000 --> 00:32:11.284
This is totally irrelevant.

00:32:11.284 --> 00:32:15.000
This whole mantra, feed
a cold, starve a fever.

00:32:15.000 --> 00:32:18.200
And if you asked
them what it means,

00:32:18.200 --> 00:32:21.999
they say eat a lot
if you have a cold.

00:32:21.999 --> 00:32:25.815
And if you have a fever,
don't eat very much, which

00:32:25.815 --> 00:32:29.000
is not what it means at all.

00:32:29.000 --> 00:32:33.000
Grammatically, it's exactly
the same construction as this.

00:32:33.000 --> 00:32:37.000
What this means is if
you halve the step size,

00:32:37.000 --> 00:32:38.500
you will halve the error.

00:32:38.500 --> 00:32:41.600
That's what feed a cold,
starve a fever means.

00:32:41.600 --> 00:32:44.750
And, remember this for
the rest of your life.

00:32:44.750 --> 00:32:48.850
If you feed a cold, if you eat
too much when you have a cold,

00:32:48.850 --> 00:32:53.600
you will get a fever and end up
still having to starve yourself

00:32:53.600 --> 00:32:57.000
because, of course, nobody,
when you have a fever,

00:32:57.000 --> 00:33:02.000
nobody feels like eating,
so they don't eat anything.

00:33:02.000 --> 00:33:05.330
All right, you got that?

00:33:05.330 --> 00:33:06.000
Good.

00:33:06.000 --> 00:33:14.000
I want all of you to go home
and tell that to your mothers.

00:33:14.000 --> 00:33:21.000
You know, that's the way
we always used to speak.

00:33:21.000 --> 00:33:25.666
Grimmer ones: spare
the rod, spoil

00:33:25.666 --> 00:33:33.750
the child does not mean that
you should not hit your kid.

00:33:33.750 --> 00:33:40.665
It means that if you
fail to hit your kid,

00:33:40.665 --> 00:33:45.800
he or she will be spoiled,
whatever that means.

00:33:45.800 --> 00:33:50.000
So, you don't want to do that.

00:33:50.000 --> 00:33:56.000
I guess the mantra today
would be, I don't know.

00:33:56.000 --> 00:34:00.081
Okay, so the first
line of defense

00:34:00.081 --> 00:34:05.500
is simply to keep having
the step size in Euler.

00:34:05.500 --> 00:34:10.100
And, what people do is, if
they don't want to use anything

00:34:10.100 --> 00:34:13.904
better than Euler's method, is
you keep having the step size

00:34:13.904 --> 00:34:16.665
until the curve doesn't
seem to change anymore.

00:34:16.665 --> 00:34:20.000
And then you say, well,
that must be the solution.

00:34:20.000 --> 00:34:22.921
And, I asked you on the
problems set, how much would

00:34:22.921 --> 00:34:26.571
you continue to have to
halve the step size in order

00:34:26.571 --> 00:34:30.000
for that good thing to happen?

00:34:30.000 --> 00:34:33.330
However, there are
more efficient methods

00:34:33.330 --> 00:34:36.000
which get the results faster.

00:34:36.000 --> 00:34:39.571
So if that's our
good method, let's

00:34:39.571 --> 00:34:43.000
call this our still
better method.

00:34:43.000 --> 00:34:47.000
The better methods
aim at being better.

00:34:47.000 --> 00:34:51.000
They keep the same
idea as Euler's method,

00:34:51.000 --> 00:34:56.600
but they say, look, let's try
to improve that slope, An.

00:34:56.600 --> 00:35:00.776
In other words, since the
slope, An, that we start with

00:35:00.776 --> 00:35:05.000
is guaranteed to be wrong if
the curve is convex or concave,

00:35:05.000 --> 00:35:06.875
can we somehow correct it?

00:35:06.875 --> 00:35:10.000
So, for example, instead of
immediately aiming there,

00:35:10.000 --> 00:35:13.632
can't we somehow aim it
so that by luck, we just,

00:35:13.632 --> 00:35:17.000
at the next step just lands
us back on the curve again?

00:35:17.000 --> 00:35:20.666
In other words, with sort of
looking for the short path,

00:35:20.666 --> 00:35:22.997
a shortcut path,
which by good luck

00:35:22.997 --> 00:35:25.800
will end us up back
on the curve again.

00:35:25.800 --> 00:35:29.000
And, all the simple improvements
on the Euler method,

00:35:29.000 --> 00:35:32.284
and they are the
most stable in ways

00:35:32.284 --> 00:35:34.714
to solve differential
equations numerically,

00:35:34.714 --> 00:35:39.000
aim at finding a better slope.

00:35:39.000 --> 00:35:43.000
So, they find a better
value for a better slope,

00:35:43.000 --> 00:35:45.496
find a better value than An.

00:35:45.496 --> 00:35:49.000
Try to improve that
slope that you found.

00:35:49.000 --> 00:35:54.625
Now, once you have the idea that
you should look for a better

00:35:54.625 --> 00:35:59.000
slope, it's not very difficult
to see what, in fact,

00:35:59.000 --> 00:36:00.332
you should try.

00:36:00.332 --> 00:36:04.332
Again, I think most
of you would say, hey,

00:36:04.332 --> 00:36:07.000
I would have thought of that.

00:36:07.000 --> 00:36:09.541
And, you would be
closer in time,

00:36:09.541 --> 00:36:11.614
since these methods
were only found

00:36:11.614 --> 00:36:15.625
about around the turn of the
last century is when I place

00:36:15.625 --> 00:36:19.375
them, mostly by some
German mathematicians

00:36:19.375 --> 00:36:22.000
interested in solving
equations numerically.

00:36:22.000 --> 00:36:25.000
All right, so what
is the better method?

00:36:25.000 --> 00:36:29.666
Our better slope, what should
we look for in our better slope?

00:36:29.666 --> 00:36:34.500
Well, the simplest
procedure is, once again, we

00:36:34.500 --> 00:36:38.080
are starting from there,
and the Euler slope would

00:36:38.080 --> 00:36:41.000
be the same as a line element.

00:36:41.000 --> 00:36:44.000
So, the line element
looks like this.

00:36:44.000 --> 00:36:47.200
And, our yellow slope,
A, and I'll still

00:36:47.200 --> 00:36:51.000
continue to call it An, goes
like that, gets to here.

00:36:51.000 --> 00:36:55.000
Okay, now if it were convex,
if the curve were convex,

00:36:55.000 --> 00:36:57.140
this would be too low.

00:36:57.140 --> 00:36:59.815
And therefore, the
next step would be,

00:36:59.815 --> 00:37:03.875
I'm going to draw this
next step in pink.

00:37:03.875 --> 00:37:08.800
Well, let's continue in here,
would be going up like that.

00:37:08.800 --> 00:37:11.332
I'll call this Bn,
just because it's

00:37:11.332 --> 00:37:14.000
the next step of Euler's method.

00:37:14.000 --> 00:37:19.000
It could be called An prime
or something like that.

00:37:19.000 --> 00:37:20.200
But this will do.

00:37:20.200 --> 00:37:24.800
And now what you do is,
let me put an arrow on it

00:37:24.800 --> 00:37:28.500
to indicate parallelness,
go back to the beginning,

00:37:28.500 --> 00:37:31.000
draw this parallel to Bn.

00:37:31.000 --> 00:37:32.452
So, here is Bn.

00:37:32.452 --> 00:37:35.375
Again, just a line
of that same slope.

00:37:35.375 --> 00:37:39.998
And now, what you should use
as the simplest improvement

00:37:39.998 --> 00:37:45.815
on Euler's method, is take
the average of these two

00:37:45.815 --> 00:37:48.800
because that's
more likely to hit

00:37:48.800 --> 00:37:52.800
the curve than An will,
which is sure to be

00:37:52.800 --> 00:37:55.712
too low if the curve is convex.

00:37:55.712 --> 00:37:58.200
In other words,
use this instead.

00:37:58.200 --> 00:37:59.000
Use that.

00:37:59.000 --> 00:38:02.498
So, this is our better slope.

00:38:02.498 --> 00:38:06.285
Okay, what will we
call that slope?

00:38:06.285 --> 00:38:08.428
We don't have to
call it anything.

00:38:08.428 --> 00:38:11.856
What were the equations
for the method be?

00:38:11.856 --> 00:38:17.000
Well, x n plus one is gotten
by adding the step size.

00:38:17.000 --> 00:38:20.000
So, here's my step size
just as it was before.

00:38:20.000 --> 00:38:23.072
Just as it was
before, the new thing

00:38:23.072 --> 00:38:26.332
is how to get the
new value of y.

00:38:26.332 --> 00:38:31.267
So, y n plus one should be
the old yn, plus h times not

00:38:31.267 --> 00:38:37.000
this crummy slope, An, but
the better, the pink slope.

00:38:37.000 --> 00:38:39.000
What's the formula
for the pink slope?

00:38:39.000 --> 00:38:41.499
Well, let's do it in two steps.

00:38:41.499 --> 00:38:44.000
It's the average of An and Bn.

00:38:44.000 --> 00:38:48.285
Hey, but you didn't tell me, or
I didn't tell you what Bn was.

00:38:48.285 --> 00:38:52.664
So, you now must tell the
computer, oh yes, by the way,

00:38:52.664 --> 00:38:56.400
you remember that An
was what it always was.

00:38:56.400 --> 00:38:59.284
The interesting
thing is, what is Bn?

00:38:59.284 --> 00:39:03.331
Well, to get Bn, Bn is
the slope of the line

00:39:03.331 --> 00:39:05.000
element at this new point.

00:39:05.000 --> 00:39:08.000
Now, what am I going
to call that new point?

00:39:08.000 --> 00:39:12.000
I don't want to call this
y value, y n plus one,

00:39:12.000 --> 00:39:15.500
because that's, it's
this up here that's

00:39:15.500 --> 00:39:17.400
going to be the y n plus one.

00:39:17.400 --> 00:39:19.776
All this is, is
a temporary value

00:39:19.776 --> 00:39:23.665
used to make another
calculation, which will then

00:39:23.665 --> 00:39:27.000
be combined with the
previous calculations

00:39:27.000 --> 00:39:29.000
to get the right value.

00:39:29.000 --> 00:39:31.500
Therefore, give it
a temporary name.

00:39:31.500 --> 00:39:34.614
That point, we'll
call it, it's not

00:39:34.614 --> 00:39:38.000
going to be the final,
the real y n plus one.

00:39:38.000 --> 00:39:41.499
We'll call it y n plus
one twiddle, y n plus one

00:39:41.499 --> 00:39:41.998
temporary.

00:39:41.998 --> 00:39:44.000
And, what's the formula for it?

00:39:44.000 --> 00:39:47.630
Well, it's just going to
be what the original Euler

00:39:47.630 --> 00:39:51.192
formula; it's going to be y n
plus what you would have gotten

00:39:51.192 --> 00:39:53.600
if you had calculated,
in other words,

00:39:53.600 --> 00:39:56.400
it's the point that the
Euler method produced,

00:39:56.400 --> 00:40:01.000
but it's not, finally,
the point that we want.

00:40:01.000 --> 00:40:04.000
Now, do I have to
say anything else?

00:40:04.000 --> 00:40:08.000
Yeah, I didn't tell the
computer what Bn was.

00:40:08.000 --> 00:40:11.688
Okay, Bn is the slope
of the direction

00:40:11.688 --> 00:40:15.428
field at the point n plus one.

00:40:15.428 --> 00:40:19.800
And the computer
knows what that is.

00:40:19.800 --> 00:40:24.000
And, this point, y n
plus one temporary.

00:40:24.000 --> 00:40:31.000
So, you make a temporary choice
of this, calculate that number,

00:40:31.000 --> 00:40:34.000
and then go back,
and as it were,

00:40:34.000 --> 00:40:39.625
correct that value to this value
by using this better slope.

00:40:39.625 --> 00:40:44.500
Now, that's all there
is to the method,

00:40:44.500 --> 00:40:48.000
except I didn't
give you its name.

00:40:48.000 --> 00:40:52.000
Well, it has three names,
four names in fact.

00:40:52.000 --> 00:40:54.664
Which one shall I give you?

00:40:54.664 --> 00:40:56.000
I don't care.

00:40:56.000 --> 00:41:00.000
Okay, the shortest
name is Heun's method.

00:41:00.000 --> 00:41:05.000
But nobody pronounces
that correctly.

00:41:05.000 --> 00:41:07.664
So, it's Heun's method.

00:41:07.664 --> 00:41:13.000
It's called, also, the
Improved Euler method.

00:41:13.000 --> 00:41:19.000
It's called Modified Euler,
very expressive word,

00:41:19.000 --> 00:41:21.250
Modified Euler's method.

00:41:21.250 --> 00:41:25.000
And, it's also called RK2.

00:41:25.000 --> 00:41:31.000
I'm sure you'll
like that name best.

00:41:31.000 --> 00:41:33.000
It has a Star Wars
sort of sound.

00:41:33.000 --> 00:41:37.576
RK stands for Runge Kutta,
and the reason for the two

00:41:37.576 --> 00:41:42.307
is not that it uses, well, it
is that it uses two slopes,

00:41:42.307 --> 00:41:47.000
but the real reason for the two
is that it is a second order

00:41:47.000 --> 00:41:47.500
method.

00:41:47.500 --> 00:41:52.724
So, that's the most important
thing to put down about it.

00:41:52.724 --> 00:41:57.500
It's a second order method,
whereas Euler's was only

00:41:57.500 --> 00:42:00.000
a first order method.

00:42:00.000 --> 00:42:03.000
So, Heun's method, or
RK2, let's write it,

00:42:03.000 --> 00:42:08.000
is the shortest thing to write,
is a second order method,

00:42:08.000 --> 00:42:11.632
meaning that the error
varies with the step

00:42:11.632 --> 00:42:15.000
size like some
constant, it will not

00:42:15.000 --> 00:42:20.500
be the same as the constant
for Euler's method, times

00:42:20.500 --> 00:42:22.000
h squared.

00:42:22.000 --> 00:42:25.227
That's a big saving
because it now

00:42:25.227 --> 00:42:28.908
means that if you
halve the step size,

00:42:28.908 --> 00:42:34.250
you're going to decrease
the error by a factor of one

00:42:34.250 --> 00:42:34.875
quarter.

00:42:34.875 --> 00:42:38.000
You will quarter the error.

00:42:38.000 --> 00:42:41.142
Now, you say, hey, why should
anyone use anything else?

00:42:41.142 --> 00:42:44.000
Well, think a little second.

00:42:44.000 --> 00:42:48.000
The real thing which determines
how slowly one of these methods

00:42:48.000 --> 00:42:51.927
run is you look at the
hardest step of the method

00:42:51.927 --> 00:42:54.452
and ask how long
does the computer

00:42:54.452 --> 00:42:57.666
take, how many of those
hardest steps are there?

00:42:57.666 --> 00:43:01.500
Now, the answer is, the
hardest step is always

00:43:01.500 --> 00:43:05.452
the evaluation of the function
because the functions that

00:43:05.452 --> 00:43:09.800
are common use are not x
squared minus y squared.

00:43:09.800 --> 00:43:14.856
They take half a page and
have, as coefficients,

00:43:14.856 --> 00:43:18.250
you know, ten decimal
place numbers, whatever

00:43:18.250 --> 00:43:22.750
the engineers doing it,
whatever their accuracy was.

00:43:22.750 --> 00:43:26.600
So, the thing that controls
how long a method runs

00:43:26.600 --> 00:43:33.000
is how many times the slope,
the function, must be evaluated.

00:43:33.000 --> 00:43:37.000
For Euler, I only have
to evaluate it once.

00:43:37.000 --> 00:43:40.000
Here, I have to
evaluate it twice.

00:43:40.000 --> 00:43:44.571
Now, roughly speaking, the
number of function evaluations

00:43:44.571 --> 00:43:48.000
will each give you the exponent.

00:43:48.000 --> 00:43:52.440
The method that's called
Runge Kutta fourth order

00:43:52.440 --> 00:43:56.000
will require four
evaluations of slope,

00:43:56.000 --> 00:44:05.000
but the accuracy will be like
h to the fourth: very accurate.

00:44:05.000 --> 00:44:09.863
You halve the step size, and
it goes down by a factor of

00:44:09.863 --> 00:44:10.363
16.

00:44:10.363 --> 00:44:10.863
Great.

00:44:10.863 --> 00:44:14.000
But you had to evaluate
the slope four times.

00:44:14.000 --> 00:44:19.000
Suppose, instead, you halve
four times this thing.

00:44:19.000 --> 00:44:21.496
And, what would you have done?

00:44:21.496 --> 00:44:26.500
You would have decreased it
to 1/16th to what it was.

00:44:26.500 --> 00:44:31.500
You still would increase the
number of function evaluations

00:44:31.500 --> 00:44:38.200
you needed by four, and you
would have decreased the error

00:44:38.200 --> 00:44:40.000
by a 16th.

00:44:40.000 --> 00:44:42.625
So, in some sense,
it really doesn't

00:44:42.625 --> 00:44:46.600
matter whether you use a very
fancy method, which requires

00:44:46.600 --> 00:44:48.500
more function evaluations.

00:44:48.500 --> 00:44:50.000
That's true.

00:44:50.000 --> 00:44:52.664
The error goes down
faster, but you are

00:44:52.664 --> 00:44:55.125
having to more work to get it.

00:44:55.125 --> 00:44:57.000
So, anyway, nothing is free.

00:44:57.000 --> 00:44:59.000
Now, there is an RK4.

00:44:59.000 --> 00:45:02.362
I think I'll skip
that, since I wouldn't

00:45:02.362 --> 00:45:06.000
dare to ask you any
questions about it.

00:45:06.000 --> 00:45:08.904
But, let me just
mention it, at least,

00:45:08.904 --> 00:45:10.600
because it's the standard.

00:45:10.600 --> 00:45:13.000
It uses four evaluations.

00:45:13.000 --> 00:45:15.800
It's the standard
method, if you don't

00:45:15.800 --> 00:45:18.200
want to do anything fancier.

00:45:18.200 --> 00:45:21.000
It's rather
inefficient, but it's

00:45:21.000 --> 00:45:23.444
very accurate, standard
method, accurate,

00:45:23.444 --> 00:45:27.000
and you'll see when
you use the programs,

00:45:27.000 --> 00:45:31.000
it's, in fact, a program
which is drawing those curves,

00:45:31.000 --> 00:45:34.816
the numerical method which
draws all those curves

00:45:34.816 --> 00:45:38.625
that you believe in
on the computer screen

00:45:38.625 --> 00:45:41.125
is the RK4 method.

00:45:41.125 --> 00:45:46.000
The Runge Kutta, I should
give them their names.

00:45:46.000 --> 00:45:49.400
Runge Kutta, fourth
order method.

00:45:49.400 --> 00:45:53.500
Two mathematicians, I believe
both German mathematicians

00:45:53.500 --> 00:45:58.330
around the turn of the
last century, Runge Kutta

00:45:58.330 --> 00:46:01.875
fourth order method
requires four slopes,

00:46:01.875 --> 00:46:05.571
requires you to
calculate four slopes.

00:46:05.571 --> 00:46:09.500
I won't bother telling
you what you do,

00:46:09.500 --> 00:46:11.000
but it's a procedure like that.

00:46:11.000 --> 00:46:14.000
It's just a little
bit more elaborate.

00:46:14.000 --> 00:46:17.000
And you take two of these,
you make up a weighted average

00:46:17.000 --> 00:46:18.500
for the super slope.

00:46:18.500 --> 00:46:20.000
You use weighted average.

00:46:20.000 --> 00:46:23.000
What should I divide that
by to get the right...?

00:46:23.000 --> 00:46:24.000
Six.

00:46:24.000 --> 00:46:24.570
Why six?

00:46:24.570 --> 00:46:27.000
Well, because if all these
numbers were the same,

00:46:27.000 --> 00:46:32.330
I'd want it to come out to be
whatever that common value was.

00:46:32.330 --> 00:46:35.454
Therefore, in a
weighted average,

00:46:35.454 --> 00:46:40.000
you must always divide by
the sum of the coefficients.

00:46:40.000 --> 00:46:42.178
So, this is the super slope.

00:46:42.178 --> 00:46:45.332
And, if you plug that
super slope into here,

00:46:45.332 --> 00:46:48.500
you will be using the
Runge Kutta method,

00:46:48.500 --> 00:46:51.375
and get the best
possible results.

00:46:51.375 --> 00:46:54.571
Now, I wanted to
spend the last three

00:46:54.571 --> 00:46:58.600
minutes talking about pitfalls
of numerical computation

00:46:58.600 --> 00:46:59.800
in general.

00:46:59.800 --> 00:47:05.332
One pitfall I am leaving
you on the homework

00:47:05.332 --> 00:47:08.000
to discover for yourself.

00:47:08.000 --> 00:47:12.000
Don't worry, it won't
cause you any grief.

00:47:12.000 --> 00:47:16.000
It'll just destroy your
faith in these things

00:47:16.000 --> 00:47:22.000
for the rest of your life,
which is probably a good thing.

00:47:22.000 --> 00:47:25.800
So, pitfalls, number one,
you find, you'll find.

00:47:25.800 --> 00:47:29.725
Let me talk, instead,
briefly about number two,

00:47:29.725 --> 00:47:34.500
which I am not giving
you an exercise in.

00:47:34.500 --> 00:47:38.284
Number two is illustrated
by the following equation.

00:47:38.284 --> 00:47:40.000
What could be simpler?

00:47:40.000 --> 00:47:44.000
This is a very bad equation
to try to solve numerically.

00:47:44.000 --> 00:47:44.856
Now, why?

00:47:44.856 --> 00:47:47.250
Well, because if I
separate variables,

00:47:47.250 --> 00:47:49.000
why don't I save a little time?

00:47:49.000 --> 00:47:53.000
I'll just tell you what
the solution is, okay?

00:47:53.000 --> 00:47:55.000
You obviously
separate variables.

00:47:55.000 --> 00:47:57.000
Maybe you can do
it in your head.

00:47:57.000 --> 00:47:58.998
The solution will
be, the solutions

00:47:58.998 --> 00:48:01.332
will have an arbitrary
constant in them,

00:48:01.332 --> 00:48:03.555
and they won't be
very complicated.

00:48:03.555 --> 00:48:08.000
They will be one over c minus x.

00:48:08.000 --> 00:48:12.250
C is an arbitrary constant, and
as you give different values,

00:48:12.250 --> 00:48:15.000
you get, now, what do
those guys look like?

00:48:15.000 --> 00:48:16.360
Okay, so here I am.

00:48:16.360 --> 00:48:18.200
I start out at the point, one.

00:48:18.200 --> 00:48:20.452
And, I start out, I
tell the computer,

00:48:20.452 --> 00:48:23.855
compute for me the value
of the solution at one

00:48:23.855 --> 00:48:25.000
starting out at one.

00:48:25.000 --> 00:48:28.000
And, it computes and
computes a little while.

00:48:28.000 --> 00:48:31.600
But the solution, how does
this curve actually look?

00:48:31.600 --> 00:48:38.000
So, in other words, suppose I
say that y of zero equals one.

00:48:38.000 --> 00:48:39.875
Find me y of two.

00:48:39.875 --> 00:48:42.800
In other words, take a
nice small step size.

00:48:42.800 --> 00:48:45.713
Use the Runge Kutta
fourth order method.

00:48:45.713 --> 00:48:48.816
Calculate a little
bit, and tell me,

00:48:48.816 --> 00:48:51.500
I just want to know
what y of two is.

00:48:51.500 --> 00:48:53.000
Well, what is y of two?

00:48:53.000 --> 00:48:56.000
Well, unfortunately, how
does that curve look?

00:48:56.000 --> 00:48:59.125
The curve looks like this.

00:48:59.125 --> 00:49:02.332
At that point, it
drops to infinity

00:49:02.332 --> 00:49:05.800
in a manner of speaking,
and then sort of comes back

00:49:05.800 --> 00:49:07.000
up again like that.

00:49:07.000 --> 00:49:09.400
What is the value of y?

00:49:09.400 --> 00:49:11.222
This is the point, one.

00:49:11.222 --> 00:49:13.000
What is the value of y of two?

00:49:13.000 --> 00:49:15.000
Is it here?

00:49:15.000 --> 00:49:15.855
Is it this?

00:49:15.855 --> 00:49:19.448
Well, I don't know, but I do
know that the computer will not

00:49:19.448 --> 00:49:20.000
find it.

00:49:20.000 --> 00:49:22.724
The computer will
follow this along,

00:49:22.724 --> 00:49:25.750
and get lost in
eternity, in infinity,

00:49:25.750 --> 00:49:30.400
and see no reason whatever
why it should start again

00:49:30.400 --> 00:49:34.000
on this branch of the curve.

00:49:34.000 --> 00:49:36.800
Okay, well, can't we
predict that that's

00:49:36.800 --> 00:49:40.000
going to happen somehow,
avoid what I should have.

00:49:40.000 --> 00:49:44.500
The whole difficulty is, this
is called a singular point.

00:49:44.500 --> 00:49:49.400
The solution has a singularity,
in other words, a single place

00:49:49.400 --> 00:49:53.726
where it goes to infinity or
becomes discontinuous, maybe as

00:49:53.726 --> 00:49:54.815
a jump discontinuity.

00:49:54.815 --> 00:49:58.200
It has a singularity
at x equals c.

00:49:58.200 --> 00:50:02.220
This, in particular,
at x equals one here,

00:50:02.220 --> 00:50:06.725
but from the differential
equation, where is that c?

00:50:06.725 --> 00:50:10.333
There is no way
of predicting it.

00:50:10.333 --> 00:50:15.000
Each solution, in other words,
to this differential equation,

00:50:15.000 --> 00:50:17.000
has its own,
private singularity,

00:50:17.000 --> 00:50:21.400
which only it knows about, and
where it's going to blow up,

00:50:21.400 --> 00:50:25.500
and there's no way of telling
from the differential equation

00:50:25.500 --> 00:50:28.000
where that's going to be.

00:50:28.000 --> 00:50:32.000
That's one of the things that
makes numerical calculation

00:50:32.000 --> 00:50:37.000
difficult, when you cannot
predict where things are going

00:50:37.000 --> 00:50:39.450
to go bad in advance.