4.3 Euler's Method: Linear Approximation
4.3 Euler's Method: Linear Approximation
3 Euler’s Method
Euler’s method is a numerical method that can be used to approximate the solutions
to explicit first-order equations. It is based on making successive linear approximations
to the solution.
Linear Approximation
Suppose we are given a single data point ( x0 , y0 ) for a function y ( x ) , and suppose we
also know the value of the derivative y 0 ( x0 ) at this point. In this case, nearby points
( x, y ) on the graph of the function obey the approximate formula
∆y
≈ y0 ( x0 ) .
∆x
Here ∆x x − x0 is the distance in the x direction, and ∆y y − y0 is the distance
in the y direction, as shown in Figure 1. This equation is only approximately correct,
since it assumes that the average slope between ( x 0 , y0 ) and ( x, y ) is equal to y 0 ( x0 ) .
We can use this formula to estimate y ( x ) for x close to x0 . Specifically, we compute
a Figure 1: The ratio of ∆y to ∆x is ∆x x − x 0 , and then estimate ∆y using the formula
approximately equal to the slope at ( x 0 , y0 ) .
∆y ≈ y 0 ( x0 ) ∆x
EXAMPLE 1
Suppose y ( x ) is a differentiable function satisfying y (1) 3 and y 0 (1) 0.5. Use a linear
approximation to estimate the value of y (1.04) .
a Figure 2: The estimated point lies on the SOLUTION Here we are changing x by the small amount ∆x 0.04. The corresponding
tangent line to the graph of y ( x ) at the point change in y is
( x 0 , y0 ) . ∆y ≈ y 0 (1) ∆x (0.5)(0.04) 0.02.
Then
y (1.04) y (1) + ∆y ≈ 3 + 0.02 3.02.
EXAMPLE 2
Let y ( x ) be the solution to the following initial value problem:
y 0 3y 2 + ln x, y (1) 0.5.
Estimate y (1.002) .
SOLUTION Plugging x 1 and y 0.5 into the differential equation itself gives us the value
of y 0 (1) :
y 0 (1) 3 (0.5) 2 + ln (1) 0.75.
EULER’S METHOD 2
Euler’s Method
The idea of Euler’s method is to use repeated linear approximations to estimate a
sequence of points that lie on a solution curve. Starting with an initial condition ( x0 , y0 ) ,
we use a linear approximation to estimate a nearby point on the solution curve. We
then use a linear approximation based at the new point to estimate yet another point,
and so forth.
EXAMPLE 3
Let y ( x ) be the solution to the following initial value problem:
SOLUTION The idea is to use three linear approximations, each with ∆x 0.1. We will keep
track of three decimal places during the process.
1st Approximation
We start by making a linear approximation to estimate y (0.1) . We have
2nd Approximation
Next we make a linear approximation to estimate y (0.2) , using the the point (0.1, 1.084)
from the previous approximation as the base point. We have
3rd Approximation
Finally we make a linear approximation to estimate y (0.3) , using the the point (0.2, 1.142)
from the previous approximation as the base point. We have
a Figure 3: The three linear Figure 3 shows the three linear approximations in this example. By changing slope twice, we
manage to follow the slope field much better than we could with a single linear approximation.
approximations in Example 3.
EULER’S METHOD 3
When using Euler’s method, we typically use the same step size ∆x for all of the
linear approximations. It is common to use a table to keep track of the estimates in each
step, as shown in Table 4.1. Each value of y 0 is computed from the x and y values in
x 0.0 0.1 0.2 0.3
the same column using the differential equation, and each value of y is computed from
y 1.000 1.084 1.142 1.173 the y and y 0 values in the previous column using the following linear approximation
y0 0.841 0.584 0.309 — formula:
a Table 4.1: Table of values for the linear ynew ≈ yold + yold
0
∆x
approximations used in Example 1.
Note that this formula combines the two parts of the linear approximation (computing
∆y and then adding it to yold ) into a single equation.
EXAMPLE 4
Let y ( x ) be the solution to the following initial value problem:
y 0 ( x − 1) 2 − y 2 , y (0) 0.5.
Use Euler’s method with step size ∆x 0.5 to estimate y (2.5) , keeping track of four decimal
places during the procedure.
Here are the calculations that were used to produce this table:
Figure 4 shows the five linear approximations used in this example. Note that each linear
a Figure 4: The five steps of Euler’s segment has the correct slope at its left endpoint, but the slope gradually becomes wrong over
method used in Example 4. the course of each step.
Euler’s method may remind you of using a Riemann sum to approximate a definite
integral. Indeed, in the special case where the differential equation has the form
y0 f ( x ) ,
solving the differential equation is the same as integrating f , and Euler’s method gives
the same result as the left endpoint rule for a Riemann sum.
EULER’S METHOD 4
Euler’s method is only the simplest numerical method for solving differential equations.
Finding better ways of approximating solutions to differential equations is an ongoing subject
of research, and is one of the primary goals of the field of mathematics known as numerical
analysis.
One basic improvement is to estimate the slope of each straight segment using a combination
of y 0 values corresponding to different values of x. This idea leads to a set of possible methods
known collectively as Runge-Kutta methods. Another possible improvement, often combined
with Runge-Kutta, is to change the step size ∆x adaptively, using small steps when the value
of y 0 seems to be changing quickly, and using large steps when y 0 is roughly constant.
Modern computer algebra systems such as Mathematica, Sage, and Matlab have a variety of
different numerical methods built into the system. Though you can choose a method explicitly
to solve a given problem, most computer algebra systems also have a built-in algorithm to
choose an appropriate method based on the properties of the given equation.
As with a Riemann sum, Euler’s method becomes more precise as the step size
becomes smaller, since the slope is being adjusted more often. For example, we can
improve the estimated values in Example 4 by decreasing the step size, as shown in
Figures 5, 6, and 7. The last of these three graphs (with step size 0.01) follows the actual
solution curve to within 0.004, which is about a third of the width of the red line.
a Figure 5: Euler’s method for the With a computer, it is possible to implement Euler’s method using very small steps
initial-value problem in Example 4 with step (e.g. ∆x 0.000001), which leads to very accurate numerical approximations for the
size ∆x 0.25.
solution curves. Combining this with other numerical methods (see the Numerical
Methods box above) can increase the speed and accuracy further, making computers an
indispensable tool for scientific modeling.
EXERCISES
y0 x 2 − y 3 , y (0) 1.
a Figure 6: Euler’s method for the
Use Euler’s method with a step size of 0.2 to estimate y (1) , keeping track of three
initial-value problem in Example 4 with step
size ∆x 0.1. decimal places during the calculation.
y 0 x y − 2, y (2) 1.
Use Euler’s method with a step size of 0.5 to estimate y (4) , keeping track of three
decimal places during the calculation.
3. A ball is dropped from the top of a tall building. If air resistance is taken into
a Figure 7: Euler’s method for the account, the downward velocity v of the ball is modeled by the differential equation
initial-value problem in Example 4 with step
size ∆x 0.01. dv
g − kv 2
dt
where g 9.8 m/sec2 is the acceleration due to gravity, and k 0.1/m is the drag
coefficient. Assuming the initial velocity of the ball is zero, use Euler’s method
with a step size of 0.25 sec to estimate the velocity of the ball after one second.
Keep track of three decimal places during the calculation.