1 Derivation of Euler's Method

1 Derivation of Euler's Method

1 Derivation of Euler's Method - Numerical Methods for Solving Differential Equations Let’s start with a general first order Initial Value Problem 푑푦 = 푓(푥, 푦) 푦(푥 ) = 푦 (1) 푑푥 0 0 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, 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 + 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 1 푦 = 푒2푥 + (−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푥 푓푛푑 푦 We don’t know what the constant is, so 푦 = 푥2 + 퐶 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. 퐺푣푒푛: 푦′ = 2푥 푎푛푑 푦 = 4 푤ℎ푒푛 푥 = 1 , 푓푛푑 푡ℎ푒 푒푞푢푎푡표푛 푓표푟 푦. 2 푦 = 푥 + 퐶 This is called an initial value problem. 4 = 1 + 퐶 We need the initial values to find the 퐶 = 3 constant. 푦 = 푥2 + 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. 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 Only special types of differential equations can be 퐸푥푎푚푝푙푒: = 푥푦 푦(0) = 푑푥 2 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 푥2 1 푝푎푟푡푐푢푙푎푟 푠표푙푢푡표푛: 푦 = 푒 2 2 The particular (specific) solution, for the initial condition (0,½), 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 = ± √푥.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us