derivation - uplift web viewthe word "on" as a little optimistic—perhaps...

24
1 Derivation of Euler's Method - Numerical Methods for Solving Differential Equations Let’s start with a general first order Initial Value Problem dy dx =f ( x,y ) y ( x 0 ) =y 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 = x 0 . 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 = x 0 : 1. point (x 0 , y 0 ) an exact value, known to lie on the solution curve tangent line to the ghost (unknown) solution y = f(x) at x = x 0 : y=y 0 + f' ( x 0 ,y 0 )( xx 0 ) If x 1 is close enough to x 0 then the point y 1 on the tangent line should be fairly close to the actual value of the solution at x 1 , or y(x 1 ). 2. point (x 1 , y 1 ) y 1 =y 0 +f ( x 0 ,y 0 )( x 1 x 0 ) an approximate value of f(x 1 ) , lying on tangent line through (x o , y o ). 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, (x 1 , y 1 ), into the formula: slope of the solution = f (x,y) to get the slope of a pseudo-tangent line to the curve at (x 1 ,y 1 ). We hope that our approximate point, (x 1 ,y 1 ),

Upload: buinhi

Post on 06-Feb-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

1

Derivation of Euler's Method - Numerical Methods for Solving Differential Equations

Let’s start with a general first order Initial Value Problem

dydx

=f ( x , y ) y ( x0 )= y0(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 : y= y0+ f ' (x0 , y0)(x−x0) 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) y1= y0+ f (x0 , y 0)(x1−x0) 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) y2= y1+ f (x1 , y1)(x2−x1) an approximate value, lying on tangent line through (x1, y1).y= y1+ f (x1 , y1)(x−x1)

4. point (x3, y3) y3= y2+ f (x2 , y2)(x3−x2) an approximate value, lying on tangent line through (x2,y2).y= y2+ f (x2 , y2)(x−x2)

y= y0+ f (x0 , y0)(x−x0) y= y1+f ( x1 , y1)(x−x1)

y= y2+ f (x2 , y2)(x−x2)

y= y3+ f (x3 , y3)(x−x3)

Assuming that the step sizes are of uniform size: xn+1−xn=h

recursive formula for approximate points is:

Page 2: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

2

xn+1=xn+h

yn+1= yn+f nh f n=f (xn , yn)

Example

Solve the initial value problem: y′ = x + 2y, y(0) = 0 numerically (Euler), finding a value for the solution at x = 1, and using steps of size h = 0.25.

xn+1 = xn + hyn+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.218755. 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:

dydx

+P ( x ) y=Q (x ) → y e∫ Pdx=∫Q e∫ Pdx dx+C

dydx

−2 y=x→ y e∫−2 dx=∫ x e∫−2dx dx+C → y e−2x=∫ x e−2 x+C

y e−2 x=14

e−2x (−2x−1)+C → y=14(−2 x−1)+C e2x∧ y (0)=0 →C=1

4

y= 14

e2x+ 14(−2x−1)

Comparison of analytical (blue) and numerical solutions (red) with steps 0.25 and 0.02.

Page 3: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

3

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!

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 theslopes at points on the coordinate plane for a differential equation.

First a little review:

Consider : y=x2+3 y=x2−5 orthen : y '=2x y '=2 x

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:

Given : y '=2 x find y

y=x2+C

If we have some more information we can find C.

Given : y '=2 x∧ y=4 when x=1 , find theequation for y .

y=x2+C 4=1+CC=3y=x2+3

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.

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.

This is called an initial value problem. We need the initial values to find the constant.

draw a segment with a slope of 2

draw a segment with a slope of 0

draw a segment with a slope of 4

Page 4: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

4

Example : dydx

=xy y (0)=12

The particular (specific) solution, for the initial condition (0,1), has been superimposed as thesolid line on the field. Notice how the field’s lines match up with the solution’s curve. This iswhy slope fields are useful: they can show the shapes of the possible solutions (just follow theand connect the slope lines), as well as predict other values on the solution. Even though mostgraphing calculators can plot slope fields, you should know how to make them by hand. The APtest requires that you be able to identify what the slope field of a function looks like, without agraphing calculator. Making a slope field involves evaluating the differential equation at eachpoint.

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:

dyy

=xdx → ln y= x2

2+ ln C

ln yC

= x2

2→ y=C e

x2

2

for initial condition y (0)=12

,C=12

particular solution : y=12

ex2

2

y '=2 x

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.

y=x2+C is the family of solutions

y=x2−3 is the particular soulution

don’t panicthis is experience

Page 5: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

5

Example : Draw the slope field for diferential equation : dydx

=x y2

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:

Example: Match the following differential equations with their respective slope fields.

a¿ dydx

=x+ yb¿ dydx

=x− y2 c¿ dydx

=x (1− y )d¿ dydx

=−x √ y

Solution:

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:

Page 6: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

6

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 = ± √ x. The answers are 1c, 2a, 3d, 4b.

Example: 1. Sketch the slope field for the differential equation:

dydx

=0.25( y−1)(5− y )

2a. Describe (draw) the particular solution with the initial condition y(0)=62b. Describe (draw) the particular solution with the initial condition y(0)=52c. Describe (draw) the particular solution with the initial condition y(0)=32d. Describe (draw) the particular solution with the initial condition y(0)=12e. Describe (draw) the particular solution with the initial condition y(0)=0

1.

2a,c. 2b,d. 2e.

Page 7: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

7

SOLUTIONS:

1

2a. starting at the point (0, 6) will 2b. The trajectory starting at 2c. The trajectory starting at go down toward the line y = 5. the point (0, 5)will stay at the point (0, 3) will go up

along the line y = 5 toward the line y = 5

2d. The trajectory starting at the point (0, 1) 2e. The trajectory starting at the point (0, 0) will stay along the line y = 1 will go down toward – ∞

Page 8: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

8

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).

PROBLEMS:

Page 9: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

9

5. For the IVP (Initial value problem): y '+2 y=2−e−4 t y (0)=1

use Euler’s method with a step size of h = 0.1 to find approximate values of the solution att = 0.1, 0.2, 0.3, 0.4, and 0.5.Compare them to the exact values of the solution as these points using:

precent error=|exact−approximate|exact

×100 %

Solution of this linear differential equation is

y (t )=1+12

e−4 t−12

e−2 t

what could be checked by substitution into diff. eq. Conclusion about errors?

Page 10: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

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. dydx

=x+1 7. dydx

=2 y 8. dydx

=x+ y

9. dydx

=2x 10. dydx

= y−1 11. dydx

=− yx

Page 11: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

11

Match the slope fields with their differential equations.

12. dydx

=sin x 13. dydx

=x− y 14. dydx

=2− y15. dydx

=x

Match the slope fields with their differential equations.

16. dydx

=0.5 x−1 17. dydx

=0.5 y 18. dydx

=¿− xy

19. dydx

=x+ y

Page 12: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

12

20. The slope field from a certain differential equation is shown above. Which of the following could bea specific solution to that differential equation?

( A) y=x2(B) y=e x(C ) y=e−x (D) y=cos x (E) y=ln x

21. The slope field for a certain differential equation is shown below. Which of the following could be aspecific solution to that differential equation?

( A) y=sin x (B) y=cos x(C ) y=x2(D) y=16

x3(E) y=ln x

Page 13: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

13

22. Consider the differential equation given by dydx

= xy2

(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).

Page 14: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

14

(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.

23. Consider the differential equation given by dydx

= xy

(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.

Page 15: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

15

(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.

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 Approximation Exact Errort0 = 0 y0 =1 y(0) = 1 0 %

t1 = 0.1 y1 =0.9 y(0.1) = 0.925794646

2.79 %

t2 = 0.2 y2 =0.852967995 y(0.2) = 0.889504459

4.11 %

t3 = 0.3 y3 =0.837441500 y(0.3) = 0.876191288

4.42 %

t4 = 0.4 y4 =0.839833779 y(0.4) = 0.876283777

4.16 %

t5 = 0.5 y5 =0.851677371 y(0.5) = 0.883727921

3.63 %

Page 16: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

16

Page 17: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

17

Page 18: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

18

Page 19: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

19

Page 20: Derivation - Uplift Web viewthe word "on" as a little optimistic—perhaps "near" would be a more realistic word here.). ... Slope fields are a way to visualize a differential equation

20