The Chemistry Maths Book, Second Edition

(Grace) #1

572 Chapter 20Numerical methods


is, with continuous first and second (and possibly higher) derivatives at the nodes.


In the simplest and most widely used procedure, cubic spline interpolation, the


function between each pair of nodes is approximated as a cubic. For the jth interval,


between (x


j

, y


j

) and (x


j+ 1

, y


j+ 1

), the cubicf


j

(x)can be written as


f


j

(x) 1 = 1 a


j

1 + 1 b


j

(x 1 − 1 x


j

) 1 + 1 c


j

(x 1 − 1 x


j

)


2

1 + 1 d


j

(x 1 − 1 x


j

)


3

(20.24)


Then, at the nodes,


f


j

(x


j

) 1 = 1 y


j

, f


j

(x


j+ 1

) 1 = 1 y


j+ 1

(20.25)


For continuity of the first derivatives at the nodes, the derivativef


j

′(x)is related to the


derivatives of the cubics in the adjacent intervals by


f


j

′(x


j

) 1 = 1 f′


j− 1

(x


j

), f


j

′(x


j+ 1

) 1 = 1 f′


j+ 1

(x


j+ 1

) (20.26)


Similarly for the second derivatives,


f


j

′′(x


j

) 1 = 1 f′′


j− 1

(x


j

), f


j

′′(x


j+ 1

) 1 = 1 f′′


j+ 1

(x


j+ 1

) (20.27)


We consider here only the special case of evenly spaced nodes, withx


j+ 1

1 − 1 x


j

1 = 1 h(all


j 1 = 11 to nfor (n 1 + 11 ) nodes). Then, if the derivative at nodejis denoted byk


j

,the


three sets of conditions (20.25) to (20.27) give the following expressions for the


coefficients in the cubic (20.24):


a


j

1 = 1 y


j

, b


j

1 = 1 k


j

(20.28)


and the recurrence relation for the gradients,


(20.29)


These relations are sufficient to determine the interpolation cubics for all the internal


intervals (j 1 = 11 to n). For the end intervals it is necessary also to specify the slopes


k


0

andk


n

. If these are chosen by means of the end-point conditions


f


0

′′(x


0

) 1 = 1 f


n

′′(x


n

) 1 = 10 (20.30)


the cubic splines are called natural splines, and these give approximately linear


behaviour near the ends. Other choices can be made to alter this behaviour.


Computer programs for cubic spline interpolation exist in all the popular computer


programming languages, and are widely used for the display of experimental data and


of the results of computational studies in the physical sciences and engineering. The


result of natural spline interpolation for the points given in Table 20.4 is illustrated in


kkk


h


yy


jjj jj−++−

++ = −


1111

4


3


()


d


h


yy


h


kk


jjj jj

=−+ +


++

21


3

1
2

1

()()


c


h


yy


h


kk


jjjjj

=−−+


++

31


2


2

11

()( )

Free download pdf