17 Cubic Spline Interpolation 01 Feb 2019reference Material I - MAT3005 - SplineInterpolation
17 Cubic Spline Interpolation 01 Feb 2019reference Material I - MAT3005 - SplineInterpolation
BSRV Prasad
Lecture Notes: Cubic Spline Interpolation Department of Mathematics, SAS, VIT, Vellore
Introduction
• So far we have discussed how an interpolation polynomial of degree n can be constructed and
used if a set of values of function are given.
• There are situations in which this approach is likely to face problems and produced incorrect
estimates.
• This is because the interpolation takes a global rather than a local view of data.
• It has been proved that when n is large compared to the order of the “true” function, the inter-
polation polynomial of degree n does not provide accurate results at the end of the range.
• Thus, increasing the order of polynomials does not necessarily increase the accuracy.
• To overcome this problem, one can divide the entire range into subintervals and use local low-
order polynomials to interpolate each subinterval.
• These local polynomials are called piecewise polynomials, which are continuous in the subin-
terval and discontinuous at the interpolating points.
• We can construct piecewise polynomials such that they are continuous at the interpolating points
also.
• This type of polynomials are called Spline polynomials.
• The concept of splines originated from the mechanical drafting tool called “spline” used by
designers for drawing smooth curves.
• The connection points are called knots or nodes.
Definition. A spline function of degree n over the interval [x0 , xn ] with knots (nodes) xi , i =
0, 1, 2, . . . , n is a function S(x) with the properties:
(i) si (x) is a polynomial of degree at most n in each of the subintervals [xi−1 , xi ], 1 ≤ i ≤ n.
(ii) si (x) and its derivatives of orders 1, 2, . . . , n − 1 are continuous on [x0 , xn ].
The set of all polynomials form a spline interpolating polynomial if si (xi ) = f (xi ), for i =
0, 1, 2, . . . , n. The process of constructing such polynomials for a given set of function points is
known as spline interpolation.
Cubic Splines
• These curves are continuous and also have resemble cubic curves and hence the name cubic
splines.
• Cubic splines are popular because of their ability to interpolate data with smooth curves.
Definition. A Cubic spline function over the interval [x0 , xn ] with knots (nodes) xi , i = 0, 1, 2, . . . , n
is a function S(x) with the properties:
(i) si (x) is almost a cubic in each of the subintervals [xi−1 , xi ], 1 ≤ i ≤ n.
(ii) si (xi ) = yi , i = 0, 1, 2, . . . , n.
1
MAT3005 – Applied Numerical Methods Dr. BSRV Prasad
Lecture Notes: Cubic Spline Interpolation Department of Mathematics, SAS, VIT, Vellore
(iii) si (x), s0i (x) and s00i (x) are continuous on [x0 , xn ], and
(iv) s00i (x0 ) = s00i (xn ) = 0.
To derive the governing equations of the cubic spline interpolating polynomial, we observe that the
cubic spline second derivatives must be linear. Hence we have in [xi−1 , xi ]:
1
s00i (x) = [(xi − x)Mi−1 + (x − xi−1 )Mi ]
hi
where hi = xi − xi−1 and s00i (xi ) = Mi for all i.
The cubic spline interpolating polynomial si (x) in the interval [xi−1 , xi ] is then given by
h2i
1 3 3
1
si (x) = (xi − x) Mi−1 + (x − xi−1 ) Mi + fi−1 − Mi−1 (xi − x)
6hi hi 6
2
1 h
+ fi − i Mi (x − xi−1 ) (1)
hi 6
The Mi ’s can be found from the following relations:
fi+1 − fi fi − fi−1
hi Mi−1 + 2(hi + hi+1 )Mi + hi+1 Mi+1 = 6 − (2)
hi+1 hi
For equal intervals, hi = hi+1 = h and hence the above equations reduces to:
h2
1 3 3
1
si (x) = (xi − x) Mi−1 + (x − xi−1 ) Mi + fi−1 − Mi−1 (xi − x)
6h h 6
2
1 h
+ fi − Mi (x − xi−1 ) (3)
h 6
and
6
Mi−1 + 4Mi + Mi+1 = (fi+1 − 2fi + fi−1 ) (4)
h2
(Here Mi = s00 (xi )).
2
MAT3005 – Applied Numerical Methods Dr. BSRV Prasad
Lecture Notes: Cubic Spline Interpolation Department of Mathematics, SAS, VIT, Vellore
Problem. Obtain the cubic spline approximation for the function given in the tabular form:
x 0 1 2 3
f (x) 1 2 33 244
and M0 = M3 = 0.
Solution. Since n = 4, we have three intervals and three cubics and, therefore only M1 , M2 are to be
determined.
Case (i):
i = 1, h = 1 =⇒ M0 + 4M1 + M2 = 6(f2 − 2f1 + f0 ) (5)
Case (ii):
i = 2, h = 1 =⇒ M1 + 4M2 + M3 = 6(f3 − 2f2 + f1 ) (6)
Since M0 = M3 = 0, from (9) and (10) we have
Now in the interval [1, 2] we have i = 2, h = 1 and required cubic spline is:
1 3 3
1 1
s2 (x) = (x2 − x) M1 + (x − x1 ) M2 + 1(x2 − x) f1 − M1 + 1(x − x1 ) f2 − M2
6 6 6
1 24 276
(2 − x)3 (−24) + (x − 1)3 (276) + (2 − x) 2 +
= + (x − 1) 33 −
6 6 6
3 2
= 50x − 162x + 167x − 53
Finally, in the interval [2, 3] we have i = 3, h = 1 and required cubic spline is:
1 3 3
1 1
s3 (x) = (x3 − x) M2 + (x − x2 ) M3 + 1(x3 − x) f2 − M2 + 1(x − x2 ) f3 − M3
6 6 6
1 276
(3 − x)3 (276) + (3 − x) 33 −
= + (x − 2)(244)
6 6
= −46x3 + 414x2 − 985x + 715
3
MAT3005 – Applied Numerical Methods Dr. BSRV Prasad
Lecture Notes: Cubic Spline Interpolation Department of Mathematics, SAS, VIT, Vellore
Solution. The points are equally spaced and hence h = 1. Since n = 4, we have three intervals and
three cubics and, therefore only M1 , M2 are to be determined.
Case (i):
i = 1, h = 1 =⇒ M0 + 4M1 + M2 = 6(f2 − 2f1 + f0 ) (9)
Case (ii):
i = 2, h = 1 =⇒ M1 + 4M2 + M3 = 6(f3 − 2f2 + f1 ) (10)
Since M0 = M3 = 0, from (9) and (10) we have