Transcript PPT
Euler Method Industrial Engineering Majors Authors: Autar Kaw, Charlie Barker http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates 7/12/2016 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 The open loop response, that is, the speed of the motor to a voltage input of 20 V, assuming a system without damping is 20 0.02 dw 0.06w dt If the initial speed is zero w0 0 , and using Euler’s method, what is the speed at t 0.8 s ? Assume a step size of h 0.4 s. dw 1000 3w dt f t , w 1000 3w wi 1 wi f ti , wi h 6 http://numericalmethods.eng.usf.edu Solution Step 1: For i 0, t0 0, w0 0 w1 w0 f t0 , w0 h 0 f 0,0 0.4 0 1000 300.4 0 1000 0.4 400 rad/s w1 is the approximate speed of the motor at t t1 t0 h 0 0.4 0.4 s w0.4 w1 400 rad/s 7 http://numericalmethods.eng.usf.edu Solution Cont Step 2: For i 1, t1 0.4, w2 400 w2 w1 f t1 , w1 h 400 f 0.4, 400 0.4 400 1000 3400 0.4 400 200 0.4 320 rad/s w2 is the approximate speed of the motor at t t2 t1 h 0.4 0.4 0.8 s x0.8 w2 320 rad/s 8 http://numericalmethods.eng.usf.edu Solution Cont The exact solution of the ordinary differential equation is given by 1000 1000 3t wt e 3 3 The solution to this nonlinear equation at t = 0.8 s is w0.8 303.09 rad/s 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 Speed of motor at 0.8 seconds as a function of step size, h 11 Step size, h w0.8 Et |t | % 0.8 0.4 0.2 0.1 0.05 800 320 324.8 314.18 308.58 −496.91 −16.906 −21.706 −11.023 −5.4890 163.95 5.5778 7.1615 3.6370 1.8110 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