0% found this document useful (0 votes)
58 views18 pages

Splines

The document discusses cubic splines, which are piecewise polynomial curves used to model smooth curves. Cubic splines are composed of cubic polynomial pieces that match smoothly at "knots". The key equations for cubic splines are presented, including those that ensure continuity of the spline and its derivatives up to the second order at each knot. These equations form a tridiagonal system that can be solved efficiently to determine the spline.

Uploaded by

kingofmotor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views18 pages

Splines

The document discusses cubic splines, which are piecewise polynomial curves used to model smooth curves. Cubic splines are composed of cubic polynomial pieces that match smoothly at "knots". The key equations for cubic splines are presented, including those that ensure continuity of the spline and its derivatives up to the second order at each knot. These equations form a tridiagonal system that can be solved efficiently to determine the spline.

Uploaded by

kingofmotor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Cubic Splines

Antony Jameson

Department of Aeronautics and Astronautics, Stanford University, Stanford,


California, 94305

1 References on splines

1. J. H. Ahlberg, E. N. Nilson, J. H. Walsh. ”Theory of splines and their applica-


tions”, Academic Press, 1967.
2. I. J. Schoenberg (ed.). ”Spline functions”, (Symposium at U. Wisconsin, 1969),
Academic Press, 1969.
3. I. J. Schoenberg. Quart. Appl. Math. 4, 1946, pp. 45-99, pp. 112-114.
4. C. H. Reinsch. Numer. Math. 10, 1967, pp. 177-183. Smoothing by spline func-
tions.
5. Schulz, Spline Analysis.

1
2 Definition of spline

A spline is a piecewise polynomial in which the coefficients of each polynomial are


fixed between ’knots’ or joints.

Figure 1:

Typically cubics are used. Then the coefficients are chosen to match the function and
its first and second derivatives at each joint. There remain one free condition at each
end, or two conditions at one end. However, using only starting conditions the spline
is unstable. In general with nth degree polynomials one can obtain continuity up to
the n − 1 derivative. The most common spline is a cubic spline. Then the spline
function y(x) satisfies y (4) (x) = 0, y(3)(x) = const, y 00 (x) = a(x) + h. But for a beam
between simple supports
M (x)
y 00 (x) =
EI

where M (x) varies linearly. Thus a spline is the curve obtained from a draughtsman’s
spline.

2
Figure 2: Draughtsman’s spline

3 Equations of cubic spline

Let data be given at x0 , x1 , · · · xn with values y0 , y1 , · · · yn . Let S(x) bet the spline.
Let
Mj = S 00 (xj ), hj = xj − xj−1

be ’moment’ at j th point. Then between xj−1 and xj

xj − x x − xj−1
S 00 (x) = Mj−1 + Mj
hj hj

(xj − x)2 (x − xj−1 )2


S 0 (x) = −Mj−1 + Mj +A
2hj 2hj

(xj − x)3 (x − xj−1 )3


S(x) = Mj−1 + Mj + Ax + B
6hj 6hj

But
S(xj−1 ) = yj−1 , S(xj ) = yj .

We obtain

(xj − x)3 (x − xj−1 )3 h2j xj − x h2j x − xj


   
S(x) = Mj−1 +Mj + yj−1 − Mj−1 + yj + Mj
6hj 6hj 6 hj 6 hj

3
(xj − x)2 (x − xj−1 )2 yj − yj−1 Mj − Mj−1
S 0 (x) = −Mj−1 + Mj + − hj
2hj 2hj hj 6

We now have continuity of S 00 (x) and S(x) at xj . We also require continuity of S 0 (x).
Now
hj hj yj − yj−1
S 0 (x−
j ) = Mj−1 + Mj +
6 3 hj
−hj+1 hj+1 yj+1 − yj
S 0 (x+
j ) = Mj − Mj+1 +
3 6 hj+1

Equating these gives equations for the Mj at every interior node:

hj hj + hj+1 hj+1 yj+1 − yj yj − yj−1


Mj−1 + Mj + Mj+1 = −
6 3 6 hj+1 hj

To complete the system we need 2 additional equations. Setting S 00 (x0 ) = M0 = 0,


S 00 (xn ) = Mn = 0, corresponds to simple supports at the ends of the beam. Better
accuracy is obtained if S 0 (x0 ) and S 0 (xn ) are known. Then from the equation for
S 0 (xn ) we have
h1 h1 y1 − y0
M0 + M1 = − y00
3 6 h1
hn hn yn − yn−1
Mn−1 + Mn = yn0 −
6 3 hn

If neither S 0 (x) nor S 00 (x) are known at the ends, one may set S 000 (x) = 0, or

M1 − M0 = 0

Mn−1 − Mn = 0

Alternatively one may use some linear combination of these end conditions. In any

4
case one obtains a tridiagonal set of equations which may be written

    
2 λ0 M0 d0
    
    
µ1 2 λ1   M1   d1 
    
    
  = 
    
    
µn−1 2 λn−1   Mn−1   dn−1
    
 
    
µn 2 Mn dn

where at interior points

hj+1
λj = , µj = 1 − λj
hj + hj+1

(yj+1 − yj )/hj+1 − (yj − yj−1 )/hj


dj = 6
hj + hj+1

and λ0 , µn , d0 , dn depend on the end conditions. These equations are diagonally


dominant, leading to stable behaviour.

Spline equations for first derivatives

Let
mj = S 0 (xj )

Then

(xj − x)2 (x − xj−1 ) (x − xj−1 )2 (xj − x)


S(x) = mj−1 − mj
h2j h2j
(xj − x)2 [2(x − xj−1 ) + hj ] (x − xj−1 )2 [2(xj − x) + hj ]
+yj−1 + y j
h3j h3j

5
(xj − x)(2xj−1 + xj − 3x) (x − xj−1 )(2xj − xj−1 − 3x)
S 0 (x) = mj−1 2
− mj
hj h2j
yj − yj−1
+6 (xj − x)(x − xj−1 )
h3j

2xj + xj−1 − 3x 2xj−1 + xj − 3x)


S 00 (x) = −2mj−1 2
− 2mj
hj h2j
yj − yj−1
+6 (xj + xj−1 − 2x)
h3j

2mj−1 4mj yj − yj−1


S 00 (x−
j ) = + −6
hj hj h2j

4mj 2mj+1 yj+1 − yj


S 00 (x+
j ) = − − +6
hj+1 hj+1 h2j+1

Equating these gives

 
1 1 1 1 yj − yj−1 yj+1 − yj
mj−1 + 2 + mj + mj+1 = 3 2
+3
hj hj hj+1 hj+1 hj h2j+1

Then     
2 µ0 m0 c0
    
    
λ1 2 µ1   m1   c1 
    
    
  = 
    
    
λN −1 2 µN −1   mN −1   cN −1
    
 
    
λN 2 mN cN

where at interior points

yj − yj−1 yj+1 − yj
cj = 3λj + 3µj
hj hj+1

6
The end condition S 00 = 0 gives

yj − y0
µ0 = 1, c0 = 3
hj

yN − yN −1
λN = 1, cN = 3
hN −1

4 Minimum curvature property of splines

Consider all functions f (x) such that f (xi ) = yi Then the spline S(x) with S 00 (x0 ) =
S 00 (xn ) = 0 is that function f (x) which minimize:

Z xn
f 00 (x)2 dx
x0

(Ahlberg, p. 76)

Proof
Z xn
2
(f 00 (x) − S 00 (x)) dx
x0
Z xn Z Z
00 00 00 00
= 2
f (x) dx − 2 (f (x) − S (x)) S (x)dx − S 00 (x)2 dx
x0

The middle term is


n Z
X xi
(f 00 (x) − S 00 (x)) S 00 (x)dx
i=1 xi−1

Integrating by parts it becomes

n
X n Z
X xi
0 0 00 i
[(f (x) − S (x)) S (x)]i−1 − (f 0 (x) − S 0 (x)) S 000 (x)dx
i=1 i=1 xi−1

7
S 000 (x) is constant in each segment, and can be taken out of each integral in the second
term.

But
Z xi
(f 0 (x) − S 0 (x)) dx = [f (x) − S(x)]ii−1
xi−1

which vanishes because

f (xi ) = S(xi ) = yi , i = 0, 1, . . . n

Also the contributions to the sum in the first term vanish at every interior node,
leaving
(f 0 (xn ) − S 0 (xn )) S 00 (xn ) − (f 0 (x0 ) − S 0 (x0 )) S 00 (x0 )

Thus
Z xn
(f 00 (x) − S 00 (x)) S 00 (x)dx = 0
x0

if either S 00 (x) = 0 at each end or f 0 (x) = S 0 (x). Consequently

Z xn Z xn Z xn
00 00 2
2
f (x) dx − 2
S (x) dx = (f 00 (x) − S 00 (x)) dx > 0
x0 x0 x0

unless f (x) = S(x).

8
5 Errors in spline approximation

If the maximum interval is h then

f (x) − S(x) ∼ h4

f 0 (x) − S 0 (x) ∼ h3

f 00 (x) − S 00 (x) ∼ h2

f 000 (x) − S 000 (x) ∼ h

This is proved by Ahlberg, Nilson and Walsh, p. 29, provided that f (4) is continuous.

To study convergence properties of splines we need an estimate of the norm of the


inverse of the matrix B of the equations for the spline. Taking

kxk = max|xi |

the induced norm of B is

n
kBxk X
kBk = sup = max |bij |
x6=0 kxk i
j=1

9
With a diagonally dominant matrix we have

X n
kyk = kBxk = max bij xj

i
j=1

Xn
≥ bij xj


j=1

where kxk = |xk |, or

( )
X
kyk ≥ |bkk | − |bkj | kxk
j6=k
( )
X
≥ min |bii | − |bij | kxk
i
j6=i

Thus " ( )#−1


−1
kB yk X
kB −1 k = sup ≤ min |bi i| − |bij |
y6=0 kyk i
j6=i

or for the spline matrix

kB −1 k ≤ max (2 − λ0 )−1 , (2 − λn )−1 , 1


 

Now let
δ = maxhj

and let
δ
max ≤ β < ∞.
hj

Then the spline has the following convergence propety as the maximum mesh spacing

10
δ is reduced:
Theorem A: (Ahlberg, p. 22)
Let f (x) be continuous on [a, b] and let max [|λ0 |, |µn |] < 2. Then if S(x) is a spline
fit to f (x) with x0 = a, xn = b, then

|f (x) − S(x)| → 0 as δ → 0.

Also if
α
|f (x) − f (x0 )| ≤ κ |x − x0 | , 0≤α≤1

then
|f (x) − S(x)| = O (δ α ) .

Proof: On [xj−1 , xj ] the spline equations can be arranged as

   
Mj−1 (xj − x) (xj − x)2 − h2j Mj (x − xj−1 ) (x − xj−1 )2 − h2j
S(x) − f (x) = +
6hj 6hj

fj + fj−1 xj + xj−1 − 2x
+ − f (x) + (fj − fj−1 )
2 2hj

By maximizing the coefficients of Mj and Mj−1 we find that they do not exceed
h2j /35/2 . Let Ai j be the elements of B −1 where B is the coefficient matrix. Then

n−1
X (fi+1 − fi )/hi+1 − (fi − fi−1 )/hi
Mj = 6 Aji + Aj0 d0 + Ajn dn .
i=1
hi + hi+1

11
Also let µ(f, δ) be the modulus of continuity of f (x) on [a, b] defined as

µ(f, δ) = sup |f (x) − f (x0 )|


|x−x0 |<δ

Then remembering the condition that δ ≤ βhj , we find that


(fi+1 − fi )/hi+1 − (fi − fi−1 )/hi
h2j ≤ β 2 µ(f, δ)
hi + hi+1

Thus
h2j (|Mj−1 + |Mj |) ≤ 2kB −1 k 6β 2 µ(f, δ) + δ 2 (|d0 | + |dn |)


and finally

 
2 −1
 2 2
1
|S(x) − f (x)| ≤ 5 kB k 6β µ(f, δ) + δ (|d0 | + |dn |) + µ(f, δ) 1 +
32 2

If the function satisfies

|f (x) − f (x0 )| ≤ κ(x − x0 )α , 0<α≤1

then
µ(f, δ) ≤ κδ α

establishing the required result, in light of the inequality satisfied by kB −1 k, provided


that λ < 2, µn < 2.

If f is in C 2 we can prove
Theorem B: (Ahlberg, p. 27)

12
|f (p) x − S (p) (x)| = O(δ 2−p )

where S(x) satisfies end conditions

 
6 f1 − f0
2M0 + M1 = − f00
h1 h1

or
M0 = f000 .

Proof: If B is the matrix of the spline we have

BM = d

whence
   
d B
B M− = I− d
3 3

The right side is  


 d0 − d1 
 
 µ1 (d1 − d0 ) − λ1 (d2 − d1 )
1 

3
 
 ··· 

 
dN − dN −1

Now at interior points

dj (fj+1 − fj )/hj+1 − (fj − fj−1 )/hj


= = f [xj−1 , xj , xj+1 ]
6 hj + hj+1
1 00
= f (ξj ), xj−1 ≤ ξj ≤ xj+1
2

13
Also by the Taylor theorem

d0 (f1 − f0 )/h1 − f00 1


= = f 00 (ξ0 ), x0 ≤ ξ0 ≤ x1
6 h1 2

Thus if µ is the modulus of continuity of f 00 ,

|f 00 (x) − f 00 (x0 )| ≤ µ(f 00 , δ), |x − x0 | ≤ δ

then here since λj + µj = 1,

 

I− B ≤ 3µ(f 00 , δ)

d
3

Also with the given end conditions kB −1 k ≤ 1 so

 
d −1

M − ≤ kB k I − B 00
3 3 ≤ 3µ(f , δ)
d

dj
Now since = f 00 (ξj ) it also follows that
3

00
f − d
≤ µ(f 00 , δ)
3

whence
kM − f 00 k ≤ 4µ(f 00 , δ)

and since S 00 is linear on each interval

kS 00 − f 00 k ≤ 5µ(f 00 , δ)

14
Now if
|f 00 (x) − f 00 (x0 )| ≤ κ|x − x0 |α , 0<α≤1

we have
kS 00 − f 00 k ≤ 5κδ α

Since S(xj ) = f (xj ), by Rolle’s theorem, there is a point ξj in the interval [xj−1 , xj ]
at which S 0 (ξj ) = f 0 (ξj ). Then on this interval

Z
x
0 0
|f (x) − S (x)| = (f (x) − S (x)) ≤ 5δµ(f 00 , δ)
00 00

ξj

and integrating a second time

5
|f (x) − S(x)| ≤ δ 2 µ(f 00 , δ)
2

Even stronger convergence theorems can be proved. Ahlberg (p. 29) gives:
Theorem C: Let f (4) (x) be continuous then

f (p) (x) − S (p) (x) = O δ 3−p ,



p = 0, 1, 2, 3

B spline

15
Figure 3: B spline

6 Smoothing splines

Instead of requiring a spline to coincide with the function at specidied points one may
simply require it to pass closer and permit some smoothing. To do this let S(x) be
chosen to minimize

xn n
(f (xi ) − yi )2
Z X
R1 f 00 (x)2 dx + R2
x0 i=0
Qi

Then by the calculus of variations the solution can be shown to be a spline with joints
at x1 , x2 , · · · xn−1 which does not necessarily pass through thte points.

Reinsch (Numer. Math 10, 1967, pp. 177-183) shows that the equations now reduce
to a five diagonal system, which can still be solved with a number of operations
proportional to n.

16
7 Change of independent variable

With any type of polynomial fitting or spline fitting difficulties occur if the function
y(x) has too large a slope. In extreme cases the given points may represent a closed
curve or other curve that bends back on itself.

Figure 4:

dy
In such a case the xi do not form a monotone sequence, and also is inifinite at
dx
dx
the nose, while is infinite at the top and bottom. To overcome this difficulty we
dy
need to parameterize the curve and set

x = x(t)

y = y(t)

where t is a new independent variable that increases monotonely. Then form separate
splines for x(t) and y(t).

17
8 Integration

Splines are useful for integration when function is defined by a table of coordinates
at unequal intervals.

Conclusions

Acknowledgements

References

18

You might also like