9 2
9 2
KIU
Direction Fields and Euler's Method
Unfortunately, it’s impossible to solve most differential equations in the sense of
obtaining an explicit formula for the solution.
In this section we show that, despite the absence of an explicit solution, we can
still learn a lot about the solution through a graphical approach (direction fields)
or a numerical approach (Euler’s method).
3
Direction Fields
4
Direction Fields (1 of 10)
Suppose we are asked to sketch the graph of the solution of the initial-value
problem
y = x + y y (0) = 1
We don’t know a formula for the solution, so how can we possibly sketch its
graph? Let’s think about what the differential equation means.
5
Direction Fields (2 of 10)
The equation y = x + y tells us that the slope at any point (x, y) on the graph
(called the solution curve) is equal to the sum of the x- and y-coordinates of the
point (see Figure 1).
A solution of y = x + y
Figure 1
6
Direction Fields (3 of 10)
In particular, because the curve passes through the point (0, 1), its slope there
must be 0 + 1 = 1. So a small portion of the solution curve near the point (0, 1)
looks like a short line segment through (0, 1) with slope 1. (See Figure 2.)
7
Direction Fields (4 of 10)
As a guide to sketching the rest of the curve, let’s draw short line segments at a
number of points (x, y) with slope x + y. The result is called a direction field and
is shown in Figure 3.
Direction field y = x +y
Figure 3
8
Direction Fields (5 of 10)
For instance, the line segment at the point (1, 2) has slope 1 + 2 = 3.
The direction field allows us to visualize the general shape of the solution
curves by indicating the direction in which the curves proceed at each point.
Now we can sketch the solution curve through the point (0, 1) by following the
direction field as in Figure 4.
y = F ( x, y )
where F(x, y) is some expression in x and y. The differential equation says that
the slope of a solution curve at a point (x, y) on the curve is F(x, y).
10
Direction Fields (7 of 10)
If we draw short line segments with slope F(x, y) at several points (x, y), the
result is called a direction field (or slope field).
These line segments indicate the direction in which a solution curve is heading,
so the direction field helps us visualize the general shape of these curves.
11
Example 1
(a) Sketch the direction field for the differential equation y = x 2
+ y 2
− 1.
(b) Use part (a) to sketch the solution curve that passes through the origin.
Solution:
(a) We start by computing the slope at several points in the following table:
12
Example 1 – Solution (1 of 2)
Now we draw short line segments with these slopes at these points. The result
is the direction field shown in Figure 5.
Figure 5
13
Example 1 – Solution (2 of 2)
(b) We start at the origin and move to the right in the direction of the line
segment (which has slope −1).
We continue to draw the solution curve so that it moves parallel to the nearby
line segments. The resulting solution curve is shown in Figure 6.
Returning to the origin, we draw the solution curve to the left as well.
Figure 6
14
Direction Fields (8 of 10)
Now let’s see how direction fields give insight into physical situations.
Figure 8
15
Direction Fields (9 of 10)
The circuit also contains a resistor with a resistance of R ohms (Ω) and an
inductor with an inductance of L henries (H).
Ohm’s Law gives the drop in voltage due to the resistor as RI. The voltage drop
due to the inductor is L = dl . One of Kirchhoff’s laws says that the sum of the
dt
voltage drops is equal to the supplied voltage E(t). Thus we have
dI
1 L + RI = E ( t )
dt
16
Direction Fields (10 of 10)
A differential equation of the form
y = f (y )
in which the independent variable is missing from the right side, is called
autonomous.
For such an equation, the slopes corresponding to two different points with the
same y-coordinate must be equal.
17
Euler’s Method
18
Euler’s Method (1 of 11)
The basic idea behind direction fields can be used to find numerical
approximations to solutions of differential equations.
The differential equation tells us that y (0) = 0 + 1 = 1, so the solution curve has
slope 1 at the point (0, 1).
19
Euler’s Method (2 of 11)
In other words, we could use the tangent line at (0, 1) as a rough approximation
to the solution curve (see Figure 11).
Since L(0.5) = 1.5, we have y(0.5) ≈ 1.5 and we take (0.5, 1.5) as the starting
point for a new line segment.
21
Euler’s Method (4 of 11)
The differential equation tells us that y (0.5) = 0.5 + 1.5 = 2, so we use the
linear function
y = 1.5 + 2 ( x − 0.5 ) = 2 x + 0.5
as an approximation to the solution for x > 0.5 (the green segment in Figure 12).
If we decrease the step size from 0.5 to 0.25, we get the better Euler
approximation shown in Figure 13.
22
Euler’s Method (5 of 11)
In general, Euler’s method says to start at the point given by the initial value
and proceed in the direction indicated by the direction field.
Stop after a short time, look at the slope at the new location, and proceed in
that direction.
23
Euler’s Method (6 of 11)
But by decreasing the step size (and therefore increasing the number of
midcourse corrections), we obtain successively better approximations to the
exact solution. (Compare Figures 11, 12, and 13.)
First Euler approximation Euler approximation with step size 0.5 Euler approximation with step size 0.25
Figure 11 Figure 12 Figure 13
y1 = y 0 + hF ( x0 , y 0 )
Similarly, y 2 = y1 + hF ( x1, y1 )
In general, y n = y n −1 + hF ( xn −1, y n −1 )
Figure 14
25
Euler’s Method (8 of 11)
Euler's Method Approximate values for the solution of the initial-value problem
y = F ( x, y ) , y ( x0 ) = y 0 , with step size h, at xn = xn−1 + h, are
y n = y n −1 + hF ( xn −1, y n −1 ) n = 1, 2, 3,
26
Example 3
Use Euler’s method with step size 0.1 to construct a table of approximate
values for the solution of the initial-value problem
y = x + y y (0) = 1
Solution:
We are given that h = 0.1, x0 = 0, y0 = 1, and F(x, y) = x + y. So we have
y1 = y 0 + hF ( x0 , y 0 ) = 1 + 0.1( 0 + 1) = 1.1
y 2 = y1 + hF ( x1, y1 ) = 1.1 + 0.1( 0.1 + 1.1) = 1.22
y 3 = y 2 + hF ( x2 , y 2 ) = 1.22 + 0.1( 0.2 + 1.22 ) = 1.362
This means that if y(x) is the exact solution, then y(0.3) ≈ 1.362.
27
Example 3 – Solution
Proceeding with similar calculations, we get the values in the table:
n xn yn n xn yn
1 0.1 1.100000 6 0.6 1.943122
2 0.2 1.220000 7 0.7 2.197434
3 0.3 1.362000 8 0.8 2.487178
4 0.4 1.528200 9 0.9 2.815895
5 0.5 1.721020 10 1.0 3.187485
28
Euler’s Method (9 of 11)
For a more accurate table of values in Example 3 we could decrease the step
size.
But for a large number of small steps the amount of computation is
considerable and so we need to program a calculator or computer to carry out
these calculations.
29
Euler’s Method (10 of 11)
The following table shows the results of applying Euler’s method with decreasing step
size to the initial-value problem of Example 3.
Step size Euler estimate of y(0.5) Euler estimate of y(1)
0.500 1.500000 2.500000
0.250 1.625000 2.882813
0.100 1.721020 3.187485
0.050 1.757789 3.306595
0.020 1.781212 3.383176
0.010 1.789264 3.409628
0.005 1.793337 3.423034
0.001 1.796619 3.433848
Notice that the Euler estimates in the table seem to be approaching limits, namely, the
true values of y(0.5) and y(1).
30
Euler’s Method (11 of 11)
Figure 15 shows graphs of the Euler approximations with step sizes 0.5, 0.25,
0.1, 0.05, 0.02, 0.01, and 0.005.
They are approaching the exact solution curve as the step size h approaches 0.
31