### Video Transcript

In this lesson, weβll learn how to
use Eulerβs method to approximate solutions to differential equations. When we canβt solve a differential
equation by analytical methods, we can use what are called numerical methods. From a given starting point, we use
it to find repetitive process to approximate a solution to our differential
equation. Eulerβs method is one such
process. Weβll begin by reminding ourselves
of the meanings of some of the terms that weβll use. Weβll then look at how Eulerβs
method is formulated and go on to see how it works with some examples.

Remember that a differential
equation is an equation containing one or more derivatives. The first-order differential
equation contains only the first derivative dπ¦ by dπ₯. And for an unknown function π¦, we
have the slope of π¦ in terms of the function π, which can be a function of π₯ and
π¦, a function of π₯, or a function of π¦. And we might be asked to solve the
differential equation dπ¦ by dπ₯ is equal to π of π₯, π¦ given the initial value π¦
at π₯ is equal to zero is π¦ zero. This means that our starting point
is the point π₯ zero, π¦ zero. And weβre to use this to find the
function π¦ of π₯. When we do this numerically, we use
the point π₯ zero, π¦ zero to find the value of π¦ one, which we then use to find π¦
two with our differential equation and so on to π¦ π. This gives us our approximation to
the function π¦ of π₯.

Using Eulerβs method, we do this by
using a series of tangent lines to build up a picture of our solution. Since weβll be using tangent lines,
letβs keep our differential equation in mind but remind ourselves of some fact about
straight lines. Suppose we have a straight line
through the points π₯ zero, π¦ zero and π₯ one, π¦ one. The slope of this line π is equal
to π¦ one minus π¦ zero over π₯ one minus π₯ zero. Rearranging this we have π¦ one
minus π¦ zero is equal to π times π₯ one minus π₯ zero. This gives us π¦ one equal to π¦
zero plus π times π₯ one minus π₯ zero. Now, if we go back to our
differential equation, we know that the slope of π¦, dπ¦ by dπ₯, is equal to π of
π₯ π¦ so that at the point π₯ zero, π¦ zero, the slope π is equal to π of π₯ zero,
π¦ zero. And for our line through the points
π₯ zero, π¦ zero and π₯ one, π¦ one, we have π¦ one equal to π¦ zero plus π of π₯
zero, π¦ zero times π₯ one minus π₯ zero.

And now, if we call the distance
between π₯ zero and π₯ one β, we have π¦ one equal to π¦ zero plus β times π of π₯
zero, π¦ zero. So we can calculate the value of π¦
one from knowing π¦ zero, β, and π of π₯ zero π¦ zero. Letβs see how this works on a graph
of the function π¦. We have our starting point on the
graph π¦ of π₯, which is π₯ zero, π¦ zero. We draw a tangent line to the curve
at π₯ zero, π¦ zero. And we know that the slope of this
line is π of π₯ zero, π¦ zero. If we continue this line to where
it meets the vertical with π₯ one, which is the distance β from π₯ zero, this gives
us the value π¦ one. Now, if we draw a tangent to the
curve π¦ at the point π₯ one, π¦ one, this tangent has the slope π of π₯ one, π¦
one. If this tangent then meets the
vertical at π₯ two, which is the distance β from π₯ one, we can find π¦ two, in
terms of π¦ one, β, and π of π₯ one, π¦ one.

If we continue in this way for a
specified number of steps π up to π₯ π, on a specified step size β we find π¦ π
is equal to π¦ π minus one plus β times π of π₯ π minus one π¦ π minus one. And in this way, we find an
approximation to π¦ of π π₯ which is a solution to the differential equation. Itβs important to remember that
weβre actually approximating a solution to the given differential equation. If our step size is quite large,
our approximation might be quite far away from the actual solution function π¦ of
π₯. We can increase the accuracy of our
solution by decreasing the step size. Now, letβs see how this works with
an example.

Consider the initial value problem
π¦ prime is four π₯ minus three π¦ where π¦ at π₯ equal to zero is negative one. Use Eulerβs method with π equal to
five steps on the closed interval zero one to find the value of π¦ at π₯ is equal to
one.

Weβve actually been given a
differential equation π¦ prime is equal to four π₯ minus three π¦ and an initial
value π¦ at π₯ is equal to zero is negative one. This means that our starting point
for Eulerβs method is the point π₯ zero, π¦ zero which is equal to zero, negative
one. We also know that we have five
steps and that our closed interval zero, one means that zero is less than or equal
to π₯ is less than or equal to one. So we have π equal to five and
zero less than or equal to π₯ less than or equal to one.

Weβre asked to use Eulerβs method
to find the value of π¦ at π₯ is equal to one. To do this, the first thing we need
to do is to find the value of β. Thatβs our step size. Now, β is the interval width
divided by the number of steps, in our case, the interval where thereβs a maximum π₯
value one minus the minimum π₯ value zero which is one. The number of steps is five. So our step size is one over
five. Letβs just sketch our Interval so
that we can refer to it throughout our calculations. Our first π₯ value is zero, which
is π₯ zero. Our step size is one over five,
which is 0.2. So our next point π₯ one is
0.2. Our next π₯ value π₯ two is 0.4, π₯
three is 0.6, π₯ four is 0.8, and π₯ five is one.

And remember, weβre being asked to
calculate the value of π¦ at π₯ is equal to one. So thatβs π¦ of π₯ five, which is
π¦ five. So weβre going to use Eulerβs
method to calculate π¦ five. We canβt go directly to π¦ five
because the only value we have is π₯ zero, π¦ zero. So we start at this point and
calculate π¦ one, π¦ two, then π¦ three, then π¦ four, and then π¦ five. So to use the formula, we need to
know the value of π₯ zero, π¦ zero, which is zero, negative one. We need to know β, which is 0.2,
and we need to know what the function π of π₯, π¦ is. In our differential equation, π¦
prime, which is dπ¦ by dπ₯, is equal to four π₯ minus three π¦. So π of π₯ π¦, in our case, is
four π₯ minus three π¦.

We know that π¦ zero is equal to
negative one. And we can use this to find π¦
one. And in the formula, if π is equal
to one, then π minus one is equal to zero so that π¦ one is equal to π¦ zero plus β
times π of π₯ zero, π¦ zero. We know that π¦ zero was negative
one and that β is 0.2. So we need to find π of π₯ zero,
π¦ zero. In our differential equation, π of
π₯ zero, π¦ zero is four π₯ zero minus three π¦ zero. And thatβs equal to four times zero
minus three times negative one, which is equal to three, so that π¦ one is equal to
negative one plus 0.2 times three, which is negative 0.4. Now, we can use π¦ one to calculate
π¦ two.

We know that π¦ one is equal to
negative 0.4. We know that β is 0.2. So we need to work out π of π₯
one, π¦ one. And thatβs equal to four π₯ one
minus three π¦ one. And since π₯ one is 0.2, thatβs
four times 0.2 minus three times negative 0.4, which is 0.8 plus 1.2 which is
two. So π¦ two is equal to negative 0.4
plus 0.2 times two which is actually zero. Now, if we put π equal to three in
our formula, π¦ three is equal to π¦ two plus β times π of π₯ two π¦ two. We know that π¦ two is equal to
zero and β is 0.2. So we need to work out π of π₯ two
π¦ two. And thatβs equal to four π₯ two
minus three π¦ two. And since π₯ two is 0.4, thatβs
four times 0.4 minus three times zero, which is 1.6. So we have π¦ three equal to zero
plus 0.2 times 1.6, which is 0.32.

Now, with π equal to four, we have
π¦ four is equal to π¦ three plus β times π of π₯ three, π¦ three. π of π₯ three π¦ three is four π₯
three minus three π¦ three. So we have four times 0.6 minus
three times 0.32 which is 1.44, so that π¦ four is equal to 0.32 plus 0.2 times 1.44
and thatβs 0.608. And finally with π equal to five
in our formula, we have π¦ five equal to π¦ four plus β times π of π₯ four π¦
four. π of π₯ four π¦ four is equal to
four π₯ four minus three π¦ four. And thatβs equal to four times 0.8
minus three times 0.608 which is 1.376 so that we have π¦ five equal to 0.608 plus
0.2 times 1.376. And thatβs equal to 0.8832. And remember that itβs exactly π¦
five that weβre looking for because this is the value of π¦ at π₯ is equal to one,
so that π¦ of one is 0.8832.

Now letβs plot our approximation to
the function π¦, using the points that we found. The graph shown is a
computer-generated solution of the differential equation π¦ prime is four π₯ minus
three π¦ with initial value π₯ zero, π¦ zero is zero, negative one. And these are the points that we
found using Eulerβs method to find an approximation to the solution. If we plot our points on the graph,
we can see itβs a very good approximation to the computer-generated solution.

In our next example, weβll look at
a derivative or slope, which is a function of π₯ only. And then weβll compare different
solutions, which have used different step sizes for the approximations.

Consider the initial value problem
π¦ prime is three π₯, where π¦ at π₯ is equal to zero is equal to one. Use Eulerβs method with π equal to
five steps on the closed interval zero, one to find π¦ at π₯ is equal to one.

Weβve been given a differential
equation π¦ prime is three π₯ so that π¦ prime, which is dπ¦ by dπ₯, is equal to
three π₯. We have an initial value π¦ at π₯
is equal to zero is equal to one, which means that our starting point π₯ zero, π¦
zero is zero one. We have π equals to five steps and
the closed interval zero, one. This means that zero is less than
or equal to π₯ is less than or equal to one. And weβre asked to use Eulerβs
method to find the value of π¦ at π₯ is equal to one. In order to use this formula, we
need to know the value of β, which is the step size. And thatβs given by the interval
width divided by the number of steps. In our case, the interval width is
a maximum π₯ minus the minimum π₯ which is one minus zero divided by the number of
steps which is five. Thatβs one over five, which is
0.2.

Letβs just sketch our interval, so
we can refer back to it in our calculations. Since our step size is 0.2 and π₯
zero is equal to zero, π₯ one is equal to 0.2. Similarly, π₯ two is equal to 0.4,
π₯ three is 0.6, and π₯ four is 0.8, and π₯ five, which is our maximum value is
one. Remember, weβre trying to find the
value of π¦ when π₯ is equal to one. And thatβs π¦ of π₯ five. And we call that π¦ five. In order to use the formula, we
need to know what our function π is. And from our differential equation,
we can see that dπ¦ by dπ₯ is equal to π of π₯ is three π₯. So if this is a function of π₯
only, this means we can delete the second variable π¦ in our function π in Eulerβs
formula, so that our formula is π¦ π is equal to π¦ π minus one plus β times π of
π₯ π minus one, where π of π₯ π is three π₯ π. So we have everything we need to
use the formula.

We know that π¦ zero is equal to
one, so we can use the formula to calculate π¦ one. And thatβs equal to π¦ zero plus β
times π of π₯ zero. We know the value of π¦ zero, which
is one, and we know the value of β, which is 0.2. So we need to work out π of π₯
zero. From our differential equation,
thatβs equal to three times π₯ zero, which is three times zero, which is zero so
that π¦ one is equal to one plus 0.2 times zero, which is one. And we can use this in our formula
to calculate π¦ two, which is equal to π¦ one plus β times π of π₯ one. And we need to work out π of π₯
one. Thatβs equal to three times π₯ one
from our differential equation. And from our interval, we know that
π₯ one is equal to 0.2. So we have three times 0.2 is equal
to π of π₯ one, and thatβs 0.6.

So π¦ two is equal to one plus 0.2
times 0.6 which is equal to 1.12. We use this to find π¦ three, which
is π¦ two plus β times π of π₯ two, where π of π₯ two is three times π₯ two and π₯
two is 0.4, so that π of π₯ two is 1.2. π¦ three is then 1.12 plus 0.2
times 1.2, which is 1.36. We use this to calculate π¦ four
which is π¦ three plus β times π of π₯ three and π of π₯ three is three times π₯
three. From our interval, π₯ three is
0.6. So thatβs three times 0.6, which is
1.8. And we have π¦ four equal to 1.36
plus 0.2 times 1.8, which is 1.72. Now, we use this in our final step
to calculate π¦ five, where π¦ five is equal to π¦ four plus β times π of π₯ four
which is three π₯ four. And since π₯ four is 0.8 from our
interval, π of π₯ four is three times 0.8, which is 2.4. So π¦ five is equal to 1.72 plus
0.2 times 2.4, which is 2.2. Remember that π¦ five is equal to
π¦ at π₯ is equal to one, which weβve just calculated as 2.2. So π¦ at π₯ is equal to one is
2.2.

In our example, we were given π
equal to five steps on the closed interval zero, one. This resulted in the step size of
0.2. From an initial value of π₯ zero,
π¦ zero, which is equal to zero one, we calculated all the steps up to π₯ five, π¦
five and arrived at one, 2.2. The graph shown gives a
computer-generated solution to the differential equation and our approximated
solution with the five points that we calculated. Now, letβs see what happens if we
decrease the step size. With π equal to 10 in the step
size of 0.1 now, we have five extra points. On our graph, we can see that the
approximation with the smaller step size is closer to the computer-generated
solution. So when the step size is smaller,
the approximate solution is closer to the actual solution, although notice that we
needed to do more iterations in our calculation.

Letβs summarize now what weβve
covered in Eulerβs method. Weβve been looking at Eulerβs
method for first-order differential equations, which is a numerical method for
solving first-order differential equations of the form dπ¦ by dπ₯ is π of π₯, π¦ or
dπ¦ by dπ₯ is π of π₯ or dπ¦ by dπ₯ is π of π¦. In order to solve, weβre given an
initial value, which is π¦ at π₯ equal to π₯ zero. And thatβs equal to π¦ zero, so
that from our starting point π₯ zero, π¦ zero, we have π steps in the interval π₯
zero to π₯ π. We use the formula π¦ π is equal
to π¦ π minus one plus β times π of π₯ π minus one π¦ π minus one to find
successive values of π¦, in order to form an approximation to the solution π¦ of
π₯. β is the step size, which is the
interval width divided by the number of steps. And we know that the smaller the
step size β, the more accurate the approximation. But this means more iterations will
be necessary.