You are on page 1of 6

# Splines

Let a = x0 < x1 < . . . < xn−1 < xn = b. A spline of degree m is a function S (x) which satisﬁes the following conditions: 1. For x ∈ [xi , xi+1 ], S (x) = Si (x): polynomial of degree ≤ m 2. S (m−1) exists and continuous at the interior points x1 , . . . , xn−1 , i.e. (m−1) (m−1) limx→x− Si−1 (x) = limx→x+ Si (x) i i EXAMPLE S (x) = 0, −1 ≤ x ≤ 0 x2 , 0 ≤ x ≤ 1

x0 = −1, x1 = 0, x2 = 1 S (x) is a spline of degree m = 2 (quadratic spline). EXAMPLE S (x) = 0, −1 ≤ x ≤ 0 1 − (x − 1)2 , 0 ≤ x ≤ 1

S (x) is not a quadratic spline because limx→0− S (x) = limx→0+ S (x).

Cubic Spline Interpolation
Given f , x0 , . . . , xn as above, ﬁnd a cubic spline S such that S (xi ) = f (xi ), i = 0 , . . . , n. n + 1 points ⇒ n intervals ⇒ 4n coeﬃcients 2n conditions needed to interpolate f (x0 ), . . . , f (xn ) 2(n − 1) conditions needed to ensure S , S are continuous at the interior points This leaves 2 free conditions. Popular choices are: (i) S (x0 ) = S (xn ) = 0: the natural cubic spline interpolant (ii) S (x0 ) = f (x0 ), S (xn ) = f (xn ): the clamped cubic spline interpolant
1

. STEP 2 (function values) Integrate twice ai (xi+1 − x)3 ai+1 (x − xi )3 Si (x) = + + bi (xi+1 − x) + ci (x − xi ) 6h 6h the last two terms are written in this special form just for convenience Si (xi ) = ai h 6 + bi h = f i Si (xi+1 ) = ai+1 h 6 + ci h = fi+1 Substitute Si (x) = ai (xi+1 − x)3 ai+1 (x − xi )3 + 6h 6h h2 6 xi+1 − x h + fi+1 − ai+1 h2 6 x − xi h 2 2 bi h = fi − ai h 6 2 2 ci h = fi+1 − ai+1 h 6 + fi − ai STEP 3 (1st derivative conditions). x0 . Then Si (xi ) = ai Si (xi+1 ) = ai+1 ⇒ Si−1 (xi ) = ai = Si (xi ) Thus. x0 = 0. . ai (xi+1 − x)2 ai+1 (x − xi )2 + − Si (x) = − 2h 2h 2 fi h − ai h 6 + h fi+1 − ai+1 h 6 . . xn . . Si (x) is linear for x Si (x) = ai xi+1 − x h + ai+1 x − xi h . how to ﬁnd S (x)? EXAMPLE xi = ih. S (x) is continuous at the interior nodes. . xn = 1 STEP 1 (2nd derivative conditions) Since Si (x) is a cubic polynomial. h = 1/n. . n − 1 (using Lagrange 1st order interpolating polynomial). . .Given f (x). i = 0.

0 0 .. Sn−1 (xn ) = 0 ⇒ an = 0     . .. 0   . .. .. . . so (shifting i → i − 1 in Si (xi+1 )) h ai − 2 fi−1 h − ai−1 h 6 + fi h − ai h 6 + fi+1 h − ai+1 h 6 h = (fi−1 − 2fi + fi+1 ) /h 6 h = −ai − 2 Collect like terms h ai−1 + ai 6 fi h − ai h 6 h h h h − + − 2 6 2 6 6 h + ai+1 Multiply both sides by ai−1 + 4ai + ai+1 = 6 (fi−1 − 2fi + fi+1 ) h2 This holds for i = 1... ...  . ..  .. STEP 4 (boundary conditions) S0 (x0 ) = 0 ⇒ a0 = 0  4 1       0 The coeﬃcient matrix is • tridiagonal • symmetric 3 1 4 .   h2  . . .. 0 1 ..    6 . Si−1 (xi ) = Si (xi )... .      = .      .. 0 f0 − 2f1 + f2 a1     . ..h Si (xi ) = −ai − 2 h Si (xi+1 ) = ai+1 − 2 fi h − ai h 6 fi h − ai h 6 + + fi+1 h − ai+1 h 6 fi+1 h − ai+1 h 6 We require. . n − 1.   .... . 1      1 4 fn−2 − 2fn−1 + fn an−1 (∗) ..

. For clamped splines. . . Condition (*) explains why the spline has additional inﬂection points. the values ai = S (xi ) are found by Gaussian elimination for a tridiagonal system. Recall A = (aij ) is strictly diagonally dominant if n |aii | > j =1 j =i |aij | for all i = 1. 2. Then there exists a vector x = 0 such that Ax = 0. Suppose A is not invertible. 4 . . Choose index i such that |xi | = ||x||∞ = maxj |xj |. Proof. Then n n 0 = (Ax)i = j =1 aij xj = aii xi + j =1 j =i aij xj n n ⇒ |aii xi | = − j =1 j =i aij xj ≤ j =1 j =i |aij ||xj | n ⇒ |aii | ≤ j =1 j =i |xj | ≤ |aij | |xi | n |aij | j =1 j =i This contradicts the assumption that A is strictly diagonally dominant. there are two additional equations that involve a0 and an . n Theorem If A is strictly diagonally dominant.• positive deﬁnite • strictly diagonally dominant Notes: 1. See the handout about natural cubic spline interpolation. Note In practice. then A is invertible.

b]. |f (x) − S (x)| ≤ 5 max |f (4) (x)| · h4 384 a≤x≤b where h = maxi |xi+1 − xi | b a [S (x)] dx ≤ a 2 b [f (x)]2 dx Minimum curvature property of cubic splines Note 1. b].Theorem Let f be deﬁned on [a. Curvature κ(x) = ⇒ val. . b a [f |f (x)| (1 + [f (x)]2 )3/2 ≈ |f (x)| (x)]2 dx is a crude measure of the total curvature over an interb a b a [S (x)] dx ≤ 2 [f (x)]2 dx : any smooth interpolating function must have a total curvature at least as large as that of the cubic spline (natural or clamped) Proof of (2) for natural splines algebraic identity: F 2 − S 2 = (F − S )2 − 2S (S − F ) Let F = f (x). 1. . S (xn ) = yn ). Cubic spline interpolation is 4th order accurate. 2. a = x0 < x1 < . integrate over [a. Condition (2) is optimality property: spline S (x) ”oscillates least” of all smooth functions satisfying interpolation condition + BC (natural BC or clamped spline S (x0 ) = y0 . b a [f (x)] dx − a 2 b [S (x)] dx = a b 2 b [f (x) − S (x)]2 dx −2 a S (x)(S (x) − f (x))dx 5 . < xn−1 < xn = b and let S be the natural cubic spline interpolant of f (or clamped cubic spline). S = S (x).

. i = 0.The ﬁrst term is ≥ 0. Integration by parts: b u(x)v (x)dx = a b u(x)v (x)|b a b − a n− 1 u (x)v (x)dx xi+1 S (x)(S (x) − f (x))dx = a n− 1 i=0 x (x))|xii+1 − xi xi+1 S (x)(S (x) − f (x))dx = i=0 n−1 S (x)(S (x) − f xi+1 S (x)(S (x) − f (x))dx xi =− i=0 S (xi ) xi (S (x) − f (x))dx using S (x0 ) = S (xn ) = 0. . telescoping sum and Si (x) is constant n− 1 − i=0 S (xi )(S (x) − f (x))|xii+1 = 0 x using S (xi ) = f (xi ). n. 6 . . . We will show that the second term is 0.