today’s class numerical differentiation finite difference methods numerical methods lecture 14...

32
Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Upload: eileen-peters

Post on 14-Dec-2015

237 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Today’s class

• Numerical Differentiation• Finite Difference Methods

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

1

Page 2: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Numerical Differentiation

• Finite Difference Methods• Forward• Backward• Centered

• Error Magnitude• O(h) for forward and backward• O(h2) for centered

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

2

Page 3: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Forward First Derivative

• Consider a function f(x) which can be expanded in a Taylor series in the neighborhood of a point x

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

3

Page 4: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Forward First Derivative

Numerical MethodLecture 14

Prof. Jinbo BiCSE, UConn

4

Page 5: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Backward First Derivative

• Consider a function f(x) which can be expanded in a Taylor series in the neighborhood of a point x

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

5

Page 6: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Backward First Derivative

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

6

Page 7: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Central First Derivative

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

7

Page 8: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Central First Derivative

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

8

Page 9: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Numerical Differentiation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

9

Page 10: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

2nd-order Forward Difference

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

10

Page 11: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

High-Accuracy Differentiation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

11

Page 12: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Forward Finite-Divided Difference

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

12

Page 13: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Backward Difference Scheme

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

13

+

Page 14: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Backward Finite-Divided Difference

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

14

Page 15: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Centered Difference Scheme

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

15

Page 16: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

16

Centered Divided Difference

Page 17: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

• Example:

• Find derivative at x=0.5, h=0.25• True

• Forward

Basic Differentiation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

17

Page 18: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

• Example:• Backward

• Centered

Basic Differentiation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

18

Page 19: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

• Forward

• Backward

• Centered

High-Accuracy Differentiation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

19

Page 20: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

• Forward Divided Difference method uses the value of points in front of or at the point where the derivative is calculated.

• Backward Divided Difference method uses the value of points behind of or at the point where the derivative is calculated.

Summary

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

20

Page 21: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

• Centered Divided Difference uses the value of points both in front and behind of the point where the derivative is calculated.

• Centered method is usually more accurate than forward & backward methods

• Accurate formulas use more points in the calculations.

Summary

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

21

Page 22: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

• As with integration, use two approximations to arrive at a better approximation

• D is the true value but unknown and D(h1) is an approximation based on the step size h1. Reducing the step size to half, h2 =h1/2, we obtained another approximation D(h2).

• By properly combining the two approximations, D(h1) & D(h2), the error is reduced to O(h4).

Richardson Extrapolation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

22

Page 23: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Richardson Extrapolation

2)( hhE

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

23

Page 24: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Richardson Extrapolation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

24

Page 25: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Richardson Extrapolation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

25

Page 26: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

• Example:• h=0.5

• h=0.25

• Extrapolate

Richardson’s Extrapolation

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

26

Page 27: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Unevenly Spaced Data

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

27

Page 28: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Unevenly Spaced Data

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

28

Page 29: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Unevenly Spaced Data

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

29

Page 30: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Unevenly Spaced Data

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

30

Page 31: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Unevenly Spaced Data

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

31

Page 32: Today’s class Numerical Differentiation Finite Difference Methods Numerical Methods Lecture 14 Prof. Jinbo Bi CSE, UConn 1

Next class

• Ordinary Differential Equations• Read Chapter PT7, 25

Numerical MethodsLecture 14

Prof. Jinbo BiCSE, UConn

32