Download presentation
Presentation is loading. Please wait.
Published byGinger Davidson Modified over 9 years ago
1
CSE 330 : Numerical Methods Lecture 17: Solution of Ordinary Differential Equations (a) Euler’s Method (b) Runge-Kutta Method Dr. S. M. Lutful Kabir Visiting Research Professor, BRAC University & Professor (on leave) IICT, BUET 1 Prof. S. M. Lutful Kabir, BRAC University
2
Euler’s Method Φ Step size, h x y x 0,y 0 True value y 1, Predicted value Slope Figure 1 Graphical interpretation of the first step of Euler’s method Prof. S. M. Lutful Kabir, BRAC University2
3
Euler’s Method Φ Step size h True Value y i+1, Predicted value yiyi x y xixi x i+1 Figure 2. General graphical interpretation of Euler’s method Prof. S. M. Lutful Kabir, BRAC University3
4
How to write Ordinary Differential Equation Example is rewritten as In this case How does one write a first order differential equation in the form of Prof. S. M. Lutful Kabir, BRAC University 4
5
Example A ball at 1200K is allowed to cool down in air at an ambient temperature of 300K. Assuming heat is lost only due to radiation, the differential equation for the temperature of the ball is given by Find the temperature at seconds using Euler’s method. Assume a step size of seconds. Prof. S. M. Lutful Kabir, BRAC University5
6
Solution Step 1: is the approximate temperature at Prof. S. M. Lutful Kabir, BRAC University6
7
Solution Cont For Step 2: is the approximate temperature at Prof. S. M. Lutful Kabir, BRAC University7
8
Solution Cont The exact solution of the ordinary differential equation is given by the solution of a non-linear equation as The solution to this nonlinear equation at t=480 seconds is Prof. S. M. Lutful Kabir, BRAC University8
9
Comparison of Exact and Numerical Solutions Figure 3. Comparing exact and Euler’s method Prof. S. M. Lutful Kabir, BRAC University9
10
Step, h (480) EtEt |є t |% 480 240 120 60 30 −987.81 110.32 546.77 614.97 632.77 1635.4 537.26 100.80 32.607 14.806 252.54 82.964 15.566 5.0352 2.2864 Effect of step size Table 1. Temperature at 480 seconds as a function of step size, h (exact) Prof. S. M. Lutful Kabir, BRAC University10
11
Comparison with exact results Figure 4. Comparison of Euler’s method with exact solution for different step sizes Prof. S. M. Lutful Kabir, BRAC University11
12
Effects of step size on Euler’s Method Figure 5. Effect of step size in Euler’s method. Prof. S. M. Lutful Kabir, BRAC University12
13
Errors in Euler’s Method It can be seen that Euler’s method has large errors. This can be illustrated using Taylor series. As you can see the first two terms of the Taylor series The true error in the approximation is given by are the Euler’s method. Prof. S. M. Lutful Kabir, BRAC University13
14
Runge Kutta 2 nd Order Method Runge Kutta thought to consider upto second derivative terms in Taylor’s series In that case the Eular’s Method will be extended to But finding the second derivative is sometimes difficult Hence they used the average of two approximate slopes as follows: where, 14Prof. S. M. Lutful Kabir, BRAC University
15
Runge Kutta Method (Heun’s Method) x y xixi x i+1 y i+1, predicted y i Figure 1 Runge-Kutta 2nd order method (Heun’s method) Prof. S. M. Lutful Kabir, BRAC University15
16
Example A ball at 1200K is allowed to cool down in air at an ambient temperature of 300K. Assuming heat is lost only due to radiation, the differential equation for the temperature of the ball is given by Find the temperature at seconds using Heun’s method. Assume a step size of seconds. Prof. S. M. Lutful Kabir, BRAC University16
17
Solution Step 1: Prof. S. M. Lutful Kabir, BRAC University17
18
Solution Cont Step 2: Prof. S. M. Lutful Kabir, BRAC University18
19
Comparison with exact results Figure 2. Heun’s method results for different step sizes Prof. S. M. Lutful Kabir, BRAC University19
20
Effect of step size Table 1. Temperature at 480 seconds as a function of step size, h Step size, h (480) EtEt |є t |% 480 240 120 60 30 −393.87 584.27 651.35 649.91 648.21 1041.4 63.304 −3.7762 −2.3406 −0.63219 160.82 9.7756 0.58313 0.36145 0.097625 (exact) Prof. S. M. Lutful Kabir, BRAC University20
21
21 Runge-Kutta 4 th Order Method where For Runge Kutta 4 th order method is given by Prof. S. M. Lutful Kabir, BRAC University
22
22 Example A ball at 1200K is allowed to cool down in air at an ambient temperature of 300K. Assuming heat is lost only due to radiation, the differential equation for the temperature of the ball is given by Find the temperature at seconds using Runge-Kutta 4 th order method. seconds. Assume a step size of Prof. S. M. Lutful Kabir, BRAC University
23
23 Solution Step 1: Prof. S. M. Lutful Kabir, BRAC University
24
24 Solution Cont is the approximate temperature at Prof. S. M. Lutful Kabir, BRAC University
25
25 Comparison with exact results Figure 1. Comparison of Runge-Kutta 4th order method with exact solution Prof. S. M. Lutful Kabir, BRAC University
26
Step size, h (480) EtEt |є t |% 480 240 120 60 30 −90.278 594.91 646.16 647.54 647.57 737.85 52.660 1.4122 0.033626 0.00086900 113.94 8.1319 0.21807 0.0051926 0.00013419 26 Effect of step size Table 1. Temperature at 480 seconds as a function of step size, h (exact) Prof. S. M. Lutful Kabir, BRAC University
27
THANKS Prof. S. M. Lutful Kabir, BRAC University27
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.