Computational Physics - Department of Physics

(Axel Boer) #1

48 3 Numerical differentiation and interpolation


To show this for the first and second derivatives starting with the three pointsf−h=f(x 0 −
h),f 0 =f(x 0 )andfh=f(x 0 +h), we have that the Taylor expansion aroundx=x 0 gives


a−hf−h+a 0 f 0 +ahfh=a−h



j= 0

f 0 (j)
j!
(−h)j+a 0 f 0 +ah



j= 0

f 0 (j)
j!
(h)j, (3.5)

wherea−h,a 0 andahare unknown constants to be chosen so thata−hf−h+a 0 f 0 +ahfhis the
best possible approximation forf 0 ′andf 0 ′′. Eq. (3.5) can be rewritten as


a−hf−h+a 0 f 0 +ahfh= [a−h+a 0 +ah]f 0

+[ah−a−h]h f 0 ′+ [a−h+ah]
h^2 f 0 ′′
2 +



j= 3

f 0 (j)
j!(h)

j[(− 1 )ja−h+ah].

To determinef 0 ′, we require in the last equation that


a−h+a 0 +ah= 0 ,

−a−h+ah=

1

h

,

and
a−h+ah= 0.


These equations have the solution


a−h=−ah=−

1

2 h

,

and
a 0 = 0 ,


yielding
fh−f−h
2 h
=f 0 ′+




j= 1

f 0 (^2 j+^1 )
( 2 j+ 1 )!
h^2 j.

To determinef 0 ′′, we require in the last equation that


a−h+a 0 +ah= 0 ,

−a−h+ah= 0 ,

and
a−h+ah=^2
h^2


.

These equations have the solution


a−h=−ah=−

1

h^2

,

and
a 0 =−^2
h^2


,

yielding
fh− 2 f 0 +f−h
h^2
=f 0 ′′+ 2




j= 1

f 0 (^2 j+^2 )
( 2 j+ 2 )!
h^2 j.
Free download pdf