PROFESSOR: Hi everyone.

Welcome back.

So today, I'd like to tackle a problem

in numerical integration of ODEs specifically on Euler's method.

And the problem we're interested in considering today

is the ODE y prime equals y squared minus xy.

And we're interested in integrating the solution

that starts at y of zero is equal to negative 1

using a step size of 0.5.

And we want to integrate it to y of 1.

And then for the second part, we're

interested in if our first step of integration

either overestimates or underestimates

the exact solution.

So I'll let you think about this and work it out for yourself,

and I'll come back in a moment.

Hi everyone.

Welcome back.

So as I mentioned before, this is a problem in numerics.

And specifically, whenever you're given an ODE,

you can almost always numerically

integrate it on a computer.

And this is quite possibly the simplest algorithm

for numerical integration.

So specifically, what we do is we

take the left-hand side, the derivative, y prime,

and we approximate it using a very simple finite difference

formula.

So if I take y prime and approximate it as y of n

plus 1 minus y of n divided by h, where h is the step size,

then I can approximate the continuous ODE

using this simple formula.

So here h as I mentioned is the step size.

f, in this case, is the right-hand side of the ODE.

And we see that y of n plus 1 minus y of n divided by h

is an approximation to y prime.

In addition, we can also write down

x of n plus 1 is just equal to x of n plus h.

And I'm using subscripts n here just

to denote the step of the algorithm.

So for part A, we're asked to integrate

the solution-- it starts at y of zero is equal to negative 1--

to y of 1.

So what this means for part A is we want x of zero to be zero,

and we want y of zero to be negative 1.

Now to further integrate this equation, the quickest way

to do it, especially if you're in a test scenario,

is to build a table.

So a nice table to build is one that

has a column n, x of n, y of n.

I'm going to write f of n.

f of n is to denote f evaluated at x of n and y of n.

And then, it's also useful to write down h times f of n

because the quantity h times f of n

comes up in the addition of y of n

plus 1 is equal to y of n plus h times f of n.

And in the problem under consideration,

I'm just going to fill in the first two columns

because they're the easiest.

We have n is equal to 0, 1 and 2.

X of n is starting off at zero.

So x of zero is zero.

x of 1 is going to be 0.5.

And then, x of 2 is equal to 1.

In addition, we're also told that y of zero

is equal to negative 1.

And now for f of n, I'll just use the side here,

what's f of zero going to be?

Well, it's going to be y of zero minus x of zero y of zero.

So this gives us 1 and 0.

So we can fill in a 0.1 here, which means that h times f of 1

is going to be 0.5.

And now with h of f of n, we can fill in y of 1.

So y of 1 is just going to be y of zero plus 0.5.

And y of zero is negative 1.

So this is going to be negative 0.5.

Now, we need to fill in f of 1.

So this is going to be y of 1 squared minus x of 1 y of 1.

Now y of 1 squared, this is negative 0.5 squared.

x of 1 is 0.5.

And y of 1 is, again, negative 0.5.

So this gives us one quarter plus one quarter,

which together is just 0.5.

So we have 0.5 in this square now.

And then h times 0.5 is 0.5 squared, which is just 0.25.

Now y of 2 is just going to be y of 1 plus h times f of 1.

So we know h of f of 1 is 0.25, and y of 1

is just negative 0.5.

So this is going to be negative 0.25.

And we note that this is the answer we're looking for.

So just to conclude, our approximation y of 2,

which is approximately y evaluated at 1,

is going to be negative 0.25.

So for part B, we're asked does our approximation negative 0.25

overestimate or underestimate the actual exact solution

of the ODE?

Now, in general, what you want to do

is you want to take the second derivative.

However, for this problem, we're only

going to consider the first step.

So our first step, does it overestimate or underestimate

the exact solution?

And to do this, what we want to do

is we want to take a look at the concavity.

So we want to look at y double prime.

So y double prime is going to be d by dx of y prime.

And we know from the ODE y prime is y squared minus xy.

So I can work this out to be 2y y prime,

just using the chain rule, minus y minus x y prime.

And at the first step, we're interested in evaluating

this quantity at the point x equals zero,

y is equal to negative 1.

So this is the first step.

So at x is equal to zero, y is equal to negative 1,

this simplifies to minus 2y prime plus 1.

This term right here drops off.

And y prime specifically is going to be y squared minus xy.

So we get 2-- y squared is going to be 1-- minus zero plus 1.

So together, this is going to give us minus 1.

And we note that this is less than zero.

So we've just shown that the concavity

at our starting point, x equals zero, y is equal to negative 1

is less than zero.

So what this means is that our initial approximation is going

to overestimate the solution.

We can see that it's going to overestimate it just

by a quick sketch.

For example, if I were to plot y and x,

we're starting off at this point, x is equal to zero,

y is equal to negative 1.

So this is y(0) is equal to negative 1.

We know the exact solution's increasing,

and it's concave down because the second derivative

is negative 1.

And by Euler's formula, what we're doing is

we're approximating the solution using a tangent line

at this point.

So we can see that our approximate solution

when we take one step to go from here to here,

so this is x of zero, this is x of 1, our solution which is now

going to be y of 1 here is going to overestimate the curve.

And the reason it overestimates it, I'll just reiterate again,

is because our solution is concave down.

So this concludes the problem.

And just to reiterate, when dealing with Euler's method,

the best thing to do is just to build a table like this.

And you can quickly work it out.

Secondly, if you're asked questions

on if your numerical solution overestimates or underestimates

the exact solution, typically what you want to do

is you want to look at the concavity.

And then, you can always just sketch

a quick diagram on the back of a notepad

to see if the solution overestimates or underestimates

the exact solution.

So I'd like to conclude here.

And I'll see you next time.