AMS 147 Computational Methods and Applications Lecture 09 Copyright by Hongyun Wang, UCSC. Exact value. Effect of round-off error.

Similar documents
The total error in numerical differentiation

Runge-Kutta methods. With orders of Taylor methods yet without derivatives of f (t, y(t))

Consider a function f we ll specify which assumptions we need to make about it in a minute. Let us reformulate the integral. 1 f(x) dx.

Physically Based Modeling: Principles and Practice Implicit Methods for Differential Equations

Numerical Analysis MTH603. dy dt = = (0) , y n+1. We obtain yn. Therefore. and. Copyright Virtual University of Pakistan 1

232 Calculus and Structures

LECTURE 14 NUMERICAL INTEGRATION. Find

Section 2.7 Derivatives and Rates of Change Part II Section 2.8 The Derivative as a Function. at the point a, to be. = at time t = a is

Function Composition and Chain Rules

Higher Derivatives. Differentiable Functions

4.2 - Richardson Extrapolation

lecture 26: Richardson extrapolation

Numerical Differentiation

1 The concept of limits (p.217 p.229, p.242 p.249, p.255 p.256) 1.1 Limits Consider the function determined by the formula 3. x since at this point

7.1 Using Antiderivatives to find Area

1 Lecture 13: The derivative as a function.

MA119-A Applied Calculus for Business Fall Homework 4 Solutions Due 9/29/ :30AM

Lecture XVII. Abstract We introduce the concept of directional derivative of a scalar function and discuss its relation with the gradient operator.

(4.2) -Richardson Extrapolation

Math 1210 Midterm 1 January 31st, 2014

Introduction to Derivatives

LIMITATIONS OF EULER S METHOD FOR NUMERICAL INTEGRATION

HOMEWORK HELP 2 FOR MATH 151

Differential equations. Differential equations

Continuity and Differentiability Worksheet

NUMERICAL DIFFERENTIATION

3.1 Extreme Values of a Function

Applied Linear Statistical Models. Simultaneous Inference Topics. Simultaneous Estimation of β 0 and β 1 Issues. Simultaneous Inference. Dr.

4. The slope of the line 2x 7y = 8 is (a) 2/7 (b) 7/2 (c) 2 (d) 2/7 (e) None of these.

Order of Accuracy. ũ h u Ch p, (1)

NUMERICAL DIFFERENTIATION. James T. Smith San Francisco State University. In calculus classes, you compute derivatives algebraically: for example,

REVIEW LAB ANSWER KEY

How to Find the Derivative of a Function: Calculus 1

Rules of Differentiation

Section 2.1 The Definition of the Derivative. We are interested in finding the slope of the tangent line at a specific point.

2.3 Algebraic approach to limits

Bob Brown Math 251 Calculus 1 Chapter 3, Section 1 Completed 1 CCBC Dundalk

MVT and Rolle s Theorem

THE IDEA OF DIFFERENTIABILITY FOR FUNCTIONS OF SEVERAL VARIABLES Math 225

Differential Equations

1watt=1W=1kg m 2 /s 3

The Derivative The rate of change

The Verlet Algorithm for Molecular Dynamics Simulations

1. Questions (a) through (e) refer to the graph of the function f given below. (A) 0 (B) 1 (C) 2 (D) 4 (E) does not exist

Math 102 TEST CHAPTERS 3 & 4 Solutions & Comments Fall 2006

Lesson 6: The Derivative

Fall 2014 MAT 375 Numerical Methods. Numerical Differentiation (Chapter 9)

f a h f a h h lim lim

LIMITS AND DERIVATIVES CONDITIONS FOR THE EXISTENCE OF A LIMIT

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

Finite Difference Method

1 Limits and Continuity

Combining functions: algebraic methods

(5.5) Multistep Methods

Calculus I Homework: The Derivative as a Function Page 1

Solve exponential equations in one variable using a variety of strategies. LEARN ABOUT the Math. What is the half-life of radon?

1. Which one of the following expressions is not equal to all the others? 1 C. 1 D. 25x. 2. Simplify this expression as much as possible.

Derivatives and Rates of Change

University Mathematics 2

lim 1 lim 4 Precalculus Notes: Unit 10 Concepts of Calculus

1 2 x Solution. The function f x is only defined when x 0, so we will assume that x 0 for the remainder of the solution. f x. f x h f x.

2.11 That s So Derivative

Introduction to Machine Learning. Recitation 8. w 2, b 2. w 1, b 1. z 0 z 1. The function we want to minimize is the loss over all examples: f =

2.8 The Derivative as a Function

MATH745 Fall MATH745 Fall

Precalculus Test 2 Practice Questions Page 1. Note: You can expect other types of questions on the test than the ones presented here!

Continuity and Differentiability of the Trigonometric Functions

Chapter 4: Numerical Methods for Common Mathematical Problems

158 Calculus and Structures

Name: Answer Key No calculators. Show your work! 1. (21 points) All answers should either be,, a (finite) real number, or DNE ( does not exist ).

Practice Problem Solutions: Exam 1

1. Consider the trigonometric function f(t) whose graph is shown below. Write down a possible formula for f(t).

Recall from our discussion of continuity in lecture a function is continuous at a point x = a if and only if

Chapters 19 & 20 Heat and the First Law of Thermodynamics

A.P. CALCULUS (AB) Outline Chapter 3 (Derivatives)

3.4 Worksheet: Proof of the Chain Rule NAME

Copyright c 2008 Kevin Long

MAT244 - Ordinary Di erential Equations - Summer 2016 Assignment 2 Due: July 20, 2016

Function Composition and Chain Rules

1.72, Groundwater Hydrology Prof. Charles Harvey Lecture Packet #9: Numerical Modeling of Groundwater Flow

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER /2019

Pre-Calculus Review Preemptive Strike

AMS 212A Applied Mathematical Methods I Lecture 14 Copyright by Hongyun Wang, UCSC. with initial condition

DELFT UNIVERSITY OF TECHNOLOGY Faculty of Electrical Engineering, Mathematics and Computer Science

Differentiation in higher dimensions

IEOR 165 Lecture 10 Distribution Estimation

7 Semiparametric Methods and Partially Linear Regression

Test 2 Review. 1. Find the determinant of the matrix below using (a) cofactor expansion and (b) row reduction. A = 3 2 =

= 0 and states ''hence there is a stationary point'' All aspects of the proof dx must be correct (c)

Lab 6 Derivatives and Mutant Bacteria

5 Ordinary Differential Equations: Finite Difference Methods for Boundary Problems

Section 15.6 Directional Derivatives and the Gradient Vector

Solution. Solution. f (x) = (cos x)2 cos(2x) 2 sin(2x) 2 cos x ( sin x) (cos x) 4. f (π/4) = ( 2/2) ( 2/2) ( 2/2) ( 2/2) 4.

Key Concepts. Important Techniques. 1. Average rate of change slope of a secant line. You will need two points ( a, the formula: to find value

MTH-112 Quiz 1 Name: # :

Click here to see an animation of the derivative

5.1 We will begin this section with the definition of a rational expression. We

(a) At what number x = a does f have a removable discontinuity? What value f(a) should be assigned to f at x = a in order to make f continuous at a?

Lecture 21. Numerical differentiation. f ( x+h) f ( x) h h

Derivatives of Exponentials

Transcription:

Lecture 09 Copyrigt by Hongyun Wang, UCSC Recap: Te total error in numerical differentiation fl( f ( x + fl( f ( x E T ( = f ( x Numerical result from a computer Exact value = e + f x+ Discretization error ( + f( x 3 Effect of round-off error Te total error diverges to infinity as goes to zero. Composite trapezoidal rule N 1 b f + f + f 0 N i = i=1 f ( x dx + E a Error Numerical approximation E( = O ( Exact value Composite Simpson rule N 1 N b 6 f + f + f 0 N i + 4 f i1/ = i=1 i =1 f ( x dx + E a Error E( = O ( 4 Numerical approximation (Draw tumerical grid to explain f i and f i1/. Exact value For boumerical differentiation and numerical integration, we ave Penalty for using very small Advantage for using iger order metod - 1 -

Numerical error estimation Consider te error in a numerical result: Error = Numerical result Exact value Question: How to estimate te error wen te exact value is unknown? Here we consider te situation were te total error is dominated by te discretization error and te effect of round-off error can beglected. We first introduce totation. Notation: Let T( be tumerical approximation to quantity I, obtained wit step size using a p-t order numerical metod. T( = I E were Numerical approximation + Exact value Error E( = C p + o ( p ==> T = I + C p + o ( p Example: Second order numerical differentiation metod for approximating f f ( x + f ( x = f ( x + E ( I Error T E( = C + o ( ( x: Example: Composite Simpson s rule for approximating b a f x dx - -

N 1 N 6 f + f + f 0 N i + 4 f i1/ i=1 i=1 = f( x dx + E( a Error T( I E( = C + o b Goal: to estimate E( wen te exact value of quantity I is unknown. Strategy: we calculate T( and T(/. T = I + C p + o p T = I + C p + o ( p ==> T T = 1 1 T T ==> C p = 1 1 p Using E( C p, we obtain T E p Cp + o p + o ( p T 1 1 p Tis is ow we estimate te error numerically wen te exact value is unknown. If p (te order of tumerical metod is unknown, we simply use ~ T E T Estimating te order of a metod E( C p E C p - 3 -

==> E E E ==> p log E AMS 147 Computational Metods and Applications p T ( T Using E( 1 1 p, we obtain T ( T p log T T 4 Tis is ow we estimate te order of accuracy of a numerical metod. Numerical solutions of ODEs Goal: to solve te initial value problem y = F y,t y( 0= y 0 We introduce tumerical grid = n, n = 0, 1,,, N t N = N= T were is called te time step. Te first metod we introduce is Euler metod. Euler metod: At, te differential equation is y ( = Fyt ( ( n, Strategy: use yt ( n+1 yt ( n to approximate y ( t n. yt ( ==> n+1 yt ( n Fyt ( ( n, - 4 -

==> yt ( n+1 yt ( n + F( y(, wic leads to te Euler metod y n+1 = y n + F( y n, y n : numerical approximation of y Note: te Euler metod is an explicit metod. To fully understand te difference between explicit metods and implicit metods, we introduce backward Euler metod, wic is an implicit metod. Backward Euler metod: At +1, te differential equation is y ( +1 = Fyt ( ( n +1, +1 Strategy: use yt ( n+1 yt ( n to approximate y ( t n +1. yt ( n+1 yt ( n Fyt ( ( n +1, +1 ==> yt ( n+1 yt ( n + F( y( +1,+1 wic leads to te backward Euler metod y n+1 = y n + F( y n+1, +1 Note: te backward Euler metod is an implicit metod. In te backward Euler metod, y n+1 is not given as an explicit expression. Instead, y n+1 is given as te solution of an equation. If function F(y, t is non-linear in y, te equation is a non-linear equation. Error analysis Notation: Exact solution y(t is a continuous function of t. Numerical solution {y 0, y 1, y,, y N } contains approximations at discrete times. Note: te size of numerical solution increases as time step is reduced. t N = N= T Global error: - 5 -

( = def y N yt N Numerical solution at t N Exact solution at t N were t N = N = T is fixed as 0. (Draw a grap of yt ( N and y N to sow te global error Goal of te error analysis: ( = y N yt ( N. To find te order of global error To acieve tat goal, we firseed to study te local truncation error. Local truncation error (LTE: Wen we substitute an exact solution of y = F y,t term is called te local truncation error. into tumerical metod, te residual Local truncation error (LTE of Euler metod: We write te Euler metod as y n+1 y n F( y n, = 0 Let yt be an exact solution of y = Fy,t. Te local truncation error (LTE is ( = yt ( n+1 yt ( n F( y(, We use te Taylor expansion to find te order of te local truncation error (LTE. We do Taylor expansion of yt ( n+1 = yt ( n + around. ( = y = + y ( + y ( y ( + = O ( + yt ( n F y(, Local truncation error (LTE of backward Euler metod We write te backward Euler metod as y n+1 y n F( y n+1, +1 = 0 Te local truncation error (LTE is ( = yt ( n+1 yt ( n F y( +1, +1-6 -

Again, we use te Taylor expansion to find te order of te local truncation error (LTE. We do Taylor expansion of yt ( n = yt ( n +1 around +1. ( = yt ( n+1 yt ( n +1 y ( +1 + y ( +1 + = y +1 + = O ( F y( +1, +1 Now we connect te local truncation error (LTE to te global error. Global error ( = y N yt ( N is wat we want to know. Local truncation error (LTE ( is wat we can derive using Taylor expansion. Question: How is ( related to (? Teorem: If ( = O ( p +1, ten ( = O ( p. Tat is, te global error is one order lower tan te local truncation error (LTE. (Te proof of te teorem is given in te Appendix. Using te teorem above, we examine te global error of Euler metod and te global error of backward Euler metod. Global error of Euler metod Local truncation error: ( = O ==> Global error ( = O ==> Euler metod is a first order metod. Global error of backward Euler metod: Local truncation error ( = O ==> Global error ( = O ==> Te backward Euler metod is a first order metod. For a first order metod, wen we reduce te time step by a factor of, te global error = O decreases only by a factor of. We like to ave iger order metods. - 7 -

Second order metods: At, te differential equation is y ( = Fyt ( ( n, Strategy: use yt ( n+1 yt ( n1 to approximate y (. yt ( ==> n+1 yt ( n1 F( y(, ==> yt ( n+1 yt ( n1 + F y(, wic leads to te midpoint metod. Te midpoint metod (also called te leap frog metod y n+1 = y n1 + F( y n, Local truncation error (LTE of te midpoint metod ( = yt ( n+1 yt ( n1 F y(, We do Taylor expansions of yt ( n+1 = yt ( n + and yt ( n1 = yt ( n around. ( = yt ( n + y( + y yt ( n y( + y = y ( 3 3! 3 + = O ( 3 + y ( 3 3! y ( 3 3! 3 + Global error of te midpoint metod is (by te teorem above ( = O 3 + F y (, ==> Te midpoint metod is a second order metod. Note: Te midpoint metod does not work well. It is numerically unstable. We will demonstrate its instability in computer illustration. A new approac (for constructing numerical metods Start wit te differential equation y = Fy,t - 8 -

Integrating from to +1, we ave +1 yt ( n+1 yt ( n = F( y(,t t dt Strategy: use te trapezoidal rule to approximate te integral on te rigt and side. yt ( n+1 yt ( n = F y (,, +1 wic leads to te trapezoidal metod. Te trapezoidal metod: y n+1 = y n + Fy n, ( + Fyt ( n+1 + O ( 3 ( + Fy ( n+1, +1 Local truncation error of te trapezoidal metod is ( = yt ( n+1 yt ( n F ( y (, + F y( +1, +1 = O ( 3 ( (based on te discretization error of te trapezoidal rule. Global error of te trapezoidal metod is (by te teorem above ( = O ==> Te trapezoidal metod is a second order metod. Note: te trapezoidal metod is an implicit metod. - 9 -

Appendix Teorem: If ( = O ( p +1, ten ( = O ( p. Proof of te teorem: To prove te teorem, weed to look at anoter type of error. Error of one step: Let y ( t be te exact solution of Error of one step is defined as y = F y,t. yt ( n = y n e n ( def = y ( +1 y n +1 (Draw a grap of y n+1 and y ( +1 to sow te error of one step For te Euler metod (as a representative of explicit metods, we ave e n ( = y ( +1 y n+1 = y ( +1 y n F( y n, = y ( +1 y ( F( y (, = ( For explicit metods, error of one step is te same as local truncation error. For te backward Euler metod (as a representative of implicit metods, we ave e n ( = y ( +1 y n+1 = y ( +1 y n F( y n+1, +1 = y ( +1 y ( F( y ( +1,+1 + F ( y ( +1,+1 F ( y n+1, +1 = ( + F y = ( + F y e n ( ( y ( +1 y n+1 ==> e n ( 1 F = e y n ==> 1 ( = ( 1 F y = 1 + F y + O - 10 -

In general, error of one step and local truncation error ave te same leading term. Wit te elp of error of one step, wow write out te proof of te teorem. E 0 ( = 0 E n +1 ( = yt ( n +1 y n +1 = yt ( n +1 y ( +1 y ( +1 y n +1 + ( + ==> E n +1 ( y+1 y +1 y ( +1 y n+1 (E01 Te second term on te rigt and side of (E01 is error of one step y ( +1 y n +1 = e n ( = Oe ( n ( = O p+1 ==> y ( +1 y n+1 C p +1 Te first term on te rigt and side of (E01 is te difference between two exact solutions. Bot yt and y ( t satisfy y = Fy,t. But tey ave different starting values at. Te teory of ODE tells us tat yt y ( t e ct y( y ( for t Setting t = +1 and =, we ave y +1 y +1 e c y Substituting tese into (E01, we get E n +1 y = e c yt ( n y n = e c E n ( ( e c E n ( + C p +1 (E0 Tis is a recursive inequality valid for all values of n. We are going to use it to estimate were N = T. Let = e c. Dividing bot sides of (E0 by n+1, we obtain E n +1 ( E n ( + C n+1 n p+1 1 n +1 Summing over n = 0,1,,, N 1, we get ( E 0( + C N 0 p+1 1 + 1 + + 1 N Recall tat te sum of a geometric series is given by 1 + r + + r N 1 = rn 1 r 1 (E03-11 -

==> 1 + 1 + + 1 = 1 N N ( 1 + + +N1 = 1 N Substituting it into (E03 and using E 0 ( = 0, we ave ( C p +1 N 1 1 N 1 1 (E04 Using te inequality e x 1 x, we obtain 1 = e c 1 c N 1 = e cn 1 = e ct 1 Tus, we arrive at ( C p +1 e ct 1 c = C ect 1 c p ==> ( = O ( p - 1 -