Docsity

Cubic Spline Interpolation: Finding Spline with Values and Intervals, Schemes and Mind Maps of Numerical Methods in Engineering

Toggle sidebar
bg1
Splines
Let a=x0< x1< . . . < xn−1< xn=b. A spline of degree mis a function
S(x) which satisfies 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.
limx→x−
iS(m−1)
i−1(x) = limx→x+
iS(m−1)
i(x)
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−S0(x)6= limx→0+ S0(x).
Cubic Spline Interpolation
Given f,x0, . . . , xnas above, find a cubic spline Ssuch that S(xi) = f(xi),
i= 0, . . . , n.
n+ 1 points ⇒nintervals ⇒4ncoefficients
2nconditions needed to interpolate f(x0), . . . , f (xn)
2(n−1) conditions needed to ensure S0,S00 are continuous at the interior
points
This leaves 2 free conditions. Popular choices are:
(i) S00(x0) = S00(xn) = 0: the natural cubic spline interpolant
(ii) S0(x0) = f0(x0), S0(xn) = f0(xn): the clamped cubic spline interpolant
1
pf3
pf4
pf5

Partial preview of the text

Download Cubic Spline Interpolation: Finding Spline with Values and Intervals and more Schemes and Mind Maps Numerical Methods in Engineering in PDF only on Docsity!

Splines

Let a = x 0 < x 1 <... < xn− 1 < xn = b. A spline of degree m is a function

S(x) which satisfies 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 x 1 ,... , xn− 1 , i.e.

limx→x− i

S

(m−1) i− 1 (x) = limx→x

i

S

(m−1) i (x)

EXAMPLE

S(x) =

0 , − 1 ≤ x ≤ 0

x

2 , 0 ≤ x ≤ 1

x 0 = − 1 , x 1 = 0, x 2 = 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) 6 = limx→0+ S

′ (x).

Cubic Spline Interpolation

Given f , x 0 ,... , xn as above, find a cubic spline S such that S(xi) = f (xi),

i = 0,... , n.

n + 1 points ⇒ n intervals ⇒ 4 n coefficients

2 n conditions needed to interpolate f (x 0 ),... , 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

′′ (x 0 ) = S

′′ (xn) = 0: the natural cubic spline interpolant

(ii) S

′ (x 0 ) = f

′ (x 0 ), S

′ (xn) = f

′ (xn): the clamped cubic spline interpolant

Given f (x); x 0 ,... , xn, how to find S(x)?

EXAMPLE

xi = ih, h = 1/n, x 0 = 0, xn = 1

STEP 1 (2nd derivative conditions)

Since Si(x) is a cubic polynomial, S

′′ i (x) is linear for^ x

S

′′ i (x) =^ ai

xi+1 − x

h

  • ai+

x − xi

h

, i = 0,... , n − 1

(using Lagrange 1st order interpolating polynomial).

Then

S

′′ i (xi) =^ ai

S

′′ i (xi+1) =^ ai+

⇒ S

′′ i− 1 (xi) =^ ai^ =^ S

′′ i (xi)

Thus, S

′′ (x) is continuous at the interior nodes.

STEP 2 (function values)

Integrate twice

Si(x) =

ai(xi+1 − x)

3

6 h

ai+1(x − xi)

3

6 h

  • bi(xi+1 − x) + ci(x − xi)

the last two terms are written in this special form just for convenience

Si(xi) = ai

h^2 6

  • bih = fi

Si(xi+1) = ai+

h^2 6

  • cih = fi+

bih = fi − ai

h^2 6

cih = fi+1 − ai+

h^2 6

Substitute

Si(x) =

ai(xi+1 − x)

3

6 h

ai+1(x − xi)

3

6 h

fi − ai

h

2

xi+1 − x

h

fi+1 − ai+

h

2

x − xi

h

STEP 3 (1st derivative conditions).

S

′ i(x) =^ −

ai(xi+1 − x)

2

2 h

ai+1(x − xi)

2

2 h

fi

h

− ai

h

fi+

h

− ai+

h

  • positive definite
  • strictly diagonally dominant

Notes:

  1. For clamped splines, there are two additional equations that involve a 0

and an.

  1. Condition (*) explains why the spline has additional inflection points.

See the handout about natural cubic spline interpolation.

Recall

A = (aij ) is strictly diagonally dominant if

|aii| >

∑^ n

j= j 6 =i

|aij | for all i = 1,... , n

Theorem If A is strictly diagonally dominant, then A is invertible.

Proof. Suppose A is not invertible. Then there exists a vector x 6 = 0 such

that Ax = 0. Choose index i such that |xi| = ||x||∞ = maxj |xj |. Then

0 = (Ax)i =

∑^ n

j=

aij xj = aiixi +

∑^ n

j= j 6 =i

aij xj

⇒ |aiixi| =

∑^ n

j= j 6 =i

aij xj

∑^ n

j= j 6 =i

|aij ||xj |

⇒ |aii| ≤

∑^ n

j= j 6 =i

|aij |

|xj |

|xi|

∑^ n

j= j 6 =i

|aij |

This contradicts the assumption that A is strictly diagonally dominant.

Note

In practice, the values ai = S

′′ (xi) are found by Gaussian elimination for a

tridiagonal system.

Theorem Let f be defined on [a, b], a = x 0 < x 1 <... < xn− 1 < xn = b and

let S be the natural cubic spline interpolant of f (or clamped cubic spline).

  1. |f (x) − S(x)| ≤

max a≤x≤b

|f

(4) (x)| · h

4

where h = maxi |xi+1 − xi|

∫ (^) b

a

[S

′′ (x)]

2 dx ≤

∫ (^) b

a

[f

′′ (x)]

2 dx Minimum curvature property of cubic splines

Note

  1. Cubic spline interpolation is 4

th order accurate.

  1. Condition (2) is optimality property: spline S(x) ”oscillates least” of all

smooth functions satisfying interpolation condition + BC (natural BC

or clamped spline S

′ (x 0 ) = y

′ 0 ,^ S

′ (xn) = y

′ n).

Curvature

κ(x) =

|f

′′ (x)|

(1 + [f ′(x)]^2 )

3 / 2

≈ |f

′′ (x)|

∫ (^) b

a

[f

′′ (x)]

2 dx is a crude measure of the total curvature over an inter-

val.

∫ (^) b

a

[S

′′ (x)]

2 dx ≤

∫ (^) b

a

[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 − 2 S(S − F )

Let F = f

′′ (x), S = S

′′ (x), integrate over [a, b].

∫ (^) b

a

[f

′′ (x)]

2 dx −

∫ (^) b

a

[S

′′ (x)]

2 dx =

∫ (^) b

a

[f

′′ (x) − S

′′ (x)]

2 dx

∫ (^) b

a

S

′′ (x)(S

′′ (x) − f

′′ (x))dx