Please remember: When you me, do it to Please type “numerical-15” at the beginning of the subject line Do not reply to my gmail,

Slides:



Advertisements
Similar presentations
Ordinary Differential Equations
Advertisements

Chapter 6 Differential Equations
Roots: Bracketing Methods
Computational Methods in Physics PHYS 3437
Ordinary Differential Equations
Asymptotic error expansion Example 1: Numerical differentiation –Truncation error via Taylor expansion.
Part 5 Chapter 19 Numerical Differentiation PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Dr. Jie Zou PHY Chapter 9 Ordinary Differential Equations: Initial-Value Problems Lecture (I) 1 1 Besides the main textbook, also see Ref.: “Applied.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Ordinary Differential Equations Equations which are.
Part 6 Chapter 22 Boundary-Value Problems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 32 Ordinary Differential Equations.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 31 Ordinary Differential Equations.
Initial-Value Problems
Dr. Jie Zou PHY Chapter 9 Ordinary Differential Equations: Initial-Value Problems Lecture (II) 1 1 Besides the main textbook, also see Ref.: “Applied.
8-1 Chapter 8 Differential Equations An equation that defines a relationship between an unknown function and one or more of its derivatives is referred.
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW III.
Chapter 17 Objectives Recognizing that Newton-Cotes integration formulas are based on the strategy of replacing a complicated function or tabulated data.
Numerical Solutions of Ordinary Differential Equations
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
CISE301_Topic8L31 SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM (Term 101) Section 04 Read , 26-2,
Differential Equations and Boundary Value Problems
Numerical solution of Differential and Integral Equations PSCi702 October 19, 2005.
PART 7 Ordinary Differential Equations ODEs
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Ch 8.1 Numerical Methods: The Euler or Tangent Line Method
Ch 8.3: The Runge-Kutta Method
EE3561_Unit 8Al-Dhaifallah14351 EE 3561 : Computational Methods Unit 8 Solution of Ordinary Differential Equations Lesson 3: Midpoint and Heun’s Predictor.
Modelling & Simulation of Chemical Engineering Systems Department of Chemical Engineering King Saud University 501 هعم : تمثيل الأنظمة الهندسية على الحاسب.
Integration of 3-body encounter. Figure taken from
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. ~ Ordinary Differential Equations ~ Stiffness and Multistep.
Numerical Solutions of ODE
Scientific Computing Multi-Step and Predictor-Corrector Methods.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 7 - Chapter 25.
Numerical Analysis – Differential Equation
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
Part 6 Chapter 21 Adaptive Methods and Stiff Systems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Chapter 5. Ordinary Differential Equation
Ch 8.2: Improvements on the Euler Method Consider the initial value problem y' = f (t, y), y(t 0 ) = y 0, with solution  (t). For many problems, Euler’s.
Part 3 Chapter 12 Iterative Methods
Dr. Mujahed AlDhaifallah ( Term 342)
Today’s class Ordinary Differential Equations Runge-Kutta Methods
Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
ECE 576 – Power System Dynamics and Stability Prof. Tom Overbye Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
Ordinary Differential Equations
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical Calculus and Differential Equations.
1/14  5.2 Euler’s Method Compute the approximations of y(t) at a set of ( usually equally-spaced ) mesh points a = t 0 < t 1
Lecture 39 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
This chapter is concerned with the problem in the form Chapter 6 focuses on how to find the numerical solutions of the given initial-value problems. Main.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
CISE301_Topic8L71 CISE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM (Term 101) Section 04 Read , 26-2,
Ordinary Differential Equations
Part 7 - Chapter 25.
Ordinary Differential Equations
Boundary-Value Problems
Numerical Differentiation
Class Notes 18: Numerical Methods (1/2)
SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM (Term 101) Section 04 Read , 26-2, 27-1 CISE301_Topic8L4&5.
Class Notes 19: Numerical Methods (2/2)
Part 7 - Chapter 25.
Numerical Analysis Lecture 37.
SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM (Term 101) Section 04 Read , 26-2, 27-1 CISE301_Topic8L2.
Numerical Analysis Lecture 38.
Numerical Integration of Functions
Adaptive Methods and Stiff Systems
SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM Read , 26-2, 27-1 CISE301_Topic8L3 KFUPM.
MATH 175: Numerical Analysis II
CISE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture KFUPM Read , 26-2, 27-1 CISE301_Topic8L7 KFUPM.
Presentation transcript:

Please remember: When you me, do it to Please type “numerical-15” at the beginning of the subject line Do not reply to my gmail, neo, hotmail, vz, ch , e , etc. I seldom read them. Office hours: right after class or by appointment Always check first the web page for information

Introduction to Differential Equations

Part 6 Chapter 22 Initial-Value Problems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Chapter Objectives Solve Initial Values Problems for ODE Local and global truncation errors and their relationship to step size for one-step methods for solving ODEs. to implement Runge-Kutta (RK) methods for a single ODE: –Euler –Heun –Midpoint –Fourth-Order RK Knowing how to iterate the corrector of Heun’s method. Knowing how to implement the following Runge-Kutta methods for systems of ODEs: –Euler –Fourth-order RK

sign(x)

Ordinary Differential Equations Methods described here are for solving differential equations of the form: The methods in this chapter are all one-step methods and have the general format: New value = old value + slope × step size where  is called an increment function, and is used to extrapolate from an old value y i to a new value y i+1.

OVERVIEW

Euler’s Method The first derivative provides a direct estimate of the slope at t i : and the Euler method uses that estimate as the increment function : h error y t true predicted t i+1

EXAMPLE

Error Analysis for Euler’s Method The numerical solution of ODEs involves two types of error: –Truncation errors, caused by the nature of the techniques employed –Roundoff errors, caused by the limited numbers of significant digits that can be retained The total, or global truncation error can be further split into: –local truncation error that results from an application method in question over a single step, and –propagated truncation error that results from the approximations produced during previous steps.

Error Analysis for Euler’s Method The local truncation error for Euler’s method is O(h 2 ) and proportional to the derivative of f(t,y) while the global truncation error is O(h). This means: –The global error can be reduced by decreasing the step size, and –Euler’s method will provide error-free predictions if the underlying function is linear. Euler’s method is conditionally stable, depending on the size of h.

Stability of Euler’s Method A numerical solution is unstable if errors grow exponentially for a bounded solution. the differential equation, the numerical method, and the step size EXAMPLE The parenthetical quantity 1 − ah is called an amplification factor

Euler’s method is conditionally stable. If errors grow regardless of the method, ODE is ill-conditioned Inaccuracy and instability are often confused an inaccurate method can be very stable

MATLAB Code for Euler’s Method function [t,y] = eulode(dydt,tspan,y0,h,varargin) % eulode: Euler ODE solver % [t,y] = eulode(dydt,tspan,y0,h,p1,p2,...): % uses Euler's method to integrate an ODE % input: % dydt = name of the M-file that evaluates the ODE % tspan = [ti, tf] where ti and tf = initial and % final values of independent variable % y0 = initial value of dependent variable % h = step size % p1,p2,... = additional parameters used by dydt % output: % t = vector of independent variable % y = vector of solution for dependent variable if nargin<4,error('at least 4 input arguments'),end ti = tspan(1);tf = tspan(2); if ~(tf>ti),error('upper limit greater than lower'),end

t = (ti:h:tf)'; n = length(t); % if necessary, add an additional value of t if t(n)<tf t(n+1) = tf; n = n+1; end %preallocate y to improve efficiency y = y0*ones(n,1); %implement Euler's method for i = 1:n-1 y(i+1) = y(i)+dydt(t(i),y(i),varargin{:})*(t(i+1)-t(i)); end

QUIZ Solve dy/dt = y*t^3 – (3/2)y Euler’ methods with h = 0.5 For t = 0 to 2, and y(0) = 1

Euler’s Method The first derivative provides a direct estimate of the slope at t i : and the Euler method uses that estimate as the increment function : h error y t true predicted t i+1

Heun’s Method One method to improve Euler’s method is to determine derivatives at the beginning and predicted ending of the interval and average them:

Heun’s Method This process relies on making a prediction of the new value of y, then correcting it based on the slope calculated at that new value. This predictor-corrector approach can be iterated to convergence:

QUIZ Solve dy/dt = (1 + 4*t)*sqrt(y) Using Heun’s method with h = 0.25 from t = 0 to 1, and y(0) = 1

Midpoint Method Another improvement to Euler’s method is similar to Heun’s method, but predicts the slope at the midpoint of an interval rather than at the end: This method has a local truncation error of O(h 3 ) and global error of O(h 2 )

Runge-Kutta Methods Runge-Kutta (RK) methods achieve the accuracy of a Taylor series approach without requiring the calculation of higher derivatives. For RK methods, the increment function  can be generally written as: where the a’s are constants and the k’s are where the p’s and q’s are constants.

Classical Fourth-Order Runge- Kutta Method The most popular RK methods are fourth-order, and the most commonly used form is : where:

Systems of Equations Many practical problems require the solution of a system of equations: The solution of such a system requires that n initial conditions be known at the starting value of t.

Solution Methods Single-equation methods can be used to solve systems of ODE’s as well; for example, Euler’s method can be used on systems of equations - the one-step method is applied for every equation at each step before proceeding to the next step. Fourth-order Runge-Kutta methods can also be used, but care must be taken in calculating the k’s.

MATLAB RK4 Code function [tp,yp] = rk4sys(dydt,tspan,y0,h,varargin) % rk4sys: fourth-order Runge-Kutta for a system of ODEs % [t,y] = rk4sys(dydt,tspan,y0,h,p1,p2,...): integrates a system of % ODEs with fourth-order RK method % input: % dydt = name of the M-file that evaluates the ODEs % tspan = [ti, tf]; initial and final times with output generated at % interval of h, or = [t0 t1... tf]; times where solution output % y0 = initial values of dependent variables % h = step size % p1,p2,... = additional parameters used by dydt % output: % tp = vector of independent variable % yp = vector of solution for dependent variables

if nargin<4,error('at least 4 input arguments required'), end if any(diff(tspan)<=0),error('tspan not ascendent order'), end n = length(tspan); ti = tspan(1); tf = tspan(n);

if n == 2 t = (ti:h:tf)'; n = length(t); if t(n) < tf t(n+1) = tf; n = n+1; end else t = tspan; end tt = ti; y(1,:) = y0; np = 1; tp(np) = tt; yp(np,:) = y(1,:); i=1;

while(1) tend = t(np+1); hh = t(np+1) - t(np); if hh >h, hh = h; end

while(1) if tt+hh > tend, hh = tend-tt; end k1 = dydt(tt, y(i,:), varargin{:})'; ymid = y(i,:) + k1.*hh./2; k2 = dydt(tt+hh/2, ymid, varargin{:})'; ymid = y(i,:) + k2*hh/2; k3 = dydt(tt+hh/2, ymid, varargin{:})'; yend = y(i,:) + k3*hh; k4 = dydt(tt+hh, yend, varargin{:})'; phi = (k1+2*(k2+k3)+k4)/6; y(i+1,:) = y(i,:) + phi*hh; tt = tt+hh; i=i+1; if tt >= tend, break, end end np = np+1; tp(np) = tt; yp(np,:) = y(i,:); if tt>=tf,break,end end

End of Chapter 22