Page 146 - Applied Numerical Methods Using MATLAB
P. 146
INTERPOLATION BY CUBIC SPLINE 135
to write
S k,1 − S k−1,1 = h k−1 (S k,2 − S k−1,2 ) + 2h k−1 S k−1,2 = h k−1 (S k,2 + S k−1,2 )
(3.5.3)
In order to use this for eliminating S k,1 from Eq. (3.5.2), we subtract (3.5.2b)
from (3.5.2a) to write
h k (S k+1,2 + 2S k,2 ) − h k−1 (S k,2 + 2S k−1,2 ) + 3(S k,1 − S k−1,1 ) = 3(dy k − dy k−1 )
and then substitute Eq. (3.5.3) into this to write
h k (S k+1,2 + 2S k,2 ) − h k−1 (S k,2 + 2S k−1,2 ) + 3h k−1 (S k,2 + S k−1,2 )
= 3(dy k − dy k−1 )
h k−1 S k−1,2 + 2(h k−1 + h k )S k,2 + h k S k+1,2 = 3(dy k − dy k−1 ) (3.5.4)
for k = 1: N − 1
Since these are N − 1 equations with respect to N + 1 unknowns {S k,2 ,k = 0:
N}, we need two more equations from the boundary conditions to be given as
listed in Table 3.4.
How do we convert the boundary condition into equations? In the case where
the first-order derivatives on the two boundary points are given as (i) in Table 3.4,
we write Eq. (3.5.2a) for k = 0as
h 0 (S 1,2 + 2S 0,2 ) + 3S 0,1 = 3 dy 0 , 2h 0 S 0,2 + h 0 S 1,2 = 3(dy 0 − S 0,1 )
(3.5.5a)
We also write Eq. (3.5.2b) for k = N as
h N−1 (S N,2 + 2S N−1,2 ) + 3S N−1,1 = 3 dy N−1
and substitute (3.5.3)(k = N) into this to write
h N−1 (S N,2 + 2S N−1,2 ) + 3S N,1 − 3h N−1 (S N,2 + S N−1,2 ) = 3 dy N−1
h N−1 S N−1,2 + 2h N−1 S N,2 = 3(S N,1 − dy N−1 ) (3.5.5b)
Equations (3.5.5a) and (3.5.5b) are two additional equations that we need to solve
Eq. (3.5.4) and that’s it. In the case where the second-order derivatives on the
two boundary points are given as (ii) in Table 3.4, S 0,2 and S N,2 are directly
known from the boundary conditions as
S 0,2 = s (x 0 )/2, S N,2 = s (x N )/2 (3.5.6)
0 N