EE3561_Unit 6(c)AL-DHAIFALLAH14351 EE 3561 : Computational Methods Unit 6 Numerical Differentiation...

Post on 18-Dec-2015

213 views 0 download

Tags:

Transcript of EE3561_Unit 6(c)AL-DHAIFALLAH14351 EE 3561 : Computational Methods Unit 6 Numerical Differentiation...

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 1

EE 3561 : Computational Methods

Unit 6Numerical

Differentiation

Dr. Mujahed AlDhaifallah ( Term 342)

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 2

Lecture 17Numerical Differentiation

First order derivatives High order derivatives Richardson Extrapolation Examples

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 3

Motivation

How do you evaluate the derivative of a tabulated function.

How do we determine the velocity and

acceleration from tabulated measurements.

Time(second)

Displacement

(meters)

0 30.1

5 48.2

10 50.0

15 40.2

• Calculus is the mathematics of change. Because engineers must continuously deal with systems and processes that change, they always need to estimate the value of f '(x) for a given function f(x)..• Standing in the heart of calculus are the mathematical concepts of differentiation and integration:

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 4

Recall Numerical differentiationand integration•The derivative represents the rate of change of a dependent variable with respect to an independent variable.

The difference approximation

If x is allowed to approach zero, the difference becomes a derivative

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 5

Difference Formulas

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 6

Recall

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 7

Three formula

them?judge wedo How better? is method Which

2

)()()(DifferenceCentral

)()()(DifferenceBackward

)()()(DifferenceForward

h

hxfhxf

dx

xdf

h

hxfxf

dx

xdf

h

xfhxf

dx

xdf

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 8

Forward Difference formula

)()()(

)('

)()()()('

)()(')()( :DifferenceBackward

_______________________________________________________

)()()(

)('

)()()()('

)()(')()(DifferenceForward

2

2

2

2

hOh

hxfxfxf

hOhxfxfhxf

hOhxfxfhxf

hOh

xfhxfxf

hOxfhxfhxf

hOhxfxfhxf

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 9

Central Difference formula

)(2

)()()('

...!3

)(2)('2)()(

...!4

)(

!3

)(

!2

)()(')()(

...!4

)(

!3

)(

!2

)()(')()(

DifferenceCentral

2

3)3(

4)4(3)3(2)2(

4)4(3)3(2)2(

hOh

hxfhxfxf

hxfhxfhxfhxf

hxfhxfhxfhxfxfhxf

hxfhxfhxfhxfxfhxf

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 10

The Three formula (revisited)

2

( ) ( ) ( )Forward Difference ( )

( ) ( ) ( )Backward Difference ( )

( ) ( ) ( )Central Difference ( )

2

Forward and backward difference formulas are comparable in accurcy

Cent

df x f x h f xO h

dx h

df x f x f x hO h

dx h

df x f x h f x hO h

dx h

ral difference formula is expected to give better answer

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 11

Higher Order Formulas

12

)(

)()()(2)(

)(

...!4

)(2

!2

)(2)(2)()(

...!4

)(

!3

)(

!2

)()(')()(

...!4

)(

!3

)(

!2

)()(')()(

2)4(

22

)2(

4)4(2)2(

4)4(3)3(2)2(

4)4(3)3(2)2(

hfError

hOh

hxfxfhxfxf

hxfhxfxfhxfhxf

hxfhxfhxfhxfxfhxf

hxfhxfhxfhxfxfhxf

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 12

Other Higher Order Formulas

ordererror theobtainand themprove toTheoremTaylor use can You

possible. also are)...(),(for formulasOther

)2()(4)(6)(4)2()(

2

)2()(2)(2)2()(

)()(2)()(

)3()2(

4)4(

3)3(

2)2(

xfxf

h

hxfhxfxfhxfhxfxf

h

hxfhxfhxfhxfxf

h

hxfxfhxfxf

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 13

HIGH-ACCURACY DIFFERENTIATION FORMULAS• The forward Taylor series expansion is:

• From this, we can write

• Substitute the second derivative approximation into the formula to yield:

• By collecting terms

21

1

''( )( ) ( ) ( )

2

( ) ( ) ''( )( )

2

ii i i

i i ii

f xf x f x f x h h

f x f x f xf x h

h

h

xfxfxfxf

hhxfxfxf

h

xfxfxf

iiii

iii

iii

2

)(3)(4)()(

2

)()(2)()()(

)(

12

212

1

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 14

HIGH-ACCURACY DIFFERENTIATION FORMULAS Inclusion of the 2nd derivative term has

improved the accuracy to O(h2). This is the forward divided difference

formula for the first derivative.

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 15

Forward Formulas

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 16

Backward Formulas

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 17

Centered Formulas

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 18

ExampleEstimate f '(1) for f(x) = ex + x using the centered

formula of O(h4) with h = 0.25.

• Solution

From Table 23.3:

5.15.012

25.125.01

1

75.025.01

5.05.012

12

)()(8)(8)()(

2

1

1

2

2112

hxx

hxx

x

hxx

hxx

h

xfxfxfxfxf

ii

ii

i

ii

ii

iiiii

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 19

• substituting the values results in

717.33

)149.2()867.2(8)740.4(8982.5

)25.0(12

)5.0()75.0(8)25.1(8)5.1()(

ffff

xf i

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 20

Numerical Differentiation Richardson Extrapolation Examples

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 21

Richardson Extrapolation

...)(')(

2

)()()(

)(

formula?better a get weCan

)(2

)()()('DifferenceCentral

66

44

22

2

hahahaxfh

h

hxfhxfh

fixedxandxfHold

hOh

hxfhxfxf

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 22

Richardson Extrapolation

4

66

44

6

6

4

4

2

2

66

44

22

3

)2

(4)()('

...16

15

4

3)('3)

2(4)(

...222

)(')2

(

...)(')(

2

)()()(

)(

hO

hh

xf

hahaxfh

h

ha

ha

haxf

h

hahahaxfh

h

hxfhxfh

fixedxandxfHold

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 23

Richardson Extrapolation TableD(0,0)=Φ(h)

D(1,0)=Φ(h/2) D(1,1)

D(2,0)=Φ(h/4) D(2,1) D(2,2)

D(3,0)=Φ(h/8) D(3,1) D(3,2) D(3,3)

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 24

Richardson Extrapolation Table

whend terminateissolution The•

)1,1()1,(14

1)1,(),(

2)0,(:

mnDmnDmnDmnD

others

hnDColumnFirst

m

n

smnmna DD 1,,

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 25

Example

.derivative theof

estimate theas D(2,2)Obtain0.1,h

withtion Extrapolan RichardsoUse

.6.0xat

of derivative y thenumericall Evaluatecos

(x)xf(x)

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 26

ExampleFirst Column

f(x h)-f(x-h)(h)

2hf(0.7)-f(0.5)

(0.1) 1.08480.2

f(0.65)-f(0.55)(0.05) 1.0899

0.1f(0.625)-f(0.575)

(0.025) 1.09110.05

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 27

ExampleRichardson Table

1.09157111214

11222

1.09157010214

10212

1.09156000114

10111

11114

11

09115.1D(2,0) 0.10988,D(1,0) , 08483.1)0,0(

2

),D(),D(),D(),D(

),D(),D(),D(),D(

),D(),D(),D(),D(

),m-D(n)D(n,m-)D(n,m-D(n,m)

D

m

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 28

ExampleRichardson Table

1.0848

1.0899 1.09157

1.0911 1.09157 1.09157

This is the best estimate of the derivative of the function

All entries of the Richardson table are estimates of the derivative of the function. The first column are estimates using the central difference formula with different h.

EE3561_Unit 6 (c)AL-DHAIFALLAH1435 29

Summary Several formulas are available to

determine first order, second order or higher order derivatives

Richardson Extrapolation provides high accuracy estimates of the first order derivative