Analysis and Implementation of Numerical Methods for Solving Ordinary Differential Equations Muhammad Sohel Rana Western Kentucky University, Sohel [email protected]
Total Page:16
File Type:pdf, Size:1020Kb
Western Kentucky University TopSCHOLAR® Masters Theses & Specialist Projects Graduate School Fall 2017 Analysis and Implementation of Numerical Methods for Solving Ordinary Differential Equations Muhammad Sohel Rana Western Kentucky University, [email protected] Follow this and additional works at: https://digitalcommons.wku.edu/theses Part of the Numerical Analysis and Computation Commons, Ordinary Differential Equations and Applied Dynamics Commons, and the Partial Differential Equations Commons Recommended Citation Rana, Muhammad Sohel, "Analysis and Implementation of Numerical Methods for Solving Ordinary Differential Equations" (2017). Masters Theses & Specialist Projects. Paper 2053. https://digitalcommons.wku.edu/theses/2053 This Thesis is brought to you for free and open access by TopSCHOLAR®. It has been accepted for inclusion in Masters Theses & Specialist Projects by an authorized administrator of TopSCHOLAR®. For more information, please contact [email protected]. ANALYSIS AND IMPLEMENTATION OF NUMERICAL METHODS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS A Thesis Presented to The Faculty of the Department of Mathematics Western Kentucky University Bowling Green, Kentucky In Partial Fulfillment Of the Requirements for the Degree Master of Science By Muhammad Sohel Rana December 2017 ACKNOWLEDGMENTS At the very outset I would like to thank my advisor Dr. Mark Robinson to give me a chance to work with him for my thesis and for his constant supervision to finish my work. I am also grateful for his patience during the work. I especially indebted to him for his support, help and guidance in the course of prepare this paper. I also want to give special thanks to my other two thesis committee members Dr. Ferhan Atici and Dr. Ngoc Nguyen for their cooperation towards me. It is also worth mentioning all my supportive and inspiring friends for their inspiration during the hard time. Finally, I would like mention my beloved parents and other family members for their enthusiastic support and advice to move forward in life. iii CONTENTS List of Figures vi List of Tables ix ABSTRACT x Chapter 1. INTRODUCTION 1 1.1. Differential Equations and Initial Value Problems 1 1.2. Numerical Difference Methods 2 1.3. Order and Truncation Error of a Numerical Method 3 Chapter 2. Stiffness and Stability 13 2.1. Stiffness 13 2.2. Stability 16 Chapter 3. Some Special Problems and Their Numerical Solutions 22 3.1. Nonhomogeneous Differential Equations 22 3.2. Logistic Differential Equation 27 3.3. Systems of Differential Equations 32 3.4. Predator-Prey Problem 34 3.5. Harmonic Oscillator 40 3.6. Conditions Under Which Newton Iteration Converges When Applied for Backward Euler or Trapezoidal Method 43 Chapter 4. Discretization of Partial Differential Equations 49 4.1. Difference Formulas and Other Preliminaries 49 iv 4.2. Stiff Differential Systems in Some Applications: 52 4.3. Nonhomogeneous Heat Equation 56 Chapter 5. Experimental Estimation of the Order of Numerical Methods 60 5.1. Error Analysis 60 5.2. Handling Order in Practice 66 Chapter 6. Numerical Approximation for Second Order Singular Differential Equations 72 6.1. Lane-Emden Equation and Series Solutions 72 6.2. Numerical Results for Second Order Singular Differential Equations 75 Chapter 7. Conclusion and Future Work 84 Appendices 87 BIBLIOGRAPHY 97 v List of Figures 2.2.1 Stability region of Euler’s method (non shaded region) 19 2.2.2 Stability region of backward Euler method (non shaded region) 19 2.2.3 Stability region of Trapezoidal method (non shaded region) 20 2.2.4 Stability region of modified Euler method (non shaded region) 20 3.1.1 Graph of exact solution of y0 = −100(y − et) with y(0) = 0. 25 3.1.2 Graph of the solution using Trapezoidal method (oscillating curve) with step size h = 0:1 together with exact solution of y0 = −100(y − et) with y(0) = 0: 25 3.1.3 Graph of exact solution (dark curve) and solution using backward Euler method (light curve) for h = 0:1 of y0 = −100(y − et) with y(0) = 0. 26 3.1.4 Approximate solution for Example 3.1.1 using backward Euler method (smoother curve) and Trapezoidal method (oscillating curve) for step size h = 0.1. 26 3.2.1 Figure shows no stiffness for λ = 1. 29 3.2.2 Figure shows that the differential equation starts to become stiff for λ = 5. 29 3.2.3 Figure shows that the stiffness increased for the differential equation when λ = 15. 29 3.2.4 Figure shows that the differential equation is very stiff when λ = 50. 30 vi 3.2.5 Figure of results from the use of Trapezoidal method for numerical solution using λ = 1; 5; 15; 50 for h = 0:25. Gray level decreases as the value of the λ increases. 30 3.2.6 Figure of results of the logistic equation for different values of λ = 1; 5; 15; 50 using StiffnessSwitching command in Mathematica. Gray level decreases as the value of λ increases. 30 3.2.7 Figure of step size h versus t using StiffnessSwitching for logistic equation for λ = 1 (dashed curve) and λ = 50 (lined curve). 31 3.4.1 Using explicit Euler method for Lotka-Volterra problem (3.9) with step size h = 0:001 dark graph for predator and light one is for prey for initial 79 conditions x1(0) = 40 and x2(0) = 1 37 3.4.2 Phase space plot where horizontal axis represents number of prey and vertical axis represents numbers of predator for the problem (3.9) using implicit solution of the differential equation by Mathematica ContourPlot 38 3.4.3 Numerical solution using backward Euler method where horizontal-axis for prey and vertical-axis for predator with step size h = 0:001: 38 3.4.4 Using implicit Trapezoidal method(using the codes developed for system of two differential equations) the plot of the numeric discrete solution for Lotka-Volterra problem (3.9) with step size h = 0:05 for initial solution 79 x1(0) = 40 and x2(0) = 1 39 3.4.5 Using implicit Trapezoidal method(using the codes developed for system of two differential equations) the plot of the numeric discrete solution for Lotka-Volterra equation (3.9) with step size h = 0:05 for initial conditions 79 x1(0) = 40 and x2(0) = 1 39 3.5.1 Plot of exact solution y(t) = cos(wt) of the second order differential equation (3.10) for ! = 20. 44 vii 3.5.2 Plot of numeric solution of the converted system of equations of second order differential equation (3.10) using Trapezoidal method for system of two equations for ! = 20 and step size h = 0.005. 44 3.5.3 Combined plot of exact solution and numeric solution using trapezoidal method of the second order ODE (3.10) for ! = 20 and step size h = 0:005. 44 3.5.4 Plot of exact solution and numeric solution using trapezoidal method of the second order ODE (3.10) for ! = 20 and step size h = 0:035. 45 2 2b0 2 2b1 2 4.2.1 Figure of circles center at − 2 , ( − 2 ) and (− − 2 ) on the real h a0h h a1h h 2 1 axis having radius h2 for h = 1, b0 = 2 , a0 = 4, a1 = 8 and b1 = 1. 56 5.1.1 Plot of claimed E(h) versus h for backward Euler method, implicit trapezoidal method, and Runge-Kutta method. 64 5.1.2 Plot of acctual error, E(h) versus h for backward Euler method, implicit trapezoidal method, and Runge-Kutta method for the equation in Example 5.1.1. 64 5.2.1 Plot of E(h) versus h when computational finiteness contributes to the error of the methods. 71 viii List of Tables 5.1.1 Approximation wh(b) and actual Error jE(h)j = jy(b) − wh(b)j for y0(t) = 5e5t(y − t)2 + 1 63 lnjE(2h)|−lnjE(h)j 0 5t 2 5.1.2 Order of Error p = ln2 for y (t) = 5e (y − t) + 1 66 lnjD4h|−lnjD2hj 0 2 5.2.1 Order p = ln2 for y (t) = t − y 70 lnjE(2h)|−lnjE(h)j 00 2 0 6.2.1 Order of Error p = ln2 for y (t) + t y (t) + y = 0; t 2 0 sin t (0; 1] with y(0) = 1; y (0) = 0 and exact solution y(t) = t for Nystrom method. 81 6.2.2 Comparison of the backward Euler method and Nystrom method with Beech’s approximation for Lane-Emden equation for n = 3 and h = 0:025. 82 6.2.3 Comparison of backward Euler method and Nystrom method with Fowler and Hoyle’s approximation for Lane-Emden equation for n = 1:5 and h = 0:025 . 83 ix ANALYSIS AND IMPLEMENTATION OF NUMERICAL METHODS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS Muhammad Sohel Rana December 2017 98 Pages Directed by: Dr. Mark Robinson, Dr. Ferhan Atici and Dr. Ngoc Nguyen Department of Mathematics Western Kentucky University Numerical methods to solve initial value problems of differential equations pro- gressed quite a bit in the last century. We give a brief summary of how useful numerical methods are for ordinary differential equations of first and higher order. In this thesis both computational and theoretical discussion of the application of numerical methods on differential equations takes place. The thesis consists of an investigation of various categories of numerical methods for the solution of ordi- nary differential equations including the numerical solution of ordinary differential equations from a number of practical fields such as equations arising in population dynamics and astrophysics. It includes discussion what are the advantages and dis- advantages of implicit methods over explicit methods, the accuracy and stability of methods and how the order of various methods can be approximated numerically.