WEBVTT
00:00:03.904 --> 00:00:06.780
PROFESSOR: A Very important
property of a numerical method
00:00:06.780 --> 00:00:08.730
is its order.
00:00:08.730 --> 00:00:13.550
The accuracy of the method
is proportional to a power
00:00:13.550 --> 00:00:15.230
of the step size.
00:00:15.230 --> 00:00:19.160
And that power is
called the order.
00:00:19.160 --> 00:00:22.540
If h is the step size
and p is the order,
00:00:22.540 --> 00:00:27.300
then the error
made in one step is
00:00:27.300 --> 00:00:31.450
proportional to h
to the p plus 1.
00:00:31.450 --> 00:00:37.160
And the error made in
traversing an entire interval is
00:00:37.160 --> 00:00:41.680
proportional to H to the p.
00:00:41.680 --> 00:00:45.350
So this means, if you're
using a method of order p,
00:00:45.350 --> 00:00:48.390
and cut the step
size in half, you
00:00:48.390 --> 00:00:53.000
can expect the overall error
to be reduced by a factor of 2
00:00:53.000 --> 00:00:53.670
to the p.
00:00:57.750 --> 00:01:03.610
The order of a numerical method
is determined by analysis
00:01:03.610 --> 00:01:08.160
involving Taylor series during
the derivation of the method.
00:01:08.160 --> 00:01:13.820
But we can also do an experiment
to determine the order.
00:01:13.820 --> 00:01:15.870
That's what this program does.
00:01:15.870 --> 00:01:20.050
The input is the name
of an ODE solver.
00:01:20.050 --> 00:01:24.970
And then it's going to do
a numerical integration
00:01:24.970 --> 00:01:28.940
of an ordinary differential
equation, just involving t.
00:01:28.940 --> 00:01:32.760
So the result is the
value of an integral.
00:01:32.760 --> 00:01:38.700
The integral of 1 over 1
plus t squared, from 0 to 1.
00:01:38.700 --> 00:01:41.890
We know the exact answer is 1/2.
00:01:41.890 --> 00:01:47.470
So we integrate that
differential equation twice,
00:01:47.470 --> 00:01:51.350
once with a step size of
0.1, and then with a step
00:01:51.350 --> 00:01:55.100
size of one half that.
00:01:55.100 --> 00:01:57.410
We integrate the
differential equation,
00:01:57.410 --> 00:02:02.690
take the final value of y for
each of those two integrations,
00:02:02.690 --> 00:02:06.120
compare those values
with the exact answer,
00:02:06.120 --> 00:02:08.770
take the ratio of
those two values.
00:02:08.770 --> 00:02:12.980
That shows how much the
error is decreased when
00:02:12.980 --> 00:02:16.040
we cut the step size in half.
00:02:16.040 --> 00:02:20.100
The log base 2 of that
ratio is the order.
00:02:20.100 --> 00:02:23.340
It should be an integer so we
can round it to the nearest
00:02:23.340 --> 00:02:27.575
integer, and return that value
as the value in this function.
00:02:32.000 --> 00:02:35.095
Let's run our experiment
first on ODE1.
00:02:37.910 --> 00:02:45.010
We step size of 0.1, this method
gets the integral as 0.5389,
00:02:45.010 --> 00:02:46.420
not very accurate.
00:02:46.420 --> 00:02:51.280
Cut the step size in
half, it gets 0.5191.
00:02:51.280 --> 00:02:53.750
The ratio of those is two.
00:02:53.750 --> 00:02:56.250
Logarithm base 2 is 1.
00:02:56.250 --> 00:03:00.340
So ODE1 has order 1.
00:03:04.600 --> 00:03:09.620
Now ODE2-- step size 0.1.
00:03:09.620 --> 00:03:11.210
0.499.
00:03:11.210 --> 00:03:14.930
cut it in half, 0.4998.
00:03:14.930 --> 00:03:18.590
The ratio of those
is close to 4.
00:03:18.590 --> 00:03:24.655
And so ODE2, we find with this
experiment, is getting order 2.
00:03:29.970 --> 00:03:32.270
Now let's try
classical Runge-Kutta.
00:03:34.880 --> 00:03:36.740
This is why it's so popular.
00:03:36.740 --> 00:03:38.600
It's very accurate.
00:03:38.600 --> 00:03:43.120
We step size of 0.1,
we get close to 1/2.
00:03:43.120 --> 00:03:48.310
Cut the step size in
half, we get even closer.
00:03:48.310 --> 00:03:52.760
The ratio of these
two is close to 16.
00:03:52.760 --> 00:03:55.570
To the log base 2 is 4.
00:03:55.570 --> 00:04:01.300
So ODE4 has,
experimentally, order 4.
00:04:01.300 --> 00:04:05.680
So we found that, at least
with this single experiment,
00:04:05.680 --> 00:04:13.340
the ODE solvers 1, 2, and
4, have orders 1, 2, and 4.
00:04:13.340 --> 00:04:16.160
So as you probably
realized, this
00:04:16.160 --> 00:04:19.750
is why we named them
ODE 1, 2, and 4.
00:04:24.440 --> 00:04:29.130
This brings us to the naming
conventions in the functions
00:04:29.130 --> 00:04:31.550
in the MATLAB ODE suite.
00:04:31.550 --> 00:04:34.380
All the functions
have names that are
00:04:34.380 --> 00:04:36.190
variations on the theme ODEpq.
00:04:39.090 --> 00:04:47.520
That means that the method ODEpq
uses methods of order p and q
00:04:47.520 --> 00:04:54.180
So we've been getting a glimpse
of that with our names, ODE 1,
00:04:54.180 --> 00:04:55.005
2, and 4.
00:05:00.620 --> 00:05:02.830
Here's an exercise.
00:05:02.830 --> 00:05:06.540
Modify order x to do further
experiments involving
00:05:06.540 --> 00:05:09.990
the order of our ODE solvers.
00:05:09.990 --> 00:05:13.530
Change it to do other integrals.
00:05:13.530 --> 00:05:19.710
And check out the order
of ODE 1, 2, and 4.