Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Euler Method Civil Engineering Majors Authors: Autar Kaw, Charlie Barker http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates 5/23/2017 http://numericalmethods.eng.usf.edu 1 Euler Method http://numericalmethods.eng.usf.edu Euler’s Method y dy f x, y , y 0 y 0 dx Slope Rise Run y1 y0 x1 x0 f x0 , y 0 y1 y0 f x0 , y0 x1 x0 y0 f x0 , y0 h 3 True value Φ x0,y0 y1, Predicted value Step size, h x Figure 1 Graphical interpretation of the first step of Euler’s method http://numericalmethods.eng.usf.edu Euler’s Method y yi 1 yi f xi , yi h True Value h xi 1 xi yi+1, Predicted value Φ yi h Step size xi xi+1 x Figure 2. General graphical interpretation of Euler’s method 4 http://numericalmethods.eng.usf.edu How to write Ordinary Differential Equation How does one write a first order differential equation in the form of dy f x, y dx Example dy 2 y 1.3e x , y 0 5 dx is rewritten as dy 1.3e x 2 y, y 0 5 dx In this case f x, y 1.3e x 2 y 5 http://numericalmethods.eng.usf.edu Example A polluted lake with an initial concentration of a bacteria is 107 parts/m3, while the acceptable level is only 5×106 parts/m3. The concentration of the bacteria will reduce as fresh water enters the lake. The differential equation that governs the concentration C of the pollutant as a function of time (in weeks) is given by dC 0.06C 0, C (0) 107 dt Find the concentration of the pollutant after 7 weeks. Take a step size of 3.5 weeks. dC dt 0.06C f t , C 0.06C Ci 1 Ci f t i , Ci h 6 http://numericalmethods.eng.usf.edu Solution Step 1: For i 0, t0 0, C0 107 C1 C0 f t0 , C0 h 107 f 0, 107 3.5 6 10 3.5 107 0.06 107 3.5 107 5 7.9 106 parts / m3 C1 is the approximate concentration of bacteria at t t1 t0 h 0 3.5 3.5 weeks C 3.5 C1 7.9 106 parts/m 3 7 http://numericalmethods.eng.usf.edu Solution Cont Step 2: For i 1, t1 3.5, C1 7.9 106 C2 C1 f t1 , C1 h 0.067.9 10 3.5 4.74 10 3.5 7.9 106 f 3.5, 7.9 106 3.5 7.9 106 7.9 106 6 5 6.241106 parts/m 3 C2 is the approximate concentration of bacteria at t t2 t1 h 3.5 3.5 7 weeks C 7 C2 6.241106 parts/m 3 8 http://numericalmethods.eng.usf.edu Solution Cont The exact solution of the ordinary differential equation is given by the solution of a non-linear equation as C (t ) 1 107 e 3t 50 The solution to this nonlinear equation at t=7 weeks is C (7) 6.5705 106 parts/m 3 9 http://numericalmethods.eng.usf.edu Comparison of Exact and Numerical Solutions Figure 3. Comparing exact and Euler’s method 10 http://numericalmethods.eng.usf.edu Effect of step size Table 1 Concentration of bacteria after 7 weeks as a function of step size Step size h 7 3.5 1.75 0.875 0.4375 11 C7 5.8×106 6.241×106 6.4164×106 6.4959×106 6.5337×106 Et 770470 329470 154060 74652 36763 |t | % 11.726 5.0144 2.3447 1.1362 0.55952 http://numericalmethods.eng.usf.edu Comparison with exact results Figure 4. Comparison of Euler’s method with exact solution for different step sizes 12 http://numericalmethods.eng.usf.edu Effects of step size on Euler’s Method Figure 5. Effect of step size in Euler’s method. 13 http://numericalmethods.eng.usf.edu Errors in Euler’s Method It can be seen that Euler’s method has large errors. This can be illustrated using Taylor series. dy 1 d2y 1 d3y 2 3 xi 1 xi y i 1 y i x x x x ... i 1 i i 1 i 2 3 dx xi , yi 2! dx x , y 3! dx x , y i yi 1 yi f ( xi , yi )xi 1 xi i i i 1 1 2 3 f ' ( xi , yi )xi 1 xi f ' ' ( xi , yi )xi 1 xi ... 2! 3! As you can see the first two terms of the Taylor series yi 1 yi f xi , yi h are the Euler’s method. The true error in the approximation is given by Et 14 f xi , yi 2 f xi , yi 3 h h ... 2! 3! Et h 2 http://numericalmethods.eng.usf.edu Additional Resources For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/euler_meth od.html THE END http://numericalmethods.eng.usf.edu