4 Slope Fields, Solution Curves, and Euler’s Method

advertisement
4
Slope Fields, Solution Curves, and Euler’s Method
You may recall from calculus that it is not always possible to evaluate an integral
symbolically. For example, the integral
Z
Here the term elementary functions
refers to polynomials, exponentials,
logarithms, trigonometric functions,
inverse trigonometric functions, and
combinations thereof.
Of course, y 0 = sin x2 is itself a
differential equation whose solutions
can’t be written using elementary
formulas.
sin x2 dx
cannot be expressed as a formula involving
elementary functions—there simply isn’t a
formula whose derivative is sin x2 .
Of course, this doesn’t mean that we can’t integrate sin x2 . The antiderivative
still exists. We can graph it, and we can evaluate it numerically using approximate
methods. We just can’t write a formula for it that doesn’t involve an integral.
The same thing happens with differential equations: even if a solution exists, there
might no be way to express it as a formula. For example, the equation
y 0 = x3 + y 3
has plenty of solutions, but none of these solutions can be written as a formula involving
elementary functions. If we want to solve this differential equation, we must resort to
either numerical or graphical methods.
Explicit Equations
But how can we possibly know that a differential equation has a solution if we can’t
find a formula for it? Well, consider again the equation
y 0 = x3 + y 3 .
There is a simple intuitive argument that this differential equation must have a solution.
Imagine an object moving vertically, whose vertical position y changes with time. In
this case, the equation
This is the same as the last equation,
except that we have renamed x to t.
dy
= t3 + y 3
dt
can be thought of as instructions for how to move the object. Specifically, this equation
says what the velocity of the object should be in terms of the time t and the vertical
position y. If we just move the object according to these instructions, we will obtain a
position function y(t), which must be a solution to this differential equation.
This same reasoning applies to any differential equation of the form
y 0 = F (x, y),
Almost every differential equation that
arises in science is explicit.
where F (x, y) is any expression involving x and y. A differential equation of this form
is said to be explicit, and can be thought of as a set of instructions for how quickly
y should change in terms of x and y. Intuitively, we expect that any explicit equation
should have at least one solution. Indeed, we expect that any initial value problem of
the form
y 0 = F (x, y),
y(a) = b
should have a uniquely determined solution.
The following theorem makes this intuition rigorous.
SLOPE FIELDS, SOLUTION CURVES, AND EULER’S METHOD
2
EXISTENCE AND UNIQUENESS OF SOLUTIONS
Consider an initial value problem of the form
y 0 = F (x, y),
y(a) = b.
Assuming the partial derivatives of the function F exist and are continuous, this
initial value problem has a uniquely determined solution.
In case you aren’t familiar with partial derivatives (which are normally covered in
a vector calculus course), the important thing to understand here is that the initial
value problem
y 0 = F (x, y),
y(a) = b.
usually has a uniquely determined solution, and there’s a fairly simple test we can use
to make sure.
Slope Fields and Solution Curves
1.5
One way to understand a differential equation is to draw graphs of its solutions. These
graphs are curves in the xy-plane, and are known as solution curves.
There is a nice way to figure out the geometry of the solution curves directly from
the differential equation. For example, consider the equation:
1.0
y 0 = (x − 1)2 − y 2 .
0.5
0.5
1.0
1.5
2.0
2.5
Figure 1: Slope field for the equation y 0 = (x − 1)2 − y 2 .
We can interpret this equation as a formula for the slope y 0 of the solution curve in
terms of x and y. For example, if a solution curve for this equation goes through the
point (4, 2), its slope at that point must be 5, since plugging in x = 4 and y = 2 into
the differential equation gives y 0 = 5.
We can visualize this information by drawing small line segments with the appropriate slopes at various points in the xy-plane, as shown in Figure 1. This picture is
called a slope field, and was drawn using the following procedure:
1.5
1. First, an array of x and y values were chosen. In this case, the x-values were
0.0, 0.1, 0.2, . . . , 2.5, and the y-values were 0.0, 0.1, 0.2, . . . , 1.5.
1.0
2. For each (x, y) pair, the slope y 0 was computed using the equation
y 0 = (x − 1)2 − y 2 .
0.5
0.5
1.0
1.5
2.0
2.5
Figure 2: Three solutions to this
equation.
1.5
1.0
0.5
0.5
1.0
1.5
2.0
2.5
Figure 3: The solution for which
y(0) = 1.
3. At each point (x, y), a small line segment was drawn with the computed slope.
We can think of a slope field as a picture of a differential equation, in the sense that
it contains the same information that the differential equation does. The solutions to
a differential equation are curves that follow the slopes of the slope field, as shown in
Figure 2.
By the way, we can understand an initial condition graphically as a point on the
plane that the solution curve must go through. For example, the solution to the initial
value problem
y 0 = (x − 1)2 − y 2 ,
y(0) = 1
is shown in Figure 3. As you can see, the initial condition y(0) = 1 corresponds to
the fact that the solution curve goes through the point (0, 1). Intuitively, the solution
to this initial value problem can be obtained by starting at the point (0, 1) and then
“following the slopes” to obtain a solution curve.
SLOPE FIELDS, SOLUTION CURVES, AND EULER’S METHOD
3
EXAMPLE 1 Recall that the logistic equation is the differential equation
dP
P
= kP 1 −
dt
Pmax
P
Pmax
t
Figure 4: Slope field and solution
curves for the logistic equation.
where k and Pmax are constants. This equation can be used to modeled the growth of
a population in an environment with a finite carrying capacity Pmax .
A typical slope field for the logistic equation is shown in Figure 4. Several solutions
to the equation are also shown. Note that the slopes point up if P < Pmax and down
if P > Pmax , so in either case the population approaches the carrying capacity. (The
case where P > Pmax corresponds to a situation where the population is too high to be
sustainable.)
By the way, observe that the slopes for this equation are the same on each horizontal line. This is because the formula for dP/dt depends on P only, with no explicit
dependence on the variable t.
Based on the pictures so far, you might have noticed a few important properties
of the solution curves for a differential equation. For example, Figure 5 shows several
different solution curves for the equation
1.4
1.2
1.0
y 0 = (x − 1)2 − y 2 .
0.8
0.6
0.4
These curves have the following properties:
0.2
0.0
0.0
0.5
1.0
1.5
2.0
2.5
Figure 5: Solution curves for the
equation y 0 = (x − 1)2 − y 2 .
1. The curves entirely fill the plane, in the sense that each point of the plane
has a solution curve going through it. This is because any point in the plane can
be thought of as an initial condition, which means that it lies on the solution
curve for the corresponding initial value problem.
2. No two of the curves intersect, i.e. each point on the plane is contained
in only one curve. This is because of the uniqueness of solutions—each point
can be thought of as an initial condition, and there should only be one solution
corresponding to a given initial condition.
These properties are typical for the solutions to explicit first-order differential equations.
Euler’s Method
Euler’s method is a simple numerical method that can be used to approximate the
solutions to explicit first-order equations. Given an initial value problem
y 0 = (x − 1)2 − y 2 ,
y(0) = 0.5,
the idea is to estimate the values of y and y 0 at several successive values of x:
x
0.0
0.5
1.0
1.5
2.0
2.5
y
0.5
?
?
?
?
?
?
?
?
?
?
?
y
The choice of ∆x = 0.5 is arbitrary.
As we shall see, choosing a smaller
value of ∆x would improve accuracy
but also make the computation longer.
0
As you can see, we have chosen to use values of x that are spaced ∆x = 0.5 apart.
First, we compute the initial value of y 0 by plugging x = 0.0 and y = 0.5 into the
differential equation:
y 0 = (0.0 − 1)2 − (0.5)2 = 0.75.
SLOPE FIELDS, SOLUTION CURVES, AND EULER’S METHOD
4
We fill this value into the table:
x
0.0
0.5
1.0
1.5
2.0
2.5
y
0.5
?
?
?
?
?
0.75
?
?
?
?
?
y
0
Next we use a linear approximation to estimate the next value of y. That is, we use
the computed value of y 0 to estimate the slope ∆y/∆x:
∆y
≈ y0
∆x
Be careful not to confuse ∆y with y.
After we figure out that ∆y ≈ 0.375,
we must add this to the old value of y
(which was 0.5) to get the new value
of y (namely 0.875).
∆y
≈ 0.75.
0.5
so
Solving gives ∆y ≈ 0.375, and we add this to the old value of y to get the new value:
x
0.0
0.5
1.0
1.5
2.0
2.5
y
0.5
0.875
?
?
?
?
0.75
?
?
?
?
?
y
0
Now, because x and y have changed, the value of y 0 has also changed. We compute the
new value of y 0
y 0 = (0.5 − 1)2 − (0.875)2 ≈ −0.5156
and fill it in:
x
0.0
0.5
1.0
1.5
2.0
2.5
y
0.5
0.875
?
?
?
?
0.75
−0.5156
?
?
?
?
y
Be careful not to confuse ∆x with x.
Although each column has a different
x value, the value of ∆x is 0.5 for this
entire computation.
0
The process just repeats from here. We have
∆y
≈ y0
∆x
∆y
≈ −0.5156.
0.5
so
which gives ∆y ≈ −0.2578. Adding this to the previous value of y (the 0.875)
gives 0.6172, which we fill into the table:
x
0.0
0.5
1.0
1.5
2.0
2.5
y
0.5
0.875
0.6172
?
?
?
0.75
−0.5156
?
?
?
?
y
0
We repeat this process three more times to finish off the table:
Since the goal is to estimate values
for y, there is no need to compute the
value of y 0 in the last column.
x
0.0
0.5
y
0.5
0.875
0.75
−0.5156
y
0
1.0
1.5
2.0
2.5
0.6172
0.4267
0.4607
0.8546
−0.3809
0.0679
0.7878
—
EULER’S METHOD
Euler’s method involves repeating the following process, starting with the initial
values of x and y:
1. Use the differential equation to compute the value of y 0 .
∆y
2. Use the approximation y 0 ≈
to estimate ∆y.
∆x
3. Add ∆y to the old value of y to obtain the new value of y, and then go back to
step 1.
SLOPE FIELDS, SOLUTION CURVES, AND EULER’S METHOD
5
Further Numerical Methods
Euler’s method is only the simplest method for approximating solutions to differential
equations. Finding better ways of approximating solutions is an ongoing subject of research,
and is one of the primary questions in 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 the
slope seems roughly constant.
Modern computer algebra systems such as Mathematica and Sage 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.
1.5
1.0
0.5
0.5
1.0
1.5
2.0
2.5
Figure 6: Euler’s method with
∆x = 0.5.
By the way, this method should remind you of numerical methods for computing
integrals by adding up the areas of vertical rectangles. Indeed, in the special case where
the differential equation has the form
y 0 = f (x)
1.5
this method is essentially identical to the Left Endpoint Rule for approximating an
integral. In general, though, Euler’s method works a bit differently than a Riemann
sum because of its recursive nature: we must use the results of each column to compute
the numbers in the next column.
1.0
0.5
The Geometry of Euler’s Method
0.5
1.0
1.5
2.0
2.5
Figure 7: Euler’s method with
∆x = 0.25.
When we use Euler’s method, we are essentially approximating the solution curve by
a straight line between successive values of x. For example, Figure 6 shows Euler’s
method for the example above, i.e. the initial value problem
y 0 = (x − 1)2 − y 2 ,
1.5
1.0
0.5
0.5
1.0
1.5
2.0
2.5
Figure 8: Euler’s method with
∆x = 0.01.
y(0) = 0.5
with ∆x = 0.5. The six marked points are the points that we computed, and the
straight lines represent the linear approximations that we used for the estimation.
Note that the slope of each straight line is correct on its left end, but becomes less and
less correct as we move right towards the next x-value.
We can improve the accuracy of Euler’s method by using a smaller step size. For
example, Figure 7 shows Euler’s method applied to the same initial value problem using
a step size of ∆x = 0.25, and Figure 8 shows a step size of ∆x = 0.01. For the step
size of 0.01, all of the y-values are accurate to within 0.004, which is about a fourth of
the width of the red line that we’re using for the graph.
EXERCISES
1. Consider the following initial value problem:
y 0 = x2 − y 3 ,
y(0) = 1.
Use Euler’s method with a step size of 0.2 to estimate y(1).
2. Consider the following initial value problem:
y 0 = xy − 2,
y(2) = 1.
Use Euler’s method with a step size of 0.5 to estimate y(4).
SLOPE FIELDS, SOLUTION CURVES, AND EULER’S METHOD
3. A ball is dropped from the top of a tall building. If air
resistance is taken into account, the downward velocity v of
the ball is modeled by the differential equation
dv
= g − kv 2
dt
where g = 9.8 m/s2 , and k = 0.1/m. Assuming the initial
velocity of the ball is zero, use Euler’s method with a step
size of 0.25 seconds to estimate the velocity of the ball after
one second.
4. The following picture shows the slope field for a certain
explicit first-order equation
2.0
6
2.0
2.0
1.5
1.5
1.0
1.0
0.5
0.5
0.0
0.0
0.0
0.5
1.0
1.5
2.0
0.0
0.5
(III)
1.0
1.5
2.0
(IV)
6. y 0 = xy
7. y 0 = x2 + y 2
8. y 0 = x2 − y 2
9. y 0 = y − x2
10–13
Match each differential equation with the
corresponding solution curve.
1.5
3.0
3.0
2.5
2.5
2.0
2.0
1.5
1.5
1.0
1.0
0.5
0.5
1.0
0.5
0.5
1.0
1.5
2.0
2.5
3.0
0.0
0.0
(a) Use this slope field to sketch the solution curve
satisfying y(0) = 1.
0.5
1.0
1.5
2.0
2.5
3.0
0.0
0.0
0.5
1.0
(I)
(b) Given that y(0) = 1, use your answer to part (a) to
estimate the value of y(3).
5. Consider the following differential equation.


−1 if x < 1,
y0 =
0 if 1 ≤ x ≤ 2,


1 if x > 2.
(a) Sketch the slope field for this equation. Your sketch
should include the range 0 ≤ x ≤ 4 and 0 ≤ y ≤ 3.
3.0
3.0
2.5
2.5
2.0
2.0
1.5
1.5
1.0
1.0
0.5
0.5
0.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
0.0
0.0
0.5
1.0
(III)
2.0
2.0
1.5
1.5
1.0
1.0
0.5
0.5
0.0
0.0
0.0
0.5
1.0
(I)
1.5
2.0
0.0
0.5
1.0
(II)
1.5
2.0
1.5
(IV)
(b) Given that y(0) = 1.5, find the value of y(4).
6–9
Match each differential equation with the corresponding
slope field.
1.5
2.0
2.5
3.0
2.0
2.5
3.0
(II)
10. y 0 = sin(xy)
11. y 0 = x − y 3
12. y 0 = e−xy
13. y 0 = cos(xy)
Answers
x
1. y
0.0
0.2
1
0.8
0.4
0.6
0.8
1.0
−1 −0.472 −0.1913 0.0628 0.3257
x
2.0 2.5
2. y
1
y0
0
1
3.0
3.5
4.0
1.25
2.125
4.8438
0.5 1.75 5.4375
t
0.00
0.25
v
0
2.45
dv/dt
9.8
3.
4. (a)
so y(1) ≈ 0.745.
0.7056 0.6673 0.6799 0.7450
y0
—
so y(4) ≈ 4.844.
—
0.50
0.75
1.00
so v(1) ≈ 7.985 m/s.
4.7499 6.6359 7.9850
9.1998 7.5438 5.3965
2.0
—
(b) y(3) is somewhere between 0 and 0.5.
1.5
1.0
0.5
0.5
1.0
1.5
2.0
2.5
3.0
3.0
5. (a)
3.0
(b)
2.5
2.0
2.0
1.5
1.5
1.0
y(4) = 2.5
2.5
1.0
0.5
0.5
0.0
0
6. III
7. IV
1
2
8. II
3
9. I
4
10. III
1
11. II
12. IV
2
3
13. I
4
Download