Lecture 10: Linear Multistep Methods (LMMs)

Similar documents
Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester

Fourth Order RK-Method

Initial-Value Problems for ODEs. Introduction to Linear Multistep Methods

COSC 3361 Numerical Analysis I Ordinary Differential Equations (II) - Multistep methods

MTH 452/552 Homework 3

5.6 Multistep Methods

Multistep Methods for IVPs. t 0 < t < T

Applied Math for Engineers

Numerical Methods for the Solution of Differential Equations

ECE257 Numerical Methods and Scientific Computing. Ordinary Differential Equations

Jim Lambers MAT 772 Fall Semester Lecture 21 Notes

Math 128A Spring 2003 Week 11 Solutions Burden & Faires 5.6: 1b, 3b, 7, 9, 12 Burden & Faires 5.7: 1b, 3b, 5 Burden & Faires 5.

multistep methods Last modified: November 28, 2017 Recall that we are interested in the numerical solution of the initial value problem (IVP):

Chapter 8. Numerical Solution of Ordinary Differential Equations. Module No. 2. Predictor-Corrector Methods

HIGHER ORDER METHODS. There are two principal means to derive higher order methods. b j f(x n j,y n j )

9.6 Predictor-Corrector Methods

Lecture 8: Calculus and Differential Equations

Lecture 8: Calculus and Differential Equations

Numerical Differential Equations: IVP

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Ordinary Differential Equations. Monday, October 10, 11

Bindel, Fall 2011 Intro to Scientific Computing (CS 3220) Week 12: Monday, Apr 18. HW 7 is posted, and will be due in class on 4/25.

An Overly Simplified and Brief Review of Differential Equation Solution Methods. 1. Some Common Exact Solution Methods for Differential Equations

1 Error Analysis for Solving IVP

Numerical Methods - Initial Value Problems for ODEs

Solving Ordinary Differential Equations

A New Block Method and Their Application to Numerical Solution of Ordinary Differential Equations

16.7 Multistep, Multivalue, and Predictor-Corrector Methods

Linear Multistep Methods I: Adams and BDF Methods

4.4 Computing π, ln 2 and e

Ph 22.1 Return of the ODEs: higher-order methods

Research Article Diagonally Implicit Block Backward Differentiation Formulas for Solving Ordinary Differential Equations

A Survey of Numerical Methods in Fractional Calculus

Module 4: Numerical Methods for ODE. Michael Bader. Winter 2007/2008

Computational Methods CMSC/AMSC/MAPL 460. Ordinary differential equations

CHAPTER 5: Linear Multistep Methods

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Chapter 5 Exercises. (a) Determine the best possible Lipschitz constant for this function over 2 u <. u (t) = log(u(t)), u(0) = 2.

Modeling & Simulation 2018 Lecture 12. Simulations

Math Numerical Analysis Homework #4 Due End of term. y = 2y t 3y2 t 3, 1 t 2, y(1) = 1. n=(b-a)/h+1; % the number of steps we need to take

Predictor Corrector Methods of High Order for Numerical Integration of Initial Value Problems

Aug Vol. 5. No. 03 International Journal of Engineering and Applied Sciences EAAS & ARF. All rights reserved

Integration of Ordinary Differential Equations

Ordinary Differential Equations (ode)

Mini project ODE, TANA22

Ordinary differential equations - Initial value problems

8 Numerical Integration of Ordinary Differential

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit V Solution of

1 Ordinary Differential Equations

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Computational Methods CMSC/AMSC/MAPL 460. Ordinary differential equations

Appendix C: Recapitulation of Numerical schemes

Initial value problems for ordinary differential equations

Python Analysis. PHYS 224 September 25/26, 2014

7.2 Linear equation systems. 7.3 Linear least square fit

8.1 Introduction. Consider the initial value problem (IVP):

Mathematics for chemical engineers. Numerical solution of ordinary differential equations

Applied Numerical Analysis

Logistic Map, Euler & Runge-Kutta Method and Lotka-Volterra Equations

Chap. 20: Initial-Value Problems

CS520: numerical ODEs (Ch.2)

Key exercise 1 INF5620

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF MATHEMATICS ACADEMIC YEAR / EVEN SEMESTER QUESTION BANK

sing matlab Farida Mosally Mathematics Department King Abdulaziz University

Numerical Methods for Engineers. and Scientists. Applications using MATLAB. An Introduction with. Vish- Subramaniam. Third Edition. Amos Gilat.

ODE Runge-Kutta methods

4. Numerical analysis II

Numerical Stability of a One-Evaluation Predictor-Corrector Algorithm for Numerical Solution of Ordinary Differential Equations

Python Analysis. PHYS 224 October 1/2, 2015

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 20

16.7 Multistep, Multivalue, and Predictor-Corrector Methods

SOLUTION OF EQUATION AND EIGENVALUE PROBLEMS PART A( 2 MARKS)

24, B = 59 24, A = 55

Exercises, module A (ODEs, numerical integration etc)

Math 660 Lecture 4: FDM for evolutionary equations: ODE solvers

Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations

Computational Techniques Prof. Dr. Niket Kaisare Department of Chemical Engineering Indian Institute of Technology, Madras

2 Numerical Methods for Initial Value Problems

Ordinary Differential Equations II: Runge-Kutta and Advanced Methods

Ordinary Differential Equations

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Ordinary Differential Equations (ODE)

Conditioning and Stability

Previous Year Questions & Detailed Solutions

Exercise_set7_programming_exercises

Parallel Numerical Methods for Ordinary Differential Equations: a Survey

Symbolic Solution of higher order equations

(5.5) Multistep Methods

You may not use your books, notes; calculators are highly recommended.

Exponential Integrators

Solving ODEs and PDEs in MATLAB. Sören Boettcher

Initial Value Problems for. Ordinary Differential Equations

A Variable-Step Double-Integration Multi-Step Integrator

Checking the Radioactive Decay Euler Algorithm

Lecture 4: Numerical solution of ordinary differential equations

Computational Methods CMSC/AMSC/MAPL 460. Ordinary differential equations

Numerical solution of ODEs

Adebayo O. Adeniran1, Saheed O. Akindeinde2 and Babatunde S. Ogundare2 * Contents. 1. Introduction

1 Introduction to MATLAB

Numerical Methods - Boundary Value Problems for ODEs

Transcription:

Lecture 10: Linear Multistep Methods (LMMs) 2nd-order Adams-Bashforth Method The approximation for the 2nd-order Adams-Bashforth method is given by equation (10.10) in the lecture note for week 10, as follows y i+1 y i + 3 2 f(x i, y i )h 1 2 f(x i 1, y i 1 )h. (1) Since the computation of y i+1 can be performed directly using known quantities of previous points, i.e., y i and y i 1, this method is referred to as being explicit. Because explicit methods are known for being conditionally stable, the above formulation shall be used as a predictor in a predictor-corrector mechanism for the 2nd-order Adams-Bashforth method. We rewrite equation (1), and use it in a corrector approximation, P i+1 y i + 3 2 f(x i, y i )h 1 2 f(x i 1, y i 1 )h, (2) y i+1 y i + 1 2 h (f(x i+1, P i+1 + f(x i, y i )). (3) To implement in Python, we first calculate the predictor in equation (2). At initial point of calculation, this formula requires initial values at two different points. Because the initial calculation must start at i = 1, to calculate P 2 we need initial values y 1 and y 0. To get these initial values, we must invoke another solver that we may choose from the solvers we have done previously. Let us use the 4th-order Runge-Kutta solver, def RungeKutta4thOrder ( func, yinit, xspan, h): m = len ( yinit ) n = int (( xspan [-1] - xspan [0]) / h) x = xspan [0] y = yinit 1

xsol = np. empty ((0)) ysol = np. empty ((0)) ysol = np. append (ysol, y) for i in range (n): k1 = feval (func, x, y) k2 = feval (func, x+h/2, y + k1*(h/2)) k3 = feval (func, x+h/2, y + k2*(h/2)) k4 = feval (func, x+h, y + k3*h) for j in range (m): y[j] = y[j] + (h/6)*(k1[j] + 2*k2[j] + 2*k3[j] + k4[j]) x = x + h for r in range ( len (y)): ysol = np. append (ysol, y[r]) return [ xsol, ysol ] Since only two quantities of y to be calculated (y 0 and y 1 ), the xspan of the Runge-Kutta function also takes only two values of x, that is x 0 and x 1. Outside of the Runge-Kutta function, we create another function for the Adams-Bashforth method. This function takes in the same input arguments as the Runge-Kutta function, such as the function func, initial condition yinit, x interval x range, and step size h, def ABM2ndOrder ( func, yinit, x_range, h): After dividing the interval x range into smaller subintervals, dx = int (( x_range [-1] - x_range [0]) / h) xrk = [ x_range [0] + k*h for k in range (dx + 1)] the first two subintervals are passed as input for the x interval of the Runge-Kutta function, t = ( xrk [0], xrk [1]) [xx, yy] = RungeKutta4thOrder (func, yinit, t, h) The two outputs of the Runge-Kutta function, xx and yy, are Numpy arrays with dimension (2,) each. It means, each array xx and yy contains 2 elements (x 0 and x 1 and y 0 and y 1, 2

respectively) which will be used in the Adams-Bashforth function. Then we initialize variables x and y along with containers for storing the results after each iteration. The elements of xx are passed as initial values for the variable x and yy for y. We also initialize variables xsol and ysol that will store results of the calculation after each iteration, x = xx xsol = np. empty (0) y = yy ysol = np. empty (0) ysol = np. append (ysol, y) We also need to initialize another variable, which we call it yn, yn = np. array ([yy[0]]) Then we start the iteration over all points of the subintervals. Within the for loop, from equation (2), we define the two points x i and x i 1, x00 = x[i] x11 = x[i - 1] also for y i and y i 1, y00 = np. array ([y[i]]) y11 = np. array ([y[i - 1]]) and evaluate the derivative(s) based on x s and y s, y0prime = feval ( func, x00, y00 ) y1prime = feval ( func, x11, y11 ) which are used to calculate P i+1, or the predictor, ypredictor = y00 + (3/2)*h* y0prime - (1/2)*h* y1prime The predictor equation is then used to evaluate the derivative(s), based on the equation (3), evaluated at point x i+1, which we also need to initialize its variable, xpp = x[i] + h and use it for ypp = feval ( func, xpp, ypredictor ) 3

We finally arrive at the equation (3) of the 2nd-order Adams-Bashforth method, for j in range (m): yn[j] = y00 [j] + (h/2)* ypp [j] + (h/2)* y0prime [j] The full implementation of the 2nd-order Adams-Bashforth method can be done as follows, def ABM2ndOrder (func, yinit, xspan, h): m = len ( yinit ) dx = int (( xspan [-1] - xspan [0]) / h) xrk = [ xspan [0] + k*h for k in range (dx + 1)] t = ( xrk [0], xrk [1]) [xx, yy] = RungeKutta4thOrder (func, yinit, t, h) x = xx xsol = np. empty (0) y = yy yn = np. array ([yy[0]]) ysol = np. empty (0) ysol = np. append (ysol, y) for i in range (1, dx): x00 = x[i] x11 = x[i - 1] xpp = x[i] + h y00 = np. array ([y[i]]) y11 = np. array ([y[i - 1]]) y0prime = feval ( func, x00, y00 ) y1prime = feval ( func, x11, y11 ) ypredictor = y00 + (3/2)*h* y0prime - (1/2)*h* y1prime ypp = feval ( func, xpp, ypredictor ) for j in range (m): yn[j] = y00 [j] + (h/2)* ypp [j] + (h/2)* y0prime [j] xs = x[i] + h xsol = np. append (xsol, xs) x = xsol for r in range ( len (yn)): ysol = np. append (ysol, yn) 4

y = ysol return [ xsol, ysol ] 4th-order Adams-Bashforth-Moulton Method The approximation for the 4th-order Adams-Bashforth-Moulton method is given by equation (10.21) in the lecture note for week 10, as follows where y i+1 y i + h 24 (9f(x i+1, P i+1 ) + 19f(x i, y i ) 5f(x i 1, y i 1 ) + f(x i 2, y i 2 )), (4) P i+1 y i + h 24 (55f(x i, y i ) 59f(x i 1, y i 1 ) + 37f(x i 2, y i 2 ) 9f(x i 3, y i 3 )), (5) is the prediction equation. The algorithm to implement this equation in Python is similar to the 2nd-order Adams- Bashforth method above, where it invokes another solver to get initial conditions, except that the 4th-order method requires 4 initial conditions evaluated at 4 previous points. Hence, for the input arguments of the Runge-Kutta method, we modify the initial subintervals to t = ( xrk [0], x[3]) [xx, yy] = RungeKutta4thOrder (func, yinit, t, h) In order to be able to solve multiple ODEs or a system of ODEs, the variable yn needs to be initialized more general, hence yn = yy[0:m] The other thing we need to modify is the following variables in the for loop, y00 = np. array ([y[i]]) y11 = np. array ([y[i-1]]) y22 = np. array ([y[i-2]]) y33 = np. array ([y[i-3]]) or, to be general for multiple ODEs, y00 = y[m*i:] y11 = y[m*(i-1):m*i] y22 = y[m*(i-2):m*(i-1)] y33 = y[m*(i-3):m*(i-2)] 5

And finally, for solving multiple ODEs, saving the result of yn in the container ysol does not require the for loop, hence, ysol = np. append (ysol, yn) 6