Mathematics for chemical engineers

Similar documents
Finite difference methods

Review Initial Value Problems Euler s Method Summary

x n x n stepnumber k order r error constant C r+1 1/2 5/12 3/8 251/720 abs. stab. interval (α,0) /11-3/10

Euler s Methods (a family of Runge- Ku9a methods)

Simulation in Computer Graphics. Particles. Matthias Teschner. Computer Science Department University of Freiburg

CS205b/CME306. Lecture 9

Ordinary Differential Equations

ODEs occur quite often in physics and astrophysics: Wave Equation in 1-D stellar structure equations hydrostatic equation in atmospheres orbits

ODE IVP. An Ordinary Differential Equation (ODE) is an equation that contains a function having one independent variable:

Discontinuous Galerkin Sparse Grid method for Maxwell s equations

(Part - 1) P. Sam Johnson. April 14, Numerical Solution of. Ordinary Differential Equations. (Part - 1) Sam Johnson. NIT Karnataka.

1. Suppose that the equation F (x, y, z) = 0 implicitly defines each of the three variables x, y, and z as functions of the other two:

Ordinary differential equations solving methods

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

. Tutorial Class V 3-10/10/2012 First Order Partial Derivatives;...

Kevin James. MTHSC 206 Section 14.5 The Chain Rule

over The idea is to construct an algorithm to solve the IVP ODE (8.1)

Introduction to Optimization Problems and Methods

REVIEW I MATH 254 Calculus IV. Exam I (Friday, April 29) will cover sections

Module 1: Introduction to Finite Difference Method and Fundamentals of CFD Lecture 6:

Direction Fields; Euler s Method

over The idea is to construct an algorithm to solve the IVP ODE (9.1)

DD2429 Computational Photography :00-19:00

Math 225 Scientific Computing II Outline of Lectures

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations)

Inverse and Implicit functions

Module1: Numerical Solution of Ordinary Differential Equations. Lecture 6. Higher order Runge Kutta Methods

Functions of Two variables.

4 Visualization and. Approximation

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations)

Math 126 Winter CHECK that your exam contains 8 problems.

37 Self-Assessment. 38 Two-stage Runge-Kutta Methods. Chapter 10 Runge Kutta Methods

Lecture 15. Lecturer: Prof. Sergei Fedotov Calculus and Vectors. Length of a Curve and Parametric Equations

Mathematical Methods and Modeling Laboratory class. Numerical Integration of Ordinary Differential Equations

Continuity and Tangent Lines for functions of two variables

Background for Surface Integration

Runge Kutta Methods Optimized For Advection Problems

Surfaces and Integral Curves

The Level Set Method. Lecture Notes, MIT J / 2.097J / 6.339J Numerical Methods for Partial Differential Equations

Computer Simulations

Parameterization of triangular meshes

Parametric and Polar Curves

Parametric and Polar Curves

Parametric and Polar Curves

SYSTEMS OF NONLINEAR EQUATIONS

Numerical Solutions of Differential Equations (1)

Winfried Auzinger, Dirk Praetorius (SS2012)

The listing says y(1) = How did the computer know this?

= w. w u. u ; u + w. x x. z z. y y. v + w. . Remark. The formula stated above is very important in the theory of. surface integral.

. 1. Chain rules. Directional derivative. Gradient Vector Field. Most Rapid Increase. Implicit Function Theorem, Implicit Differentiation

Convex Optimization Lecture 2

Chapter 6. Curves and Surfaces. 6.1 Graphs as Surfaces

Jim Lambers MAT 169 Fall Semester Lecture 33 Notes

COMPUTER AIDED ENGINEERING DESIGN (BFF2612)

1.2 Numerical Solutions of Flow Problems

Homework Set 5 (Sections )

A Study on Numerical Exact Solution of Euler, Improved Euler and Runge - Kutta Method

21. Efficient and fast numerical methods to compute fluid flows in the geophysical β plane

Application 7.6A The Runge-Kutta Method for 2-Dimensional Systems

Euler s Method and Logistic Growth (BC Only)

Curve and Surface Basics

CS 450 Numerical Analysis. Chapter 7: Interpolation

Numerical Methods on the Image Processing Problems

Asymptotic Error Analysis

A Grid Based Particle Method for Evolution of Open Curves and Surfaces

Truncation Errors. Applied Numerical Methods with MATLAB for Engineers and Scientists, 2nd ed., Steven C. Chapra, McGraw Hill, 2008, Ch. 4.

Daily WeBWorK, #1. This means the two planes normal vectors must be multiples of each other.

Sparse Optimization Lecture: Proximal Operator/Algorithm and Lagrange Dual

Application 2.4 Implementing Euler's Method

Hartley - Zisserman reading club. Part I: Hartley and Zisserman Appendix 6: Part II: Zhengyou Zhang: Presented by Daniel Fontijne

Math (Spring 2009): Lecture 5 Planes. Parametric equations of curves and lines

Math 213 Exam 2. Each question is followed by a space to write your answer. Please write your answer neatly in the space provided.

Equation of tangent plane: for implicitly defined surfaces section 12.9

PARALLEL METHODS FOR SOLVING PARTIAL DIFFERENTIAL EQUATIONS. Ioana Chiorean

Math 407 Solutions to Exam 3 April 24, Let f = u + iv, and let Γ be parmetrized by Γ = (x (t),y(t)) = x (t) +iy (t) for a t b.

Chapter 6 Some Applications of the Integral

Lecture 8: Jointly distributed random variables

Data Visualization. Fall 2017

Homework Set #2-3, Math 475B

MATH2071: LAB 2: Explicit ODE methods

MAT203 OVERVIEW OF CONTENTS AND SAMPLE PROBLEMS

Updated: August 24, 2016 Calculus III Section Math 232. Calculus III. Brian Veitch Fall 2015 Northern Illinois University

Math 209, Fall 2009 Homework 3

MA 114 Worksheet #17: Average value of a function

Tangent & normal vectors The arc-length parameterization of a 2D curve The curvature of a 2D curve

The Jello Cube Assignment 1, CSCI 520. Jernej Barbic, USC

Math 348 Differential Geometry of Curves and Surfaces

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Suppose we want to find approximate values for the solution of the differential equation

Spline Curves. Spline Curves. Prof. Dr. Hans Hagen Algorithmic Geometry WS 2013/2014 1

Chapter One. Numerical Algorithms

LAB #8 Numerical Methods

Semi-Conservative Schemes for Conservation Laws

7/28/2011 SECOND HOURLY PRACTICE V Maths 21a, O.Knill, Summer 2011

Hyperbola for Curvilinear Interpolation

Key points. Assume (except for point 4) f : R n R is twice continuously differentiable. strictly above the graph of f except at x

CS321 Introduction To Numerical Methods

Numerical Analysis Fall. Numerical Differentiation

Mass-Spring Systems. Last Time?

(1) Given the following system of linear equations, which depends on a parameter a R, 3x y + 5z = 2 4x + y + (a 2 14)z = a + 2

Transcription:

Mathematics for chemical engineers Drahoslava Janovská Department of mathematics Winter semester 2013-2014

Numerical solution of ordinary differential equations Initial value problem

Outline 1 Introduction 2 Euler s method Runge - Kutta methods

Introduction Numerical solution of differential equations necessity for engineering applications. We will consider a solution of one differential equation as well as a solution of systems of differential equations. Equations of the higher orders can be transformed into a system of differential equations of the first order. In particular, we will study differential equations of the first order, both initial and boundary value problems.

Solution of the initial value problem by a one step method We solve the initial value (Cauchy) problem y = f (x, y), y(x 0 ) = y 0. Uniqueness and existence of a solution: If f (x, y) is continuous in Ω = {(x, y), x x 0 a, a > 0, y y 0 b, b > 0} and if we denote M = max f (x, y), α = min(a, b (x,y) Ω M ), then there exist a solution of the equation y = f (x, y) defined in the interval (x 0 α, x 0 + α). Moreover, if f is a Lipschitz function, i.e. f (x, y 1 ) f (x, y 2 ) L y 1 y 2 L > 0, (x, y 1 ), (x, y 2 ) Ω, the solution is unique. Remark: L... Lipschitz constant

Taylor expansion of the solution We are looking for a function y = y(t) such that dy dt = y = f (y, t), y(0) = y 0, 0 < t < T. Let us suppose that we have already computed the solution y n := y(t n) in time t n and we want to find a solution in time t n+1. Let h := t n+1 t n be the corresponding time step. Taylor expansion of y n+1 in the point y n: And y n?... etc. y n+1 = y n + h y n }{{} + h2 2 y n + h3 6 y n +... y = = f (y n, t n) from the differential equation ( ) dy = f dt t 1 + f y y = f t + f y f y = (ft + f fy) + t y (ft + f fy) f = ftt + 2f fyt + ft fy + f f y 2 + f 2 f yy,

Euler s method Euler s method Euler s method is based on the first two terms of the Taylor expansion: We choose y(0) := y 0 and construct a sequence y n+1 = y n + hf (y n, t n), i.e.,we replace the function y in the point (y n, t n) by a tangent to the integral curve at this point. Accuracy of calculation: Euler s method is the first order method. Remark The step of the method h can be changed with a particular iteration (adaptive choice of step): y n+1 = y n + h nf (y n, t n).

Euler s method Example Solve the following initial value problem by Euler s method. Find the solution in time t = 3, y = 0, 3 y sin(t), y(1) = 2. For simplicity, let us consider n = 4, i.e., h = 0.5. y j+1 = y j + h f (y j, t j ), where f (y j, t j ) = 0, 3y j sin(t j ). t j step 0.5 step 0.005 1 2 2 1.5 2.252441295 2.30249902026881692 2 2.589461130 2.66460601831410714 2.5 2.942649681 2.99089235783755570 3 3.206813761 3.16533517440834976

Euler s method Stability of Euler s method Let us solve the model problem y = λy, λ a constant (1) Euler s method = y n+1 = y n + λh y n, t.j. y n+1 = y n(1 + λ h), i.e., we obtain y n = y n 1 (1 + λ h) = y n 2 (1 + λ h) 2 =... = y 0 (1 + λ h) n. For λ = λ 1 + iλ 2... imaginary, we have y n = y 0 (1 + λ 1 h + iλ 2 h }{{} )n = y 0 σ n. σ... so called amplification factor The numerical solution is stable (i.e. it will remain limited for the growing (large) n, too), if σ 1.

Euler s method Let in (1), λ = λ 1 + iλ 2, λ 1 0, σ = 1 + λ 1 h + iλ 2 h. Then the region of stability for Euler s method is part of the left half of the complex plane, in particular inside of the circle σ 2 = (1 + λ 1 h) 2 + λ 2 2h 2 = 1. For any value of λh in the left half of the complex plane outside of this circle the numerical solution is blowing up, while the exact solution decreases. If we want to have a stable solution, we must reduce the h so, that λh would be inside the circle.

Euler s method Implicit (backward) Euler s method The y n+1 occurs in the equation implicitly: y n+1 = y n + h f (y n+1, t n+1 ) Disadvantage: the method is computationally more demanding than explicit Euler s method. Advantage: it is more stable, sometimes linearization of f can be exploited with advantage. Example Let us apply the implicit Euler s method to the model problem (1): We obtain: 1 y n+1 = y n + λhy n+1 = y n+1 = yn, i.e., 1 λh ( ) 2 ( ) n 1 1 1 y n = 1 λh y n 1 = y n 2 =... = y 0. 1 λh 1 λh y n = σ n y 0, σ = 1 1 λh.

Euler s method θ methods We can define the following one-parameter class of one-step methods, called θ methods: For a given initial approximation y 0, we define y n+1 as a convex combination of f (y n, t n) and f (y n+1, t n+1 ) (θ... parameter): y n+1 = y n + h[(1 θ)f (y n, t n) + θf (y n+1, t n+1 )], n = 0, 1,..., N 1, θ 0, 1. θ = 0 = y n+1 = y n + hf (y n, t n)... (explicit) Euler s method θ = 1 = y n+1 = y n + hf (y n+1, t n+1 )... implicit Euler s method θ = 1 2 = y n+1 = y n + 1 2 h[f (yn, tn) + f (y n+1, t n+1 )]... trapezoidal rule. It can be shown that a θ method is explicit for θ = 0 and it is implicit for 0 < θ 1.

Runge - Kutta methods Runge - Kutta methods Runge - Kutta methods (RK) more precise than Euler s methods: explicit: The solution in time t n+1 is computed from the values y n, f (y n, t n) and from f (y, t) enumerated at a point between points t n and t n+1 = better accuracy because we use more information about the function f. implicit: They usually lead to the solution of nonlinear algebraic equations, but the amount of work involved is balanced by better numerical stability.

Runge - Kutta methods RK method of the second order Let us have the equation y = f (y, t). In the time step t n+1, we obtain the solution from the equation where y n+1 = y n + γ 1 k 1 + γ 2 k 2, (2) k 1 = hf (y n, t n) k 2 = hf (y n + βk 1, t n + αh), α, β, γ 1, γ 2 R. The constants α, β, γ 1, γ 2 have to be determined in such a way that the method should have the highest order of accuracy possible. To determine the order of accuracy, we exploit the Taylor expansion of y(t n+1 ) y n+1 = y n + h y n }{{} + h2 2 y n }{{} + = f (y n, t n) f t + f f y y n+1 = y n + hf (y n, t n) + h2 2 (ftn + f nf yn )+ (3) and compare the coefficients in (2) and (3).

Runge - Kutta methods Taylor series for the function of two variables k 2 = hf (y n + βk 1, t n + αh) = ( ) k 2 = h f (y n, t n) + βk 1 f yn + αhf tn + O(h 2 ). Remark Symbol O (capital O) g(h) = O(h p ) g(h) C h p, C is a constant independent of h. Then y n+1 = y n + (γ 1 + γ 2 )hf n + γ 2 βh 2 f nf yn + γ 2 αh 2 f tn + We compare the result with (3) and obtain three nonlinear equations for 4 unknowns: γ 1 + γ 2 = 1, γ 2 α = 1 2, γ 2β = 1 2. Let α R be a parameter. Then γ 2 = 1 2α, β = α, γ 1 = (1 1 2α ).

Runge - Kutta methods We obtain Runge - Kutta methods of the order 2: k 1 = hf (y n, t n) k 2 = hf (y n + αk 1, t n + αh) y n+1 = y n + (1 1 2α )k 1 + 1 2α k 2. We choose α and get the method. For example α = 1 2 = γ 2 = 1, β = 1 2, γ 1 = 0 = y n+1 = y n + k 2 = y n + hf (y n + 1 2 k 1, t n + 1 2 h). Remark RK method of the 2nd order requires at each step twice quantification of function values.

Runge - Kutta methods RK methods of 4th order For solving initial value problem, the RK methods of 4th order are mostly used y n+1 = y n + 1 6 k 1 + 1 3 (k 2 + k 3 ) + 1 6 k 4, where k 1 = hf (y n, t n) k 2 = hf (y n + 1 2 k 1, t n + h 2 ) k 3 = hf (y n + 1 2 k 2, t n + h 2 ) k 4 = hf (y n + k 3, t n + h). At each step, we need to compute function values 4 times. Although laborious, the RK method of 4th order is stable and very accurate. It is easily programmable, because it requires no differentiation, only computation of function values.

Runge - Kutta methods Computational error Computational error a) y(t n)... exact solution in time t n, y n... approximate solution in time t n e n = y n y(t n)... global error of the approximation b) The computer works in finite arithmetic: r n = ỹ n y n... rounding error We want to compute f but in fact, we compute the numerical approximation ỹ n. For Euler s method: (1)... the global error of approximation e n, E n is directly proportional to the first power of h (2)... rounding error r n is inversely proportional to the first power of h (3)... total error for Euler s method About rounding errors, we can convince only if we repeat the calculation with the different pracission (double precission,... )