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

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

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

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

Module 2: Single Step Methods Lecture 4: The Euler Method. The Lecture Contains: The Euler Method. Euler's Method (Analytical Interpretations)

Ordinary Differential Equations

Math 225 Scientific Computing II Outline of Lectures

Lecture 8: Euler s Methods

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

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

CS205b/CME306. Lecture 9

Review Initial Value Problems Euler s Method Summary

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

Section 18-1: Graphical Representation of Linear Equations and Functions

Finite difference methods

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

Mathematics for chemical engineers

dy = dx y dx Project 1 Consider the following differential equations: I. xy II. III.

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

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

Accuracy versus precision

2.1 Derivatives and Rates of Change

AMSC/CMSC 460 Final Exam, Fall 2007

The Euler and trapezoidal stencils to solve d d x y x = f x, y x

MATH2071: LAB 2: Explicit ODE methods

Homework 14 solutions

Lecture 22: Rules for Solving IVP

Computer Simulations

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method.

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

Homework Set #2-3, Math 475B

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

Application 2.4 Implementing Euler's Method

ChE 400: Applied Chemical Engineering Calculations Tutorial 6: Numerical Solution of ODE Using Excel and Matlab

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

Ordinary differential equations solving methods

Direction Fields; Euler s Method

Quasilinear First-Order PDEs

8 Piecewise Polynomial Interpolation

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Linear and Quadratic Least Squares

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

CALCULUS MADE EASY - FUNCTIONALITY for the TiNspire CAS

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

Computational Methods. Sources of Errors

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

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

Section 1.5. Finding Linear Equations

7.1 First-order initial-value problems

DOWNLOAD PDF BIG IDEAS MATH VERTICAL SHRINK OF A PARABOLA

4 Visualization and. Approximation

CALCULUS WITH PHYSICS APPLICATIONS - FUNCTIONALITY for the TiNspire CAS CX

First of all, we need to know what it means for a parameterize curve to be differentiable. FACT:

Asymptotic Error Analysis

Error in Numerical Methods

Polynomial Approximation and Interpolation Chapter 4

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

CS 130. Scan Conversion. Raster Graphics

GRAPHING WORKSHOP. A graph of an equation is an illustration of a set of points whose coordinates satisfy the equation.

Isn t it Saturday? IMO Trainning Camp NUK, 2004_06_19 2

Each point P in the xy-plane corresponds to an ordered pair (x, y) of real numbers called the coordinates of P.

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

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

Index. C m (Ω), 141 L 2 (Ω) space, 143 p-th order, 17

Differentiation. The Derivative and the Tangent Line Problem 10/9/2014. Copyright Cengage Learning. All rights reserved.

Rasterization: Geometric Primitives

Introduction to Computational Mathematics

1) Find. a) b) c) d) e) 2) The function g is defined by the formula. Find the slope of the tangent line at x = 1. a) b) c) e) 3) Find.

Math Homework 3

Lecture Objectives. Structured Programming & an Introduction to Error. Review the basic good habits of programming

2.2 Graphs Of Functions. Copyright Cengage Learning. All rights reserved.

Using Modified Euler Method (MEM) for the Solution of some First Order Differential Equations with Initial Value Problems (IVPs).

Determination of Inner and Outer Bounds of Reachable Sets

MATH 115: Review for Chapter 1

Today s class. Roots of equation Finish up incremental search Open methods. Numerical Methods, Fall 2011 Lecture 5. Prof. Jinbo Bi CSE, UConn

13.1. Functions of Several Variables. Introduction to Functions of Several Variables. Functions of Several Variables. Objectives. Example 1 Solution

Fall 2016 CS130 - Regression Analysis 1 7. REGRESSION. Fall 2016

MPM 1D Learning Goals and Success Criteria ver1 Sept. 1, Learning Goal I will be able to: Success Criteria I can:

ORDINARY DIFFERENTIAL EQUATIONS

Using Excel for Graphical Analysis of Data

Chapter 6. Semi-Lagrangian Methods

Math 21a Tangent Lines and Planes Fall, What do we know about the gradient f? Tangent Lines to Curves in the Plane.

Differentiation. J. Gerlach November 2010

Objectives. Materials

East Penn School District Secondary Curriculum

ÇANKAYA UNIVERSITY Department of Industrial Engineering SPRING SEMESTER

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

Euler s Method for Approximating Solution Curves

1.2 Numerical Solutions of Flow Problems

Approximate Solutions to Differential Equations Slope Fields (graphical) and Euler s Method (numeric) by Dave Slomer

16.1 Runge-Kutta Method

CHAPTER 8: INTEGRALS 8.1 REVIEW: APPROXIMATING INTEGRALS WITH RIEMANN SUMS IN 2-D

Chemical Reaction Engineering - Part 4 - Integration Richard K. Herz,

CPSC / Scan Conversion

Lecture 8. Divided Differences,Least-Squares Approximations. Ceng375 Numerical Computations at December 9, 2010

SYSTEMS OF NONLINEAR EQUATIONS

Physics Tutorial 2: Numerical Integration Methods

practice: quadratic functions [102 marks]

Line Drawing Week 6, Lecture 9

Numerical Integration

3.3 Here are VBA and MATLAB implementations of the algorithm:

Transcription:

Euler s Methods

ODE IVP An Ordinary Differential Equation (ODE) is an equation that contains a function having one independent variable: The equation is coupled with an initial value/condition (i.e., value of y at x = 0). Hence, such equation is usually called ODE Initial Value Problem (IVP). Different notations for derivatives: Space/position: Time:

Recall Taylor Series (Lecture 1) If the y-axis and origin are moved a units to the left, the equation of the same curve relative to the new axis becomes y = f(a+x) and the function value at P is f(a). y Q y=f(a+x) P f(0) f(a) f(a+h) At point Q: 0 a h x

Euler s Method from Taylor Series The approximation used with Euler s method is to take only the first two terms of the Taylor series: In general form: new value = old value + step size slope If and as well as then (7.1)

Euler s (Forward) Method Alternatively, from step size and rearrange to we use the Taylor series to approximate the function around with step size Taking only the first derivative: where and is the differential equation evaluated at (7.2) This formula is referred to as Euler s forward method, or explicit Euler s method, or Euler-Cauchy method, or pointslope method.

Example of Euler s Forward Method Obtain a numerical solution of the differential equation given the initial conditions that when the range with intervals of 0.2. for Solution: with By Euler s method:

Example of Euler s Forward Method At where then If the step by step Euler s method is continued, we can present the results in a table: x i y i y i 1 4 2 1.2 4.4 2.2 1.4 4.84 2.36 1.6 5.312 2.488 1.8 5.8096 2.5904 2 6.32768

Example of Euler s Forward Method To compare the approximations from Euler s method with the exact solution, the ODE can be solved analytically using integrating factor method. Rearrange the equation into the form (7.3) so now where and Take the integrating factor and with The general solution of the equation (7.3) is: thus (7.4)

Example of Euler s Forward Method from which The second term on the right hand side is solved using integration by parts. Hence When thus from which Therefore or:

Example of Euler s Forward Method

MATLAB ImplementaGons function [x,y] = EulerForward(f,xinit,xend,yinit,h) % Number of iterations N = (xend-xinit)/h; % Initialize arrays % The first elements take xinit and yinit, correspondingly, % the rest fill with 0s. x = zeros(1, N+1); y = zeros(1, N+1); x(1) = xinit; y(1) = yinit; for i=1:n x(i+1) = x(i)+h; y(i+1) = y(i) + h*feval(f,x(i),y(i)); end end

MATLAB ImplementaGons function dydx = EulerFunction(x,y) dydx = 3*(1+x)-y; end a = 1; b = 2; ya = 4; h = 0.2; N = (b-a)/h; t = a:h:b; [x,y] = EulerForward('EulerFunction', a, b, ya, h); ye = y; % Numerical solution from using Euler s forward method yi = 3*t+exp(1-t); % Exact solution hold on; plot(t,yi,'r','linewidth', 2); plot(t,ye,'b','linewidth', 2); hold off; box on;

Error Analysis The numerical solution of ODEs involves two types of error: (1) Truncation, or discretization errors caused by the nature of the techniques used to approximate values of y. (2) Round-off errors, caused by the limited numbers of significant digits that can be retained by a computer. The truncation errors are composed of two parts: (a) Local truncation error à from an application of the method in question over a single step. (b) Propagated truncation error à from approximations produced during the previous step The sum of (a) and (b) is the global truncation error.

Error Analysis The local truncation error is the difference between the numerical solution after one step y 1 and the exact solution at Using equation (7.2), the numerical solution is given by: (7.5) where For the exact solution, we use the Taylor expansion of the function y around x 0 : (7.6)

Error Analysis Subtracting equation (7.6) from (7.5) yields The difference between the exact and the numerical solutions is the true local truncation error E t : (7.7) The expression (7.7) shows that for sufficiently small h, the errors usually decrease as the order increases, the result is represented as the approximate local truncation error: or

Error Analysis Because Euler s method uses straight-line segments to approximate the solution, hence the method is also referred to as a first-order method. From error estimates shown in Lecture 6, then the global truncation error In general, if the local truncation error is the global truncation error is

Effect of Reduced Step on Euler s Method From the previous example Reducing the interval or step size to 0.1 within the range we get: x i y i y i 1 4 2 1.1 4.2 2.1 1.2 4.41 2.19 1.3 4.629 2.271 1.4 4.8561 2.3439 1.5 5.09049 2.40951 1.6 5.331441 2.468559 1.7 5.5782969 2.5217031 1.8 5.83046721 2.56953279 1.9 6.087420489 2.612579511 2 6.3486784401 2.6513215599

Effect of Reduced Step on Euler s Method

Improvements of Euler s Method (1) Heun s Method Recall in Euler s method: is used to extrapolate linearly to (7.8) (7.9) which is called a predictor equation. It provides an estimate of that allows the calculation of an estimated slope at the end of the interval: (7.10)

Improvements of Euler s Method Thus, the two slopes in (7.8) and (7.10) can be combined to obtain an average slope The average slope is used to extrapolate linearly from y i to y i+1 using Euler s method: Or Predictor: Corrector: (7.11) (7.12)

Improvements of Euler s Method (2) Midpoint Method To predict a value of y at the midpoint of the interval: This predicted value is used to calculate a slope at the midpoint:

Improvements of Euler s Method The slope is then used to extrapolate linearly from to get to (7.13)

Stability The (explicit) forward Euler s method is easy to implement. The drawback arises from the limitations on the step size to ensure numerical stability. To see this, let s examine a linear IVP given by (7.14) with The exact solution of (7.14) is and a very smooth solution with, which is a stable

Stability Applying the (explicit) forward Euler s method: To prevent the amplification of the errors in the iteration process, we require, for stability of the forward Euler s method:

Backward Euler s Method The backward method computes the approximations using which is an implicit method, in the sense that in order to find y i+1 the nonlinear equation (7.15) has to be solved. (7.15)

Example of Euler s Backward Method Using the same example as in the forward method with h = 0.2 Solution: with By Euler s backward method: (7.16) where Substitute this into (7.16) and

Example of Euler s Backward Method now with we solve for And we use it to get the slope

Example of Euler s Backward Method The next iteration is where and the next point of iteration we solve for And continue the iteration until

Example of Euler s Backward Method

MATLAB ImplementaGons function [x,y] = EulerBackward(f,xinit,xend,yinit,h) % number of iterations N = (xend-xinit)/h; % Initialize arrays % The first elements take xinit and yinit, correspondingly, % the rest fill with 0s. x = [xinit zeros(1, N)]; y = [yinit zeros(1, N)]; for i=1:n x(i+1) = x(i)+h; ynew = y(i) + h*feval(f,x(i),y(i)); y(i+1) = y(i) + h*feval(f,x(i+1),ynew); end

MATLAB ImplementaGons function dydx = EulerFunction(x,y) dydx = 3*(1+x)-y; end clear all close all a = 1; b = 2; ya = 4; h = 0.1; t = a:h:b; [x,y] = EulerBackward('EulerFunction', a, b, ya, h); ye = y; % Numerical solution from using Euler s backward method yi = 3*t+exp(1-t); % Exact solution, for comparison hold on; plot(t,yi,'r','linewidth', 2); plot(t,ye,'b','linewidth', 2); hold off; box on;