8/10/2019 12 Interpolation Spline
1/24
1
Curve-Fitting
Spline Interpolation
8/10/2019 12 Interpolation Spline
2/24
2
Curve Fitting
RegressionLinear Regression
Polynomial Regression
Multiple Linear Regression
Non-linear Regression
Interpolation
Newton's Divided-Difference InterpolationLagrange Interpolating Polynomials
Spline Interpolation
8/10/2019 12 Interpolation Spline
3/24
3
Spline Interpolation
For some cases, polynomialscan lead to erroneous results
because of round off error and
overshoot.
Alternative approach is to apply
lower-order polynomials to
subsets of data points. Suchconnecting polynomials are
called spline functions.
8/10/2019 12 Interpolation Spline
4/24
4
8/10/2019 12 Interpolation Spline
5/24
5
(a)Linear spline
Derivatives are not
continuous Not smooth
(b) Quadratic spline
Continuous 1
st
derivatives
(c) Cubic spline
Continuous 1st
& 2nd
derivatives
Smoother
8/10/2019 12 Interpolation Spline
6/24
6
Quadratic Spline
8/10/2019 12 Interpolation Spline
7/24
7
Quadratic Spline
Spline of Degree 2
A function Qis called a spline of degree 2if The domain of Qis an interval [a, b].
Qand Q'are continuous functions on [a, b]. There are pointsxi(called knots) such that
a = x0< x1< < xn= band Qis a polynomial ofdegree at most 2on each subinterval [xi,xi+1].
A quadratic spline is a continuously differentiablepiecewise quadratic function.
8/10/2019 12 Interpolation Spline
8/24
8
Exercise Which of the following is a quadratic spline?
]2,1[21
]1,0[
]0,2[
)( 2
2
xx
xx
xx
xB
]2,1[1
]1,0[2
]0,2[
)(
2
2
2
xxx
xxx
xx
xA
8/10/2019 12 Interpolation Spline
9/24
8/10/2019 12 Interpolation Spline
10/24
10
Observations
n+1points
nintervals
Each interval is connected by a 2nd-order
polynomial Qi(x) = aix2 + bix + ci, i = 0, , n1.
Each polynomial has 3unknowns
Altogether there are 3nunknowns
Need 3nequations (or conditions) to solve for 3n
unknowns
Quadratic Interpolation
8/10/2019 12 Interpolation Spline
11/24
11
1. Interpolating conditions On each sub interval [x
i
,xi+1
], the function Qi
(x)mustsatisfy the conditions
Qi(xi) =f(xi)and Qi(xi+1) =f(xi+1)
These conditions yield 2nequations
Quadratic Interpolation (3nconditions)
1...,,0
)(
)(
11
2
1
2
ni
xfcxbxa
xfcxbxa
iiiiii
iiiiii
8/10/2019 12 Interpolation Spline
12/24
12
Quadratic Interpolation (3nconditions)
2. Continuous first derivatives The first derivatives at the interior knots must be
equal. This adds n-1more equations:
1...,,122 11 nibxabxa iiiiii
We now have 2n + (n1) = 3n1equations.
We need one more equation.
8/10/2019 12 Interpolation Spline
13/24
13
3. Assume the 2ndderivatives is zero at the first
point. This gives us the last condition as
Quadratic Interpolation (3nconditions)
002 11 aa
With this condition selected, the first two points areconnected by a straight line.
Note: This is not the only possible choice orassumption we can make.
8/10/2019 12 Interpolation Spline
14/24
14
Example
Fit quadratic splines to the given data
points.
i 0 1 2 3
xi 3 4.5 7 9
f(xi) 2.5 1 2.5 0.5
8/10/2019 12 Interpolation Spline
15/24
15
Example (Solution)
1. Interpolating conditions
5.09815.2749
5.2749
0.15.425.20
0.15.425.20
5.239
333
333
222
222
111
111
cbacba
cba
cba
cba
cba
2. Continuous first derivatives
3322
2211
1414
99
baba
baba
3. Assume the 2nd derivatives is zero at the first point.
01a
8/10/2019 12 Interpolation Spline
16/24
16
00
0
5.0
5.2
5.2
1
15.2
00000000101140114000
000019019
1981000000
1749000000
0001749000
00015.425.20000
00000015.425.20000000139
3
3
3
2
2
2
1
1
1
cb
a
c
b
a
c
ba
Example (Solution)
We can write the system of equations in matrix form as
Notice that the coefficient matrix is sparse.
8/10/2019 12 Interpolation Spline
17/24
17
Example (Solution)
The system of equations can be solved to yield
3.916.246.1
46.1876.664.05.510
333
222
111
cba
cbacba
]9,7[3.916.246.1
]7,5.4[46.1876.664.0
]5.4,3[5.5
)(2
2
xxx
xxx
xx
xQ
Thus the quadratic spline that interpolates thegiven points is
8/10/2019 12 Interpolation Spline
18/24
18
Efficient way to derive quadratic spline
2
1
1
1
11
1
11
)()(2
)()()(
as)(formto
rearrangedandresolved,,integratedbeturnincanwhich
)('
asformLagrangein)('writecanWe
).,(and),(throughpassinglinestraightais)('
hatimpliest tconditionsderivativefirstcontinuousThe
line.straingtais)('functionquadraticais)(
).('Let
i
ii
iiiiii
i
i
ii
ii
ii
ii
i
iiiii
ii
iii
xxxx
zzxxzxfxQ
xQ
zxx
xxz
xx
xxxQ
xQ
zxzxxQ
xQxQ
xQz
8/10/2019 12 Interpolation Spline
19/24
19
Efficient way to derive quadratic spline
2
1
1 )()(2
)()()( iii
iiiiii xx
xx
zzxxzxfxQ
11)('and
)('),()(verifycorrect,isthat thisseeTo
iii
iiiiii
zxQ
zxQxfxQ
s.'ofvaluethedeterminetoneedstillWe iz
ii
iiii
iii
xx
xfxfzz
nxfxQ
1
11
11
)()(2
:equationsfollowingthe
obtaincanweequations,resultingesimpify thand
1,-...,0,ifor)()(settingBy
8/10/2019 12 Interpolation Spline
20/24
20
Efficient way to derive quadratic spline
nixx
xfxfzz
xf"z
xxxx
zzxxzxfxQ
ii
iiii
i
ii
iiiiii
...,1,0,)()(
2
0))(assumeweif(0
where
)()(2
)()()(
1
11
00
2
1
1
8/10/2019 12 Interpolation Spline
21/24
21
Cubic Spline
Spline of Degree 3
A function Sis called a spline of degree 3if
The domain of Sis an interval [a, b].
S, S'and S"are continuous functions on [a, b].
There are points ti(called knots) such that
a = t0< t1< < tn= band Qis a polynomial ofdegree at most 3on each subinterval [ti, ti+1].
8/10/2019 12 Interpolation Spline
22/24
22
Cubic Spline (4nconditions)
1. Interpolating conditions (2nconditoins).
2. Continuous 1stderivatives (n-1conditions)
The 1stderivatives at the interior knots must be equal.
3. Continuous 2ndderivatives (n-1conditions) The 2ndderivatives at the interior knots must be equal.
4. Assume the 2ndderivatives at the end points are
zero (2conditions). This condition makes the spline a "natural spline".
8/10/2019 12 Interpolation Spline
23/24
23
Efficient way to derive cubic spline
1,...,1for
)()()()(
6)(2
0,0
solvingfromobtainedbecans'unknowntheandwhere
)(6
)()(
6
)(
)(6
)(6
)(
1
11
1111
0
1
111
3
1
31
ni
h
xfxf
h
xfxf
zhzhhzh
zz
zxxh
xxzh
h
xfxxz
h
h
xf
xxh
zxx
h
zxS
i
ii
i
ii
iiiiiii
n
i
iii
iii
i
iii
i
i
i
ii
i
ii
i
i
8/10/2019 12 Interpolation Spline
24/24
24
Summary
Advantages of spline interpolation overpolynomial interpolation
The conditions that are used to derive thequadratic and cubic spline functions
Characteristics of cubic spline Overcome the problem of "overshoot"
Easier to derive (than high-order polynomial)
Smooth (continuous 2nd-order derivatives)
Top Related