Section 7.4 Runge-Kutta Methods

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

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

NUMERICAL SOLUTION OF ODE IVPs. Overview

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

Chapter 6 - Ordinary Differential Equations

Consistency and Convergence

Euler s Method, cont d

Ordinary Differential Equations (ODEs)

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method)

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

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Chap. 20: Initial-Value Problems

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

The family of Runge Kutta methods with two intermediate evaluations is defined by

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

Section 7.2 Euler s Method

Multistep Methods for IVPs. t 0 < t < T

MTH 452/552 Homework 3

Solutions to Homework 3

Ordinary differential equations - Initial value problems

Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method)

INTRODUCTION TO COMPUTER METHODS FOR O.D.E.

Multistage Methods I: Runge-Kutta Methods

551614:Advanced Mathematics for Mechatronics. Numerical solution for ODEs School of Mechanical Engineering

Euler s Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability.

2tdt 1 y = t2 + C y = which implies C = 1 and the solution is y = 1

Ordinary Differential Equations

We begin exploring Euler s method by looking at direction fields. Consider the direction field below.

9.6 Predictor-Corrector Methods

Numerical Methods - Initial Value Problems for ODEs

Do not turn over until you are told to do so by the Invigilator.

Fourth Order RK-Method

Initial value problems for ordinary differential equations

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

ODE Runge-Kutta methods

Numerical Solution of ODE IVPs

Numerical Methods for Ordinary Differential Equations

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

CHAPTER 10: Numerical Methods for DAEs

Jim Lambers MAT 772 Fall Semester Lecture 21 Notes

1 Systems of First Order IVP

13 Numerical Solution of ODE s

Initial Value Problems

Modeling & Simulation 2018 Lecture 12. Simulations

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

Numerical Differential Equations: IVP

2 Numerical Methods for Initial Value Problems

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

ACCELERATION OF RUNGE-KUTTA INTEGRATION SCHEMES

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

Solving Ordinary Differential Equations

Ordinary Differential Equations II

Higher Order Taylor Methods

Ordinary Differential Equations

δ Substituting into the differential equation gives: x i+1 x i δ f(t i,x i ) (3)

Ordinary differential equation II

EXAMPLE OF ONE-STEP METHOD

Numerical Methods for Differential Equations

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

AN OVERVIEW. Numerical Methods for ODE Initial Value Problems. 1. One-step methods (Taylor series, Runge-Kutta)

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

Applied Math for Engineers

Ph 22.1 Return of the ODEs: higher-order methods

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

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

Numerical Integration of Ordinary Differential Equations for Initial Value Problems

Numerical solution of ODEs

Solving systems of ODEs with Matlab

Modeling and Experimentation: Compound Pendulum

1 Error Analysis for Solving IVP

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9

Do not turn over until you are told to do so by the Invigilator.

Ordinary Differential Equations (ODEs)

Lecture IV: Time Discretization

4.4 Computing π, ln 2 and e

University of Alberta ENGM 541: Modeling and Simulation of Engineering Systems Laboratory #5

Calculus for the Life Sciences

Lecture Notes on Numerical Differential Equations: IVP

FORTRAN 77 Lesson 7. Reese Haywood Ayan Paul

Ordinary Differential Equations

Math Homework 3 Solutions. (1 y sin x) dx + (cos x) dy = 0. = sin x =

Numerical Methods for Differential Equations

Outline Calculus for the Life Sciences II. Pollution in a Lake 1. Introduction. Lecture Notes Numerical Methods for Differential Equations

Numerical Methods for the Solution of Differential Equations

ECE257 Numerical Methods and Scientific Computing. Ordinary Differential Equations

24, B = 59 24, A = 55

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

AM205: Assignment 3 (due 5 PM, October 20)

Runge - Kutta Methods for first and second order models

Ordinary Differential Equations

Runge - Kutta Methods for first order models

Math 128A Spring 2003 Week 12 Solutions

Scientific Computing: An Introductory Survey

Physics 584 Computational Methods

Ordinary Differential Equations II

4 Stability analysis of finite-difference methods for ODEs

CHAPTER 5: Linear Multistep Methods

Initial value problems for ordinary differential equations

Numerical Solution of Differential Equations

Transcription:

Section 7.4 Runge-Kutta Methods Key terms: Taylor methods Taylor series Runge-Kutta; methods linear combinations of function values at intermediate points Alternatives to second order Taylor methods Fourth order Runge-Kutta methods; very popular

Taylor methods require derivatives of f(t, y), which makes them difficult to use effectively. This drawback is so severe that they are seldom used in practice. However, there is another approach that is very effective. Runge-Kutta methods are related to Taylor methods in the following way. Instead of using derivatives of f(t, y), Runge-Kutta methods use evaluations of the f(t, y) at alternative pairs of points (t, y) that are not restricted to discrete points with t = t 0, t 1 = t 0 +h, t 2 = t 0 + 2h, etc. These techniques were developed around 1900 by the German mathematicians C. Runge and M.W. Kutta. The determination of these alternative pairs requires certain parameters to be selected so that we match the Taylor expressions and maintain the same power of stepsize h in the error expression. The advantage of this approach is that we use only evaluations of f not its derivatives. Thus the cost of using Runge-Kutta methods is FUNCTION EVALUATIONS instead of DERIVATIVE EVALUATIONS. Hence the Runge-Kutta methods are simple to use and have error properties corresponding to the Taylor methods upon which they are based.

The development of R-K methods expresses the difference between y(t n+1 ) and y(t n ) as a linear combination of function evaluations of f(t, y(t)). Then coefficients in such linear combinations are determined so that terms of Taylor expansions are matched. The general approach is to construct a difference equation of the form where the coefficients a j are constants and the k j are expressions involving stepsize h times evaluations of function f. That is, where the coefficients a j, α j, and β js are chosen to match terms of the Taylor expansion of y(t). (Note that k j can depend on values of previous k s and the value t n + α j h t n+1.)

Example: Construct a R-K method of the form We use Taylor expansions for the corresponding expression involving the exact solution y(t), which looks like then following. (We replace w s with y(t).) We choose parameters a 1, a 2, α, and β to match terms of the expansion Recall that When we do this (via ugly algebra & calculus) we get THREE EQUATIONS in FOUR UNKNOWNS (nonlinear system).

When these equations are satisfied then the R-K method has local truncation error O(h 2 ). That is, it will in effect act like a second order Taylor method, but with a (somewhat) different error expression. Since we have a nonlinear system of 3 equations in 4 unknowns we expect many solutions.

Some particular choices for the parameters a 1, a 2, α, and β: (Warning: the names vary from book to book. The names used here correspond to those used in MATLAB software and are not the same as those used in the text by Bradie.) Midpoint Method Bradie name,modified Euler method Modified Euler Method Bradie name,heun method Heun s Method Bradie name, Optimal RK2 method

Higher order R-K methods are constructed in a similar way just using more terms of the difference equation with and of course matching more terms of the Taylor expansion of y(t+h). The algebra & calculus becomes very tedious. One of the most popular R-K methods is a 4th order method given by the following: Note that the k-values must be computed in order.

Exact solution y(t) = 2 e 1 (-t) In a graph the sets of data look coincident. The main computational effort in RK-methods is evaluating f. There should be some payoff to using a method like RK4. We hope that such higher order methods will let us use larger step sizes h and maintain the same accuracy as lower order methods with smaller step sizes.

RK4 should give more accurate answers than Euler s method with about a stepsize about 4 times larger. RK4 should give more accurate answers than RK2 with about a stepsize about 2 times larger. To get methods which are as accurate as RK-methods, but with fewer evaluations of f, we need to use multistep methods. (Discussed in the next section.)

If you had to use one of the Runge-Kutta methods by hand (calculator) care must be used to get the substitutions correct. We illustrate this below. Example: The RK2 Midpoint Method is given by This is what you substitute for t. This is what you substitute for y. is evaluated where t is and y is

A comparison of behaviors:

MATLAB command names: eulersys rkmidpt rkmodeuler rkheun rk4th All of these routines are designed to handles systems of ODEs: The system has the form X' = F(t,X) X(t0) = X0 <-- initial condition where X is column vector and F is a vector function. The independent variable is t and the components of F(X) are functions of the variables t and x(1), x(2),..., x(k), for k<=9. Before using any of these read the help files carefully. The names used by the m-files are different than names appearing in the text.

Example: Use rk4th on IVP y = y t 2 + 1, 0 t 2, y(0) = 0.5 with stepsize h = 0.1. Use command >>rk4th What you see on the MATLAB screen that requests input: Enter size (<= 9) of the system: k = 1 Enter f1 = x(1)-t^2+1 You can see a table of output by performing several more steps: Your system is X' = x(1)-t^2+1 1 Accept current functions in f. 2 Re-enter functions. 0 Quit! Enter your choice ---> 1 Enter the initial condition X(t0) = [x1 x2...xk] Enter value of t0: t0 = 0 Enter 1 initial values in the form [a b.. etc]: X(t0) = 0.5 Enter right end of solution interval: b = 2 Enter the stepsize: h = 0.1 The solution at t = b is W = 5.3055e+00 Input in red output in blue. t w 0 0.5000 0.1000 0.6574 0.2000 0.8293 0.3000 1.0151 0.4000 1.2141 0.5000 1.4256 0.6000 1.6489 0.7000 1.8831 0.8000 2.1272 0.9000 2.3802 1.0000 2.6409 1.1000 2.9079 1.2000 3.1799 1.3000 3.4553 1.4000 3.7324 1.5000 4.0092 1.6000 4.2835 1.7000 4.5530 1.8000 4.8152 1.9000 5.0670 2.0000 5.3055 The true solution is, y = 2t -0.5e t + t 2 + 1 so you could consturct the error at each t value and graph the error. B&F 5.4 Examp 4

How do you approximate the solution of an IVP whose DE is more than first order? Answer: Convert the higher order DE to a system of first order DEs. Example: Use rk4th to approximate the solution of the IVP Linear second order nonhomogenous DE rk4th INPUT 2 3 t y'' 2ty' 2y t ln(t), 1 t 2, y( 1) 1, y'( 1) 0, with h 0. 1 7 1 3 4 2 4 3 3 The true solution is y(t) t t ln(t) t. u 1(t) y(t) Let. u (t) y'(t) 2 u ' y' u 1 2 Now differentiate to get 2 2. u 2 ' y'' u2 u 2 1 t ln(t) t t u 1 x(1); u 2 x(2) in rk4th Enter size (<= 9) of the system: k = 2 Enter f1 = x(2) Enter f2 = (2/t)*x(2)-(2/t^2)*x(1)+t*log(t) Enter the initial condition X(t0) = [x1 x2...xk] Enter value of t0: t0 = 1 Enter 2 initial values in the form [a b.. etc]: X(t0) = [1 0] Enter right end of solution interval: b = 2 The solution at t = b is W = f1 2.7258e-01-1.0911e+00 f2 B&F 5.9 #3b Enter the stepsize: h = 0.1

From rk4th t u 1 (t) u 2 (t) 1.0000 1.0000 0 1.1000 0.9902-0.1945 1.2000 0.9615-0.3762 1.3000 0.9155-0.5424 1.4000 0.8536-0.6908 1.5000 0.7780-0.8191 1.6000 0.6906-0.9252 1.7000 0.5937-1.0072 1.8000 0.4900-1.0634 1.9000 0.3820-1.0919 2.0000 0.2726-1.0911 From true soln t y(t) 1.0000 1.0000 1.1000 0.9902 1.2000 0.9615 1.3000 0.9155 1.4000 0.8536 1.5000 0.7780 1.6000 0.6906 1.7000 0.5937 1.8000 0.4900 1.9000 0.3820 2.0000 0.2726 t absolute error 1.0000e+00 0 1.1000e+00 7.4726e-07 1.2000e+00 1.4532e-06 1.3000e+00 2.1266e-06 1.4000e+00 2.7742e-06 1.5000e+00 3.4014e-06 1.6000e+00 4.0122e-06 1.7000e+00 4.6099e-06 1.8000e+00 5.1973e-06 1.9000e+00 5.7764e-06 2.0000e+00 6.3491e-06 True soln. Absolute error