Match the slope fields with their differential

advertisement
1
Derivation of Euler's Method - Numerical Methods for Solving Differential Equations
Let’s start with a general first order Initial Value Problem
𝑑𝑦
= 𝑓(π‘₯, 𝑦)
𝑦(π‘₯0 ) = 𝑦0
(1)
𝑑π‘₯
where f(x, y) is a known function and the values in the initial condition are also known numbers. If f is continuous
functions then there is a unique solution to the IVP in some interval surrounding x = x0 .
So, let’s assume that everything is nice and continuous so that we know that a solution will in fact exist.
We want to approximate the solution to (1) near x = x0 :
1. point (x0, y0) an exact value, known to lie on the solution curve
tangent line to the ghost (unknown) solution y = f(x) at x = x0 : 𝑦 = 𝑦0 + 𝑓′(π‘₯0 , 𝑦0 )(π‘₯ − π‘₯0 )
If x1 is close enough to x0 then the point y1 on the tangent
line should be fairly close to the actual value
of the solution at x1, or y(x1).
2. point (x1, y1) 𝑦1 = 𝑦0 + 𝑓(π‘₯0 , 𝑦0 )(π‘₯1 − π‘₯0 )
an approximate value of f(x1) , lying on tangent line
through (xo, yo).
If we want other points along the path of the true
solution, and yet we don't actually have the true
solution, then it looks like using the tangent line as an
approximation might be our best bet! After all, at
least on this picture, it looks like the line stays pretty close to the curve if you don't move too far away from
the initial point.
We must now attempt to continue our quest for points on the solution curve (though we're starting to see
the word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). So in hope that
we are going in the right direction we will construct pseudo-tangent line (pseudo: because it is not on the
actual solution). We will substitute our new point, (x1, y1), into the formula:
slope of the solution = f (x,y)
to get the slope of a pseudo-tangent line to the curve at (x1,y1). We hope that our approximate point, (x1,y1),
is close enough to the real solution that the pseudo-tangent line is pretty close to the unknown real tangent
line. Pattern for generating new points was established
3. point (x2, y2)
𝑦2 = 𝑦1 + 𝑓(π‘₯1 , 𝑦1 )(π‘₯2 − π‘₯1 ) an approximate value, lying on tangent line through (x1, y1).
𝑦 = 𝑦1 + 𝑓(π‘₯1 , 𝑦1 )(π‘₯ − π‘₯1 )
4. point (x3, y3)
𝑦3 = 𝑦2 + 𝑓(π‘₯2 , 𝑦2 )(π‘₯3 − π‘₯2 ) an approximate value, lying on tangent line through (x2,y2).
𝑦 = 𝑦2 + 𝑓(π‘₯2 , 𝑦2 )(π‘₯ − π‘₯2 )
𝑦 = 𝑦0 + 𝑓(π‘₯0 , 𝑦0 )(π‘₯ − π‘₯0 )
𝑦 = 𝑦1 + 𝑓(π‘₯1 , 𝑦1 )(π‘₯ − π‘₯1 )
𝑦 = 𝑦2 + 𝑓(π‘₯2 , 𝑦2 )(π‘₯ − π‘₯2 )
𝑦 = 𝑦3 + 𝑓(π‘₯3 , 𝑦3 )(π‘₯ − π‘₯3 )
Assuming that the step sizes are of uniform size:
π‘₯𝑛+1 − π‘₯𝑛 = β„Ž
recursive formula for approximate points is:
𝒙𝒏+𝟏 = 𝒙𝒏 + 𝒉
π’šπ’+𝟏 = π’šπ’ + 𝒇𝒏 𝒉
𝑓𝑛 = 𝑓(π‘₯𝑛 , 𝑦𝑛 )
2
Example
Solve the initial value problem: y′ = x + 2y,
1, and using steps of size h = 0.25.
y(0) = 0 numerically (Euler), finding a value for the solution at x =
xn+1 = xn + h
yn+1 = yn + h f(xn, yn)
1. point (0,0)
2. point (0.25, 0)
x1 = xo + h = 0.25
y1 = yo + h f(xo, yo) = yo + h (xo + 2yo) = 0 + 0.25 (0 + 2*0) = 0
3. point (0.5, 0.0625)
x2 = x1 + h = 0.5
y2 = y1 + h f (x1, y1) = y1 + h (x1 + 2y1) = 0 + 0.25 (0.25 + 2*0) = 0.0625
4. point (0.75, 0.21875)
x3 = x2 + h = 0.75
y3 = y2 + h f (x2, y2) = y2 + h (x2 + 2y2) = 0.0625+0.25 (0.5+2*0.0625) = 0.21875
5. point (1, 0.515625)
x4 = x3 + h = 1
y4 = y3 + h f (x3, y3) = y3 + h (x3 + 2y3)= 0.21875+0.25 (0.75+2*0.21875) = 0.515625
How accurate is this solution: NOT VERY!!!
Analytically: y′ = x + 2y,
𝑑𝑦
𝑑π‘₯
𝑑𝑦
𝑑π‘₯
y(0) = 0
linear differential equation of order 1:
+ 𝑃(π‘₯)𝑦 = 𝑄(π‘₯) →
𝑦 𝑒∫ 𝑃𝑑π‘₯ = ∫ 𝑄𝑒∫ 𝑃𝑑π‘₯ 𝑑π‘₯ + 𝐢
− 2𝑦 = π‘₯
𝑦 𝑒∫ −2𝑑π‘₯ = ∫ π‘₯𝑒∫ −2𝑑π‘₯ 𝑑π‘₯ + 𝐢 → 𝑦 𝑒−2π‘₯ = ∫ π‘₯ 𝑒−2π‘₯ + 𝐢
→
1
1
1
𝑦 𝑒 −2π‘₯ = 𝑒 −2π‘₯ (−2π‘₯ − 1) + 𝐢 → 𝑦 = (−2π‘₯ − 1) + 𝐢𝑒 2π‘₯ & 𝑦(0) = 0 → 𝐢 =
4
4
4
𝑦 =
1 2π‘₯ 1
𝑒 + (−2π‘₯ − 1)
4
4
Comparison of analytical (blue) and numerical solutions (red) with steps 0.25 and 0.02.
The numerical solution gets worse and worse as we move further to the right, and becomes more accurate with the
smaller steps. This method is one that truly belongs on a computer!
3
Slope Fields
Purpose: To graphically express a differential equation using slope fields.
Slope fields are a way to visualize a differential equation. It is simply a graph that shows the
slopes at points on the coordinate plane for a differential equation.
First a little review:
𝑦 = π‘₯2 + 3
πΆπ‘œπ‘›π‘ π‘–π‘‘π‘’π‘Ÿ:
𝑦 = π‘₯2 − 5
or
π‘‘β„Žπ‘’π‘›:
𝑦′ = 2π‘₯
𝑦′ = 2π‘₯
It doesn’t matter whether the constant was 3 or -5, since when we take the derivative the constant disappears.
However, when we try to reverse the operation:
𝐺𝑖𝑣𝑒𝑛:
𝑦′ = 2π‘₯
𝑓𝑖𝑛𝑑 𝑦
𝑦 = π‘₯2 + 𝐢
We don’t know what the constant is, so
we put “C” in the answer to remind us
that there might have been a constant.
If we have some more information
we can find C.
𝐺𝑖𝑣𝑒𝑛:
𝑦
4
𝐢
𝑦
𝑦′ = 2π‘₯
= π‘₯2 + 𝐢
= 1+𝐢
=3
= π‘₯2 + 3
π‘Žπ‘›π‘‘ 𝑦 = 4
π‘€β„Žπ‘’π‘› π‘₯ = 1 , 𝑓𝑖𝑛𝑑 π‘‘β„Žπ‘’ π‘’π‘žπ‘’π‘Žπ‘‘π‘–π‘œπ‘› π‘“π‘œπ‘Ÿ 𝑦.
This is called an initial value problem.
We need the initial values to find the
constant.
An equation containing a derivative is called a differential equation. It becomes an initial value problem when you
are given the initial condition and are asked to find the original equation.
Initial value problems and differential equations can be illustrated with a slope field.
Slope fields are mostly used as a learning tool and are mostly done on a computer or graphing calculator, but an AP
student could be asked to draw a simple one by hand.
draw a segment
with a slope of 0
draw a segment
with a slope of 2
draw a segment
with a slope of 4
4
𝑦′ = 2π‘₯
If you know an initial condition, such as (1,-2),
you can sketch the curve.
By following the slope field, you get a rough picture of what
the curve looks like.
In this case, it is a parabola.
𝑦 = π‘₯2 + 𝐢
𝑖𝑠 π‘‘β„Žπ‘’ π‘“π‘Žπ‘šπ‘–π‘™π‘¦ π‘œπ‘“ π‘ π‘œπ‘™π‘’π‘‘π‘–π‘œπ‘›π‘ 
𝑦 = π‘₯ 2 − 3 𝑖𝑠 π‘‘β„Žπ‘’ π‘π‘Žπ‘Ÿπ‘‘π‘–π‘π‘’π‘™π‘Žπ‘Ÿ π‘ π‘œπ‘’π‘™π‘’π‘‘π‘–π‘œπ‘›
𝐸π‘₯π‘Žπ‘šπ‘π‘™π‘’:
𝑑𝑦
𝑑π‘₯
= π‘₯𝑦
1
𝑦(0) = 2
Only special types of differential equations can be
solved analytically. In that case we don’t need
neither Euler’s method nor slope field.
Just for practice we chose the one that can be solved
analytically:
𝑑𝑦
= π‘₯ 𝑑π‘₯
𝑦
don’t panic
this is experience
→
𝑙𝑛 𝑦 =
π‘₯2
+ 𝑙𝑛 𝐢
2
π‘₯2
𝑦
π‘₯2
𝑙𝑛 =
→ 𝑦 = 𝐢𝑒 2
𝐢
2
1
1
π‘“π‘œπ‘Ÿ π‘–π‘›π‘–π‘‘π‘–π‘Žπ‘™ π‘π‘œπ‘›π‘‘π‘–π‘‘π‘–π‘œπ‘› 𝑦(0) = 2 , 𝐢 = 2
π‘π‘Žπ‘Ÿπ‘‘π‘–π‘π‘’π‘™π‘Žπ‘Ÿ π‘ π‘œπ‘™π‘’π‘‘π‘–π‘œπ‘›: 𝑦 =
1 π‘₯2
𝑒 2
2
The particular (specific) solution, for the initial condition (0,1), has been superimposed as the
solid line on the field. Notice how the field’s lines match up with the solution’s curve. This is
why slope fields are useful: they can show the shapes of the possible solutions (just follow the
and connect the slope lines), as well as predict other values on the solution. Even though most
graphing calculators can plot slope fields, you should know how to make them by hand. The AP
test requires that you be able to identify what the slope field of a function looks like, without a
graphing calculator. Making a slope field involves evaluating the differential equation at each
point.
5
𝐸π‘₯π‘Žπ‘šπ‘π‘™π‘’: π·π‘Ÿπ‘Žπ‘€ π‘‘β„Žπ‘’ π‘ π‘™π‘œπ‘π‘’ 𝑓𝑖𝑒𝑙𝑑 π‘“π‘œπ‘Ÿ π‘‘π‘–π‘“π‘’π‘Ÿπ‘’π‘›π‘‘π‘–π‘Žπ‘™ π‘’π‘žπ‘’π‘Žπ‘‘π‘–π‘œπ‘›:
𝑑𝑦
= π‘₯𝑦 2
𝑑π‘₯
Solution: Start off by making some observations about what the field should look like:
• On the axes, the slope is zero.
• Farther from the origin, the slopes are larger.
• In first and fourth quadrants, the slopes are positive.
• In the second and third quadrants, the slopes are negative.
Making observations like this will help you identify a slope field for a function.
Next, make a table of slope values, but for simpler functions like the one given, this can
usually be done in your head. Only a few slope values are shown here:
Now, you are ready to graph the field. Draw a short line segment with the
slope you calculated above for each of the points. The field should look
something like this:
Example: Match the following differential equations with their respective slope fields.
𝑑𝑦
𝑑𝑦
𝑑𝑦
𝑑𝑦
π‘Ž)
=π‘₯+𝑦
𝑏)
= π‘₯ − 𝑦2
𝑐)
= π‘₯(1 − 𝑦)
𝑑)
= −π‘₯√𝑦
𝑑π‘₯
𝑑π‘₯
𝑑π‘₯
𝑑π‘₯
Solution:
Since graph (3) is the only graph that does not exist below the x-axis, therefore, it must go with equation (d), which
has the square root. Graph (1) appears to have zero slope at y = 1, and at x = 0. The only equation to meet these
criteria is equation (c). Graph (2) appears to have zero slope along a diagonal y = −x. Equation (a) meets the
criterion in this case. The only one left is graph (4) and equation (b), which makes sense because the graph seems to
have zero slope along y = ± √π‘₯. The answers are 1c, 2a, 3d, 4b.
6
Example: 1. Sketch the slope field for the differential equation:
𝑑𝑦
= 0.25(𝑦 − 1)(5 − 𝑦)
𝑑π‘₯
2a. Describe (draw) the particular solution with the initial condition y(0)=6
2b. Describe (draw) the particular solution with the initial condition y(0)=5
2c. Describe (draw) the particular solution with the initial condition y(0)=3
2d. Describe (draw) the particular solution with the initial condition y(0)=1
2e. Describe (draw) the particular solution with the initial condition y(0)=0
1.
2a,c.
2b,d.
2e.
7
SOLUTIONS:
1
2a. starting at the point (0, 6) will
go down toward the line y = 5.
2b. The trajectory starting at
the point (0, 5)will stay
along the line y = 5
2d. The trajectory starting at the point (0, 1)
will stay along the line y = 1
2c. The trajectory starting at
at the point (0, 3) will go up
toward the line y = 5
2e. The trajectory starting at the point (0, 0)
will go down toward – ∞
8
PROBLEMS:
1. Use Euler’s method with the step size 0.1
to approximate y(1) where y(x) is the solution
of the initial-value problem y’= x+y, y(0)=1.
2. Use Euler’s method with the step size 0.2
to approximate y(2) where y(x) is the solution
of the initial-value problem y’= y- e-x , y(0) = 1.
3. Use Euler’s method with the step size 0.1
to approximate y(1) where y(x) is the solution
of the initial-value problem y’= sin(x+y), y(0) = 0.
4. Use Euler’s method with the step size 0.5
to approximate the size of fish population
at time t = 5 where time t is measured in
weeks if there are 4 fish initially and the size
of the population is changing according
to the equation y’ = - 0.045y(y-20).
9
5. For the IVP (Initial value problem):
𝑦′ + 2𝑦 = 2 − 𝑒 −4𝑑
𝑦(0) = 1
use Euler’s method with a step size of h = 0.1
to find approximate values of the solution at
t = 0.1, 0.2, 0.3, 0.4, and 0.5.
Compare them to the exact values of the
solution as these points using:
π‘π‘Ÿπ‘’π‘π‘’π‘›π‘‘ π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ =
|𝑒π‘₯π‘Žπ‘π‘‘ − π‘Žπ‘π‘π‘Ÿπ‘œπ‘₯π‘–π‘šπ‘Žπ‘‘π‘’|
× 100%
𝑒π‘₯π‘Žπ‘π‘‘
Solution of this linear differential equation is
1
1
𝑦(𝑑) = 1 + 𝑒 −4𝑑 − 𝑒 −2𝑑
2
2
what could be checked by substitution
into diff. eq. Conclusion about errors?
10
Slope Fields (Nancy Stephenson Clements High School Sugar Land, Texas)
6. – 11. Draw a slope field for each of the following differential equations. Each tick mark is one unit.
6.
𝑑𝑦
= π‘₯+1
𝑑π‘₯
9.
𝑑𝑦
= 2π‘₯
𝑑π‘₯
7.
10.
𝑑𝑦
= 2𝑦
𝑑π‘₯
𝑑𝑦
= 𝑦 −1
𝑑π‘₯
8.
𝑑𝑦
=π‘₯+𝑦
𝑑π‘₯
11.
𝑑𝑦
𝑦
=−
𝑑π‘₯
π‘₯
11
Match the slope fields with their differential equations.
12.
𝑑𝑦
= 𝑠𝑖𝑛 π‘₯
𝑑π‘₯
13.
𝑑𝑦
=π‘₯−𝑦
𝑑π‘₯
14.
𝑑𝑦
=2−𝑦
𝑑π‘₯
15.
𝑑𝑦
=π‘₯
𝑑π‘₯
Match the slope fields with their differential equations.
𝑑𝑦
16. 𝑑π‘₯ = 0.5π‘₯ − 1
𝑑𝑦
17. 𝑑π‘₯ = 0.5𝑦
𝑑𝑦
π‘₯
18. 𝑑π‘₯ == − 𝑦
𝑑𝑦
19. 𝑑π‘₯ = π‘₯ + 𝑦
12
20. The slope field from a certain differential equation is shown above. Which of the following could be
a specific solution to that differential equation?
(𝐴) 𝑦 = π‘₯ 2
(𝐡) 𝑦 = 𝑒 π‘₯
(𝐢) 𝑦 = 𝑒 −π‘₯
(𝐷) 𝑦 = π‘π‘œπ‘  π‘₯
(𝐸) 𝑦 = 𝑙𝑛 π‘₯
21. The slope field for a certain differential equation is shown below. Which of the following could be a
specific solution to that differential equation?
(𝐴) 𝑦 = 𝑠𝑖𝑛 π‘₯
(𝐡) 𝑦 = π‘π‘œπ‘  π‘₯
(𝐢) 𝑦 = π‘₯ 2
1
(𝐷) 𝑦 = π‘₯ 3
6
(𝐸) 𝑦 = 𝑙𝑛 π‘₯
13
𝑑𝑦
π‘₯𝑦
22. Consider the differential equation given by 𝑑π‘₯ = 2
(A) On the axes provided, sketch a slope field for the given differential equation.
(B) Let f be the function that satisfies the given differential equation. Write an equation for the tangent line to the
curve y = f (x) through the point (1, 1). Then use your tangent line equation to estimate the value of f (1.2).
(C) Find the particular solution y = f (x) to the differential equation with the initial condition f (1) =1. Use your
solution to find f (1.2).
(D) Compare your estimate of f (1.2) found in part (b) to the actual value of f (1.2) found in part (E) Was your
estimate from part (b) an underestimate or an overestimate? Use your slope field to explain why.
14
𝑑𝑦
π‘₯
23. Consider the differential equation given by 𝑑π‘₯ = 𝑦
(A) On the axes provided, sketch a slope field for the given differential equation.
(B) Sketch a solution curve that passes through the point (0, 1) on your slope field.
(C) Find the particular solution y = f (x) to the differential equation with the initial condition f (0) =1.
(D) Sketch a solution curve that passes through the point (0, −1) on your slope field.
(E) Find the particular solution y = f (x) to the differential equation with the initial condition f (0) = −1.
15
Solutions: 1. y(1)=3.187
2. y(2) = 3.014
3. y(1) = 0.501
4. y(5) = 19.42. Thus, there is approximately 19 fish after 5 weeks.
5. the error is clearly getting much worse as t increases.
Time, tn
t0 = 0
t1 = 0.1
t2 = 0.2
t3 = 0.3
t4 = 0.4
t5 = 0.5
Approximation
y0 =1
y1 =0.9
y2 =0.852967995
y3 =0.837441500
y4 =0.839833779
y5 =0.851677371
Exact
y(0) = 1
y(0.1) = 0.925794646
y(0.2) = 0.889504459
y(0.3) = 0.876191288
y(0.4) = 0.876283777
y(0.5) = 0.883727921
Error
0%
2.79 %
4.11 %
4.42 %
4.16 %
3.63 %
16
17
18
19
20
Download