Finite Difference Method Motivation For a given smooth function ! - - PowerPoint PPT Presentation

finite difference method
SMART_READER_LITE
LIVE PREVIEW

Finite Difference Method Motivation For a given smooth function ! - - PowerPoint PPT Presentation

Finite Difference Method Motivation For a given smooth function ! " , we want to calculate the derivative ! " at a given value of ". I = -0 Suppose we dont know how to compute the analytical expression for ! " , or


slide-1
SLIDE 1

Finite Difference Method

slide-2
SLIDE 2

Motivation

For a given smooth function ! " , we want to calculate the derivative !′ " at a given value of ". Suppose we don’t know how to compute the analytical expression for !′ " ,

  • r it is computationally very expensive. However you do know how to evaluate

the function value: We know that:

!′ # = lim

!→#

! # + ℎ − !(#) ℎ

Can we just use !′ " ≈

! "#$ %! " $

as an approximation? How do we choose ℎ? Can we get estimate the error of our approximation?

=

I

N

I

slide-3
SLIDE 3

For a differentiable function !: ℛ → ℛ, the derivative is defined as:

&′ ( = lim

!→#

& ( + ℎ − &(() ℎ

Taylor Series centered at %, where ̅ % = % + ℎ

& ( + ℎ = & ( + &$ ( ℎ + &′′ (

!! % +&′′′ ( !" & + ⋯

& ( + ℎ = & ( + &$ ( ℎ + 3(ℎ%)

We define the Forward Finite Difference as: Therefore, the truncation error of the forward finite difference approximation is bounded by:

Finite difference method

f-

'

Cx)

= fGth7h-f# t

O Ch)

  • ff (x)
= fGth)n

f

'G) = dfCx) to Ch )
  • I fKH
  • df Cx)

/ f M h

slide-4
SLIDE 4

In a similar way, we can write: ! % − ℎ = ! % − !! % ℎ + +(ℎ") → !! % = ! % − ! % − ℎ ℎ + +(ℎ) And define the Backward Finite Difference as: .! % = ! % − ! % − ℎ ℎ → !! % = .! % + +(ℎ) And subtracting the two Taylor approximations ! % + ℎ = ! % + !! % ℎ + !′′ %

#! " +!′′′ % #" $ + ⋯

! % − ℎ = ! % − !! % ℎ + !′′ %

#! " −!′′′ % #" $ + ⋯

! % + ℎ − ! % − ℎ = 2!! % ℎ + !′′′ % ℎ% 6 + +(ℎ&) !! % = ! % + ℎ − ! % − ℎ 2ℎ + +(ℎ") And define the Central Finite Difference as: .! % = % + ℎ − ! % − ℎ 2ℎ → !! % = .! % + +(ℎ")

#

EEO

§=

=

÷ h

slide-5
SLIDE 5

Forward Finite Difference: .! % =

' ()# *' ( #

→ !! % = .! % + +(ℎ) Backward Finite Difference: .! % =

' ( *' (*# #

→ !! % = .! % + +(ℎ) Central Finite Difference: .! % = ' ()# *' (*#

"#

→ !! % = .! % + +(ℎ") How accurate is the finite difference approximation? How many function evaluations (in additional to ! % )? Our typical trade-off issue! We can get better accuracy with Central Finite Difference with the (possible) increased computational cost.

How small should the value of !?

Truncation error: +(ℎ) Cost: 1 function evaluation Truncation error: +(ℎ) Cost: 1 function evaluation Truncation error: +(ℎ") Cost: 2 function evaluation2

HAI

I

slide-6
SLIDE 6

Example

! # = -$ − 2 !′ # = -$ /!01123# = (-$%!−2) − (-$−2) ℎ

  • 2232(ℎ) = 045(!′ # − /!01123#)

We want to obtain an approximation for !′ 1

ℎ 34454

Truncation error

f-(xth) = e' 'the 2

If = f(Xthh)-f#

t

q

= =

=

slide-7
SLIDE 7

Example

Should we just keep decreasing the perturbation ℎ, in order to approach the limit ℎ → 0 and

  • btain a better approximation for the derivative?
slide-8
SLIDE 8

Uh-Oh!

What happened here? ! # = -$ − 2, !′ # = -$ → !′ 1 ≈ 2.7

.! 1 = ! 1 + ℎ − !(1) ℎ

Forward Finite Difference

  • cancelation !
slide-9
SLIDE 9

.!(%) = ! % + ℎ − !(%) ℎ ≤ 8+ |! % | ℎ

When computing the finite difference approximation, we have two competing source of errors: Truncation errors and Rounding errors

  • och)

?

I

Eml H

F -

O

slide-10
SLIDE 10

Optimal “h” Loss of accuracy due to rounding

  • 2232~> ℎ

Truncation error: Rounding error:

  • 2232~ ?&|! # |

Minimize the total error 34454 ~ 8+|! % | ℎ + ;ℎ Gives ℎ = 8+|! % |/;

/

e:

I

→ to

'

slide-11
SLIDE 11

Finite Difference Method

  • Review :

f2 →Ee

df

= fCxth)-S

→ f)Cx)

E

h

%

  • f
: IR " → R

FCK)

  • ft

Iz

, Is ,
  • ' In )

=

=

=

giant

'

÷÷÷I

t.it?tSCxth#-f

E -

  • µ

:o) Ei

?)

h

⇐i

:*

slide-12
SLIDE 12

f- (x, , Xz)

= 2X, txixz the

*

is"""

⇐t.ie/Hx-tngy#=y--f7sI%fCkthIz)-fCx

)

  • h
slide-13
SLIDE 13

f : Bing - pin

÷÷i÷÷÷÷÷÷÷÷÷÷

:

÷÷÷¥⇐÷÷,

:*

.