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

Similar documents
How to Find the Derivative of a Function: Calculus 1

Function Composition and Chain Rules

LIMITS AND DERIVATIVES CONDITIONS FOR THE EXISTENCE OF A LIMIT

REVIEW LAB ANSWER KEY

lecture 26: Richardson extrapolation

Preface. Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

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

. Compute the following limits.

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

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.

INTRODUCTION TO CALCULUS LIMITS

Mathematics 105 Calculus I. Exam 1. February 13, Solution Guide

Click here to see an animation of the derivative

Material for Difference Quotient

Pre-Calculus Review Preemptive Strike

Lesson 6: The Derivative

Integral Calculus, dealing with areas and volumes, and approximate areas under and between curves.

Sin, Cos and All That

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

The derivative function

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.

Calculus I Homework: The Derivative as a Function Page 1

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

3.4 Worksheet: Proof of the Chain Rule NAME

SECTION 1.10: DIFFERENCE QUOTIENTS LEARNING OBJECTIVES

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

2.11 That s So Derivative

Copyright c 2008 Kevin Long

Lab 6 Derivatives and Mutant Bacteria

Continuity and Differentiability Worksheet

Introduction to Derivatives

Derivatives. By: OpenStaxCollege

2.3 Product and Quotient Rules

2.3 More Differentiation Patterns

Math 31A Discussion Notes Week 4 October 20 and October 22, 2015

Differential Calculus (The basics) Prepared by Mr. C. Hull

Continuity. Example 1

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.

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

158 Calculus and Structures

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

Definition of the Derivative

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

Section 3: The Derivative Definition of the Derivative

Polynomials 3: Powers of x 0 + h

Calculus I Practice Exam 1A

SECTION 3.2: DERIVATIVE FUNCTIONS and DIFFERENTIABILITY

7.1 Using Antiderivatives to find Area

Exam 1 Review Solutions

MAT 145. Type of Calculator Used TI-89 Titanium 100 points Score 100 possible points

Time (hours) Morphine sulfate (mg)

Practice Problem Solutions: Exam 1

Function Composition and Chain Rules

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 ).

THE IDEA OF DIFFERENTIABILITY FOR FUNCTIONS OF SEVERAL VARIABLES Math 225

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

The Derivative The rate of change

Math 212-Lecture 9. For a single-variable function z = f(x), the derivative is f (x) = lim h 0

232 Calculus and Structures

MTH 119 Pre Calculus I Essex County College Division of Mathematics Sample Review Questions 1 Created April 17, 2007

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

f a h f a h h lim lim

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

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

Some Review Problems for First Midterm Mathematics 1300, Calculus 1

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.

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

(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?

MVT and Rolle s Theorem

Exam 1 Solutions. x(x 2) (x + 1)(x 2) = x

3.4 Algebraic Limits. Ex 1) lim. Ex 2)

Differentiation Rules c 2002 Donald Kreider and Dwight Lahr

2.3 Algebraic approach to limits

Numerical Differentiation

1 Calculus. 1.1 Gradients and the Derivative. Q f(x+h) f(x)

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

Excursions in Computing Science: Week v Milli-micro-nano-..math Part II

10 Derivatives ( )

Chapter 1D - Rational Expressions

2.8 The Derivative as a Function

Taylor Series and the Mean Value Theorem of Derivatives

2.1 THE DEFINITION OF DERIVATIVE

MATH CALCULUS I 2.1: Derivatives and Rates of Change

1 Limits and Continuity

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

1 1. Rationalize the denominator and fully simplify the radical expression 3 3. Solution: = 1 = 3 3 = 2

Cubic Functions: Local Analysis

Notes on wavefunctions II: momentum wavefunctions

Combining functions: algebraic methods

Exercises for numerical differentiation. Øyvind Ryan

DEFINITION OF A DERIVATIVE

. If lim. x 2 x 1. f(x+h) f(x)

Poisson Equation in Sobolev Spaces

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

Math 312 Lecture Notes Modeling

Math 1210 Midterm 1 January 31st, 2014

Calculus I, Fall Solutions to Review Problems II

Teaching Differentiation: A Rare Case for the Problem of the Slope of the Tangent Line

MATH745 Fall MATH745 Fall

The total error in numerical differentiation

Transcription:

NUMERICAL DIFFERENTIATION James T Smit San Francisco State University In calculus classes, you compute derivatives algebraically: for example, f( x) = x + x f ( x) = x x Tis tecnique requires your knowing te formula for f and te appropriate differentiation rule Wat if you don t know a rule? One way is to refer to te definition of te derivative as te limit of te differential quotient f ( x+ ) f( x) f ( x) = lim 0 and evaluate te quotient for smaller and smaller until successive values don t cange significantly You can accept te last value as an adequate approximation to te derivative Te function f (x) = arctan x is a good example You don t learn its derivative very early in calculus classes, so you migt want to use tis metod On te oter and, tere is a formula, d arctan x =, + dx x so you can ceck te accuracy of te differential quotient approximation Figure gives te results for a typical argument x, wit a succession of smaller and smaller values Te error seems closely tied to te size of, until tat gets too small Te metod works well ere, but tere seems to be a limit to te accuracy Consider a less successful case: π x = 0 f( x) = sin x = 00 π π π f ( x) = cos = cosπ = 0π 346 x x 00 π π sin sin f( x+ ) f( x) sin0π sinπ = 0 0 = = 0 00 00 Clearly, you must take care wen you approximate a derivative tis way! In tese notes, you ll see ow to predict tis metod s beavior, so you can avoid taking too small, and avoid catastropes like te second example 6 December 00

Page NUMERICAL DIFFERENTIATION f (x) = arctan x x = 345678 f r(x) = 039678 f ( x+ ) f( x) Approximating f r(x) by Error = Approximation f r(x) Approximation Error 0E+0 060044 4E 0E 037759 9E 0E 039445 9E 3 0E 3 0395978 9E 4 0E 4 039654 9E 5 0E 5 0396698 9E 6 0E 6 039670 7E 7 0E 7 039668 36E 6 0E 8 0396375 34E 5 Figure Approximating a derivative by a differential quotient A major tool for analyzing approximation errors is te mean-value teorem, considered in your first calculus course Te teorem relates a difference in function arguments to te resulting difference in function values, as follows Suppose function f is defined and continuous at eac point x in a closed interval a # x # b, and differentiable at eac interior point Ten for some interior point ξ, f( b) f( a) = f ( ξ ) b a Te geometric interpretation is striking: te teorem says tat at some point <ξ, f (ξ)> te grap of f as te same slope as te secant troug points <a, f (a)> and <b, f (b)> Since te derivative isn t based on geometry, te proof of te teorem, found in calculus texts, requires detailed analysis In some cases you can actually calculate ξ: for example, if f (x) = x, ten ξ = ) (a + b) In general, owever, te teorem just asserts existence of ξ, and gives no information about its exact value To use te mean-value teorem to analyze te error f( x+ ) f( x) ε = f ( x)

NUMERICAL DIFFERENTIATION Page 3 resulting from approximating f r(x) by te differential quotient, first let a, b = x, x + so tat b a = Te teorem yields ξ between a and b suc tat ε = f r(ξ) f r(x) Now apply it again wit f replaced by f r, and a, b = x, ξ You get η between x and ξ suc tat *ε * = * f r(ξ) f r(x)* = *(ξ x) f O(η)* # M, provided M is an upper bound for all values * f O(η)* wit η between x and x + Tus, te approximation error doesn t exceed M From Taylor s teorem, considered in later calculus classes, you can derive a smaller error bound ) M Te following paragraps use tis version to analyze te beavior of te differential quotients in te earlier examples If f (x) = arctan x, ten x f ( x) =, + x and you can verify tat * f O(η)* # for all 0 between x = 345678 and x + Tus you can take M =, and te approximation error souldn t exceed ) Tat s true in figure for > 0 6, but it fails afterward Tere s no contradiction in te matematics tis analysis neglected someting tat appened in producing figure Before turning to tat, owever, consider te second example f (x) = sin(π/x): π π ( π ) π f ( x) = cos + sin 3 4 x x x x From te grap of f O you can see tat te largest value M 0000 of * f O(x)* on te interval 00 # x # 0 occurs at x 004 Wit = 00 you get te error bound ) M > 500, wic agrees wit te example and suggests tat te approximation may be very inaccurate Wy did te error ε in figure stop decreasing wit in spite of te bound ε # ) M? Te analysis tat led to tis inequality assumed tat te difference quotient was computed exactly But tat s not true In particular, calculating f wit any computer involves roundoff error Te two f values in te quotient are almost equal, so wen you subtract tem, roundoff errors may form a more significant part of te result Consider a simpler situation wit a different function f :

Page 4 NUMERICAL DIFFERENTIATION 00000005003 0000000400 = 00@0 8 ))))0))))-N ))))0))))- N N f (x + ) * f (x) * * ))))))0)))) ))- * Roundoff errors are in te t digit of te f values Resulting error is in te 4t digit of te difference Tis effect, subtractive cancellation error, is bad by itself But in te difference quotient, it s multiplied by a large factor, because is tiny Tus you can expect tat someting will go wrong wit tis approximation Can you predict wen? It s not difficult to use elementary calculus to determine wen te error stops decreasing Suppose te function values actually computed are f * (x + ) = f (x + ) + e f * (x) = f (x) + e, were f (x + ), f (x) are exact values and e, e are roundoff errors Ten te total error in te approximation is * * f ( x + ) f ( x) f( x + ) f( x) e e f ( x) = f ( x) + + f ( x ) f ( x ) f ( x) e e Wit Turbo Pascal Real aritmetic, used to compute Figure, *e *, *e * # 0 Tus te total error is bounded by M 0 0 E = + = + E() is smoot and approaces 4 as approaces 0+ or 4, ence it as a minimum value at some > 0 were 0 0 = E =, ie = 4 0, = 0 6 Tat te total approximation error is bounded by a function E() wit a minimum value at = 0 6 suggests tat te error will stop decreasing between = 0 5 and 0 6 Figure confirms tat Te previous discussion was devoted to computing a derivative in a situation were you could calculate te function at will, but ad no rule for differentiating it Wat if you only ave a table of function values? If you need an approximation to f r(x) for a

NUMERICAL DIFFERENTIATION Page 5 tabulated argument x, and x + is te next one, ten you can use te differential quotient f ( x+ ) f( x), and from te formula ) M predict te size of te approximation error (as long as is not so small as to cause subtractive cancellation roundoff error buildup) Of course, you d ave to know M If you don t, you souldn t trust approximate derivatives calculated tis way After all, you could construct anoter function g agreeing wit f at arguments x and x + By making go large enoug (increasing M ) you could make gr differ wildly from f r Te differential quotient formula would still yield an approximation to f r(x), not gr(x) If you re designing a table of values f (x) to facilitate calculating f r(x) by differential quotient approximation, and you know M, ten you can ensure tat te approximation error will not exceed a specified tolerance T by selecting so tat ) M < T You souldn t select small enoug, toug, to cause subtractive cancellation roundoff error buildup Many derivative approximation formulas more accurate tan te differential quotient are studied in numerical analysis Tese two are used in te commercial software package MatCAD : f + ( x ) f ( x f x ) f + + + ( x ) 8 f ( x ) 8 f ( x ) f ( x f x ) ) 6 M 3 ) 30 M 5 4 Te expressions at rigt are error bounds, disregarding roundoff error In general, M k stands for an upper bound of te values * f ( k ) (x)* wit x in te region of interest You sould be able to construct corresponding examples and error analyses analogous to te ones in tese notes Tat would test your understanding and sow you ow muc more accurate tese formulas are Reference Ricard L BURDEN and J Douglas FAIRES, Numerical analysis, 6t ed, Brooks/Cole, 997 4