WEBVTT

00:00:05.126 --> 00:00:06.720
PROFESSOR: Hi everyone.

00:00:06.720 --> 00:00:07.850
Welcome back.

00:00:07.850 --> 00:00:09.930
So today, I'd like
to tackle a problem

00:00:09.930 --> 00:00:15.087
in numerical integration of ODEs
specifically on Euler's method.

00:00:15.087 --> 00:00:17.295
And the problem we're
interested in considering today

00:00:17.295 --> 00:00:21.670
is the ODE y prime equals
y squared minus xy.

00:00:21.670 --> 00:00:24.750
And we're interested in
integrating the solution

00:00:24.750 --> 00:00:27.820
that starts at y of zero
is equal to negative 1

00:00:27.820 --> 00:00:30.400
using a step size of 0.5.

00:00:30.400 --> 00:00:32.880
And we want to
integrate it to y of 1.

00:00:32.880 --> 00:00:34.630
And then for the
second part, we're

00:00:34.630 --> 00:00:37.710
interested in if our
first step of integration

00:00:37.710 --> 00:00:39.910
either overestimates
or underestimates

00:00:39.910 --> 00:00:41.387
the exact solution.

00:00:41.387 --> 00:00:43.970
So I'll let you think about this
and work it out for yourself,

00:00:43.970 --> 00:00:45.261
and I'll come back in a moment.

00:00:57.990 --> 00:00:58.990
Hi everyone.

00:00:58.990 --> 00:01:00.400
Welcome back.

00:01:00.400 --> 00:01:03.470
So as I mentioned before,
this is a problem in numerics.

00:01:03.470 --> 00:01:05.616
And specifically, whenever
you're given an ODE,

00:01:05.616 --> 00:01:06.990
you can almost
always numerically

00:01:06.990 --> 00:01:08.830
integrate it on a computer.

00:01:08.830 --> 00:01:11.020
And this is quite possibly
the simplest algorithm

00:01:11.020 --> 00:01:13.590
for numerical integration.

00:01:13.590 --> 00:01:15.380
So specifically,
what we do is we

00:01:15.380 --> 00:01:18.000
take the left-hand side,
the derivative, y prime,

00:01:18.000 --> 00:01:21.590
and we approximate it using a
very simple finite difference

00:01:21.590 --> 00:01:22.090
formula.

00:01:26.450 --> 00:01:29.940
So if I take y prime and
approximate it as y of n

00:01:29.940 --> 00:01:39.540
plus 1 minus y of n divided by
h, where h is the step size,

00:01:39.540 --> 00:01:44.430
then I can approximate
the continuous ODE

00:01:44.430 --> 00:01:46.600
using this simple formula.

00:01:46.600 --> 00:01:50.250
So here h as I mentioned
is the step size.

00:01:54.150 --> 00:02:00.080
f, in this case, is the
right-hand side of the ODE.

00:02:04.890 --> 00:02:08.490
And we see that y of n plus
1 minus y of n divided by h

00:02:08.490 --> 00:02:09.880
is an approximation to y prime.

00:02:13.730 --> 00:02:15.430
In addition, we
can also write down

00:02:15.430 --> 00:02:20.386
x of n plus 1 is just
equal to x of n plus h.

00:02:23.570 --> 00:02:25.170
And I'm using
subscripts n here just

00:02:25.170 --> 00:02:28.670
to denote the step
of the algorithm.

00:02:28.670 --> 00:02:31.350
So for part A, we're
asked to integrate

00:02:31.350 --> 00:02:34.450
the solution-- it starts at y
of zero is equal to negative 1--

00:02:34.450 --> 00:02:36.550
to y of 1.

00:02:36.550 --> 00:02:44.890
So what this means for part A
is we want x of zero to be zero,

00:02:44.890 --> 00:02:47.790
and we want y of zero
to be negative 1.

00:02:52.890 --> 00:02:55.627
Now to further integrate this
equation, the quickest way

00:02:55.627 --> 00:02:57.710
to do it, especially if
you're in a test scenario,

00:02:57.710 --> 00:02:58.690
is to build a table.

00:03:01.410 --> 00:03:04.040
So a nice table to
build is one that

00:03:04.040 --> 00:03:12.240
has a column n, x of n, y of n.

00:03:12.240 --> 00:03:13.550
I'm going to write f of n.

00:03:16.170 --> 00:03:21.810
f of n is to denote f
evaluated at x of n and y of n.

00:03:24.650 --> 00:03:30.050
And then, it's also useful
to write down h times f of n

00:03:30.050 --> 00:03:33.540
because the quantity
h times f of n

00:03:33.540 --> 00:03:35.510
comes up in the
addition of y of n

00:03:35.510 --> 00:03:38.756
plus 1 is equal to y of
n plus h times f of n.

00:03:43.420 --> 00:03:45.712
And in the problem
under consideration,

00:03:45.712 --> 00:03:47.670
I'm just going to fill
in the first two columns

00:03:47.670 --> 00:03:48.890
because they're the easiest.

00:03:48.890 --> 00:03:52.420
We have n is equal
to 0, 1 and 2.

00:03:52.420 --> 00:03:54.540
X of n is starting off at zero.

00:03:54.540 --> 00:03:57.110
So x of zero is zero.

00:03:57.110 --> 00:04:01.370
x of 1 is going to be 0.5.

00:04:01.370 --> 00:04:06.160
And then, x of 2 is equal to 1.

00:04:06.160 --> 00:04:08.040
In addition, we're also
told that y of zero

00:04:08.040 --> 00:04:11.900
is equal to negative 1.

00:04:11.900 --> 00:04:19.380
And now for f of n, I'll
just use the side here,

00:04:19.380 --> 00:04:23.240
what's f of zero going to be?

00:04:23.240 --> 00:04:29.160
Well, it's going to be y of
zero minus x of zero y of zero.

00:04:32.370 --> 00:04:36.760
So this gives us 1 and 0.

00:04:36.760 --> 00:04:43.090
So we can fill in a 0.1 here,
which means that h times f of 1

00:04:43.090 --> 00:04:46.950
is going to be 0.5.

00:04:46.950 --> 00:04:52.540
And now with h of f of
n, we can fill in y of 1.

00:04:52.540 --> 00:04:57.690
So y of 1 is just going
to be y of zero plus 0.5.

00:04:57.690 --> 00:04:59.820
And y of zero is negative 1.

00:04:59.820 --> 00:05:06.250
So this is going
to be negative 0.5.

00:05:06.250 --> 00:05:09.810
Now, we need to fill in f of 1.

00:05:09.810 --> 00:05:16.450
So this is going to be y of 1
squared minus x of 1 y of 1.

00:05:16.450 --> 00:05:20.180
Now y of 1 squared, this
is negative 0.5 squared.

00:05:23.330 --> 00:05:26.860
x of 1 is 0.5.

00:05:26.860 --> 00:05:31.840
And y of 1 is,
again, negative 0.5.

00:05:31.840 --> 00:05:36.190
So this gives us one
quarter plus one quarter,

00:05:36.190 --> 00:05:41.310
which together is just 0.5.

00:05:41.310 --> 00:05:44.310
So we have 0.5 in
this square now.

00:05:44.310 --> 00:05:53.430
And then h times 0.5 is 0.5
squared, which is just 0.25.

00:05:53.430 --> 00:05:58.870
Now y of 2 is just going to
be y of 1 plus h times f of 1.

00:05:58.870 --> 00:06:03.360
So we know h of f of
1 is 0.25, and y of 1

00:06:03.360 --> 00:06:06.100
is just negative 0.5.

00:06:06.100 --> 00:06:12.380
So this is going to
be negative 0.25.

00:06:12.380 --> 00:06:17.160
And we note that this is the
answer we're looking for.

00:06:17.160 --> 00:06:24.260
So just to conclude, our
approximation y of 2,

00:06:24.260 --> 00:06:29.840
which is approximately
y evaluated at 1,

00:06:29.840 --> 00:06:36.990
is going to be negative 0.25.

00:06:36.990 --> 00:06:43.630
So for part B, we're asked does
our approximation negative 0.25

00:06:43.630 --> 00:06:46.870
overestimate or underestimate
the actual exact solution

00:06:46.870 --> 00:06:49.710
of the ODE?

00:06:49.710 --> 00:06:51.350
Now, in general,
what you want to do

00:06:51.350 --> 00:06:53.140
is you want to take
the second derivative.

00:06:53.140 --> 00:06:54.390
However, for this
problem, we're only

00:06:54.390 --> 00:06:55.770
going to consider
the first step.

00:06:55.770 --> 00:06:58.970
So our first step, does it
overestimate or underestimate

00:06:58.970 --> 00:07:00.750
the exact solution?

00:07:00.750 --> 00:07:02.420
And to do this,
what we want to do

00:07:02.420 --> 00:07:04.570
is we want to take a
look at the concavity.

00:07:04.570 --> 00:07:07.230
So we want to look
at y double prime.

00:07:07.230 --> 00:07:13.260
So y double prime is going
to be d by dx of y prime.

00:07:13.260 --> 00:07:18.240
And we know from the ODE y
prime is y squared minus xy.

00:07:18.240 --> 00:07:23.630
So I can work this
out to be 2y y prime,

00:07:23.630 --> 00:07:32.010
just using the chain rule,
minus y minus x y prime.

00:07:32.010 --> 00:07:35.550
And at the first step, we're
interested in evaluating

00:07:35.550 --> 00:07:40.130
this quantity at the
point x equals zero,

00:07:40.130 --> 00:07:41.660
y is equal to negative 1.

00:07:41.660 --> 00:07:42.810
So this is the first step.

00:07:45.410 --> 00:07:50.470
So at x is equal to zero,
y is equal to negative 1,

00:07:50.470 --> 00:07:56.500
this simplifies to
minus 2y prime plus 1.

00:07:56.500 --> 00:07:59.580
This term right here drops off.

00:07:59.580 --> 00:08:03.910
And y prime specifically is
going to be y squared minus xy.

00:08:03.910 --> 00:08:12.370
So we get 2-- y squared is going
to be 1-- minus zero plus 1.

00:08:12.370 --> 00:08:15.704
So together, this is
going to give us minus 1.

00:08:15.704 --> 00:08:17.370
And we note that this
is less than zero.

00:08:21.490 --> 00:08:23.500
So we've just shown
that the concavity

00:08:23.500 --> 00:08:27.120
at our starting point, x equals
zero, y is equal to negative 1

00:08:27.120 --> 00:08:29.880
is less than zero.

00:08:29.880 --> 00:08:32.780
So what this means is that our
initial approximation is going

00:08:32.780 --> 00:08:35.257
to overestimate the solution.

00:08:35.257 --> 00:08:37.340
We can see that it's going
to overestimate it just

00:08:37.340 --> 00:08:38.089
by a quick sketch.

00:08:42.909 --> 00:08:45.650
For example, if I
were to plot y and x,

00:08:45.650 --> 00:08:49.500
we're starting off at this
point, x is equal to zero,

00:08:49.500 --> 00:08:51.330
y is equal to negative 1.

00:08:51.330 --> 00:08:56.360
So this is y(0) is
equal to negative 1.

00:08:56.360 --> 00:08:59.730
We know the exact
solution's increasing,

00:08:59.730 --> 00:09:03.470
and it's concave down
because the second derivative

00:09:03.470 --> 00:09:05.170
is negative 1.

00:09:05.170 --> 00:09:07.390
And by Euler's formula,
what we're doing is

00:09:07.390 --> 00:09:10.910
we're approximating the
solution using a tangent line

00:09:10.910 --> 00:09:11.790
at this point.

00:09:11.790 --> 00:09:14.340
So we can see that our
approximate solution

00:09:14.340 --> 00:09:18.200
when we take one step
to go from here to here,

00:09:18.200 --> 00:09:25.380
so this is x of zero, this is x
of 1, our solution which is now

00:09:25.380 --> 00:09:31.320
going to be y of 1 here is
going to overestimate the curve.

00:09:31.320 --> 00:09:34.260
And the reason it overestimates
it, I'll just reiterate again,

00:09:34.260 --> 00:09:37.930
is because our solution
is concave down.

00:09:37.930 --> 00:09:40.090
So this concludes the problem.

00:09:40.090 --> 00:09:43.640
And just to reiterate, when
dealing with Euler's method,

00:09:43.640 --> 00:09:46.160
the best thing to do is just
to build a table like this.

00:09:46.160 --> 00:09:49.530
And you can quickly work it out.

00:09:49.530 --> 00:09:51.520
Secondly, if you're
asked questions

00:09:51.520 --> 00:09:56.380
on if your numerical solution
overestimates or underestimates

00:09:56.380 --> 00:09:58.490
the exact solution,
typically what you want to do

00:09:58.490 --> 00:10:00.880
is you want to look
at the concavity.

00:10:00.880 --> 00:10:02.400
And then, you can
always just sketch

00:10:02.400 --> 00:10:04.780
a quick diagram on
the back of a notepad

00:10:04.780 --> 00:10:10.090
to see if the solution
overestimates or underestimates

00:10:10.090 --> 00:10:12.570
the exact solution.

00:10:12.570 --> 00:10:13.860
So I'd like to conclude here.

00:10:13.860 --> 00:10:15.670
And I'll see you next time.