3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

3.4 Hermite Interpolation
3.5 Cubic Spline Interpolation
1
Hermite Polynomial
Definition. Suppose 𝑓 ∈ 𝐢 1 [π‘Ž, 𝑏]. Let π‘₯0 , … , π‘₯𝑛 be
distinct numbers in [π‘Ž, 𝑏], the Hermite polynomial
𝑃(π‘₯) approximating 𝑓 is that:
1. 𝑃 π‘₯𝑖 = 𝑓 π‘₯𝑖 , for 𝑖 = 0, … , 𝑛
2.
𝑑𝑃 π‘₯𝑖
𝑑π‘₯
=
𝑑𝑓 π‘₯𝑖
𝑑π‘₯
, for 𝑖 = 0, … , 𝑛
Remark: 𝑃(π‘₯) and 𝑓(π‘₯) agree not only function values but
also 1st derivative values at π‘₯𝑖 , 𝑖 = 0, … , 𝑛.
2
Theorem. If 𝑓 ∈ 𝐢 1 π‘Ž, 𝑏 and π‘₯0 , … , π‘₯𝑛 ∈ π‘Ž, 𝑏 distinct
numbers, the Hermite polynomial is:
𝑛
𝐻2𝑛+1 π‘₯ =
𝑛
𝑓 π‘₯𝑗 𝐻𝑛,𝑗 (π‘₯) +
𝑗=0
𝑓′ π‘₯𝑗 𝐻𝑛,𝑗 (π‘₯)
𝑗=0
Where
𝐻𝑛,𝑗 π‘₯ = [1 βˆ’ 2(π‘₯ βˆ’ π‘₯𝑗 )𝐿′ 𝑛,𝑗 (π‘₯𝑗 )]𝐿2𝑛,𝑗 (π‘₯)
𝐻𝑛,𝑗 π‘₯ = π‘₯ βˆ’ π‘₯𝑗 𝐿2𝑛,𝑗 π‘₯
Moreover, if 𝑓 ∈ 𝐢 2𝑛+2 π‘Ž, 𝑏 , then
π‘₯ βˆ’ π‘₯0 2 … π‘₯ βˆ’ π‘₯𝑛 2 2𝑛+2
𝑓 π‘₯ = 𝐻2𝑛+1 π‘₯ +
𝑓
(πœ‰(π‘₯))
2𝑛 + 2 !
for some πœ‰ π‘₯ ∈ π‘Ž, 𝑏 .
Remark:
1. 𝐻2𝑛+1 π‘₯ is a polynomial of degree at most 2𝑛 + 1.
2. 𝐿𝑛,𝑗 (π‘₯) is jth Lagrange basis polynomial of degree 𝑛.
3.
π‘₯βˆ’π‘₯0 2 … π‘₯βˆ’π‘₯𝑛 2
2𝑛+2
𝑓
2𝑛+2 !
(πœ‰(π‘₯)) is the error term.
3
3rd Degree Hermite Polynomial
β€’ Given distinct π‘₯0 , π‘₯1 and values of 𝑓 and 𝑓′ at these
numbers.
2
π‘₯ βˆ’ π‘₯0
π‘₯1 βˆ’ π‘₯
𝐻3 π‘₯ = 1 + 2
𝑓 π‘₯0
π‘₯1 βˆ’ π‘₯0 π‘₯1 βˆ’ π‘₯0
+ π‘₯ βˆ’ π‘₯0
π‘₯1 βˆ’ π‘₯
π‘₯1 βˆ’ π‘₯0
π‘₯1 βˆ’ π‘₯
+ 1+2
π‘₯1 βˆ’ π‘₯0
+ π‘₯ βˆ’ π‘₯1
π‘₯0 βˆ’ π‘₯
π‘₯0 βˆ’ π‘₯1
2
𝑓 β€² π‘₯0
π‘₯0 βˆ’ π‘₯
π‘₯0 βˆ’ π‘₯1
2
𝑓 π‘₯1
2
𝑓 β€² π‘₯1
4
Hermite Polynomial by Divided Differences
Suppose π‘₯0 , … , π‘₯𝑛 and 𝑓, 𝑓′ are given at these numbers.
Define 𝑧0 , … , 𝑧2𝑛+1 by
𝑧2𝑖 = 𝑧2𝑖+1 = π‘₯𝑖 ,
for 𝑖 = 0, … , 𝑛
Construct divided difference table, but use
𝑓 β€² π‘₯0 , 𝑓 β€² π‘₯1 , . . , 𝑓 β€² π‘₯𝑛
to set the following undefined divided difference:
𝑓 𝑧0 , 𝑧1 , 𝑓 𝑧2 , 𝑧3 , … , 𝑓 𝑧2𝑛 , 𝑧2𝑛+1 .
The Hermite polynomial is
2𝑛+1
𝐻2𝑛+1 π‘₯ = 𝑓 𝑧0 +
𝑓 𝑧0 , … , π‘§π‘˜ π‘₯ βˆ’ 𝑧0 … (π‘₯ βˆ’ π‘§π‘˜βˆ’1 )
π‘˜=1
5
Divided Difference Notation for Hermite
Interpolation
β€’ Divided difference notation:
𝐻3 π‘₯
= 𝑓 π‘₯0 + 𝑓 β€² π‘₯0 π‘₯ βˆ’ π‘₯0
+ 𝑓 π‘₯0 , π‘₯0 , π‘₯1 π‘₯ βˆ’ π‘₯0 2
+ 𝑓[π‘₯0 , π‘₯0 , π‘₯1 , π‘₯1 ] π‘₯ βˆ’ π‘₯0 2 (π‘₯ βˆ’ π‘₯1 )
6
Problems with High Order Polynomial Interpolation
β€’ 21 equal-spaced numbers to interpolate
1
𝑓 π‘₯ =
. The interpolating polynomial
2
1+16π‘₯
oscillates between interpolation points.
7
Cubic Splines
β€’ Idea: Use piecewise polynomial interpolation, i.e,
divide the interval into smaller sub-intervals, and
construct different low degree polynomial
approximations (with small oscillations) on the
sub-intervals.
β€’ Challenge: If 𝑓′(π‘₯𝑖 ) are not known, can we still
generate interpolating polynomial with
continuous derivatives?
8
Definition: Given a function 𝑓 on [π‘Ž, 𝑏] and nodes π‘Ž = π‘₯0 <
β‹― < π‘₯𝑛 = 𝑏, a cubic spline interpolant 𝑆 for 𝑓 satisfies:
(a) 𝑆(π‘₯) is a cubic polynomial 𝑆𝑗 (π‘₯) on [π‘₯𝑗 , π‘₯𝑗+1 ], βˆ€π‘— =
0,1, … , 𝑛 βˆ’ 1.
(b) 𝑆𝑗 π‘₯𝑗 = 𝑓(π‘₯𝑗 ) and 𝑆𝑗 π‘₯𝑗+1 = 𝑓 π‘₯𝑗+1 , βˆ€π‘— = 0,1, … , 𝑛 βˆ’
1.
(c) 𝑆𝑗 π‘₯𝑗+1 = 𝑆𝑗+1 π‘₯𝑗+1 , βˆ€π‘— = 0,1, … , 𝑛 βˆ’ 2.
(d) 𝑆 ′𝑗 π‘₯𝑗+1 = 𝑆 ′𝑗+1 π‘₯𝑗+1 , βˆ€π‘— = 0,1, … , 𝑛 βˆ’ 2.
(e) 𝑆 ′′𝑗 π‘₯𝑗+1 = 𝑆 ′′𝑗+1 π‘₯𝑗+1 , βˆ€π‘— = 0,1, … , 𝑛 βˆ’ 2.
(f) One of the following boundary conditions:
(i) 𝑆 β€²β€² π‘₯0 = 𝑆 β€²β€² π‘₯𝑛 = 0 (called free or natural boundary)
(ii) 𝑆 β€² π‘₯0 = 𝑓′(π‘₯0 ) and 𝑆 β€² π‘₯𝑛 = 𝑓′(π‘₯𝑛 ) (called clamped
boundary)
9
Things to match at interior point π‘₯𝑗+1 :
β€’ The spline segment 𝑆𝑗 (π‘₯) is on π‘₯𝑗 , π‘₯𝑗+1 .
β€’ The spline segment 𝑆𝑗+1 (π‘₯) is on π‘₯𝑗+1 , π‘₯𝑗+2 .
β€’ Their function values: 𝑆𝑗 π‘₯𝑗+1 = 𝑆𝑗+1 π‘₯𝑗+1 =
𝑓 π‘₯𝑗+1
β€’ First derivative values: 𝑆 ′𝑗 π‘₯𝑗+1 = 𝑆 ′𝑗+1 π‘₯𝑗+1
β€’ Second derivative values: 𝑆 ′′𝑗 π‘₯𝑗+1 = 𝑆 ′′𝑗+1 π‘₯𝑗+1
10
Building Cubic Splines
β€’ Define:
𝑆𝑗 π‘₯ = π‘Žπ‘— + 𝑏𝑗 π‘₯ βˆ’ π‘₯𝑗 + 𝑐𝑗 (π‘₯ βˆ’ π‘₯𝑗 )2 +𝑑𝑗 (π‘₯ βˆ’ π‘₯𝑗 )3
and β„Žπ‘— = π‘₯𝑗+1 βˆ’ π‘₯𝑗 , βˆ€π‘— = 0,1, … , 𝑛 βˆ’ 1.
Solve for coefficients π‘Žπ‘— , 𝑏𝑗 , 𝑐𝑗 , 𝑑𝑗 by:
1. 𝑆𝑗 π‘₯𝑗 = π‘Žπ‘— = 𝑓(π‘₯𝑗 )
2. 𝑆𝑗+1 π‘₯𝑗+1 = π‘Žπ‘—+1 = π‘Žπ‘— + 𝑏𝑗 β„Žπ‘— + 𝑐𝑗 (β„Žπ‘— )2 +𝑑𝑗 (β„Žπ‘— )3
3. 𝑆 ′𝑗 π‘₯𝑗 = 𝑏𝑗 , also 𝑏𝑗+1 = 𝑏𝑗 + 2𝑐𝑗 β„Žπ‘— + 3𝑑𝑗 (β„Žπ‘— )2
4. 𝑆 ′′𝑗 π‘₯𝑗 = 2𝑐𝑗 , also 𝑐𝑗+1 = 𝑐𝑗 + 3𝑑𝑗 β„Žπ‘—
5. Natural or clamped boundary conditions
11
Solving the Resulting Equations
βˆ€π‘— = 1, … , 𝑛 βˆ’ 1
β„Žπ‘—βˆ’1 π‘π‘—βˆ’1 + 2 β„Žπ‘—βˆ’1 + β„Žπ‘— 𝑐𝑗 + β„Žπ‘— 𝑐𝑗+1
3
3
=
π‘Žπ‘—+1 βˆ’ π‘Žπ‘— βˆ’
π‘Žπ‘— βˆ’ π‘Žπ‘—βˆ’1
β„Žπ‘—
β„Žπ‘—βˆ’1
Remark: (n-1) equations for (n+1) unknowns {𝑐𝑗 }𝑛𝑗=0 .
Once compute 𝑐𝑗 , we then compute:
𝑏𝑗 =
π‘Žπ‘—+1 βˆ’π‘Žπ‘—
β„Žπ‘—
βˆ’
β„Žπ‘— 2𝑐𝑗 +𝑐𝑗+1
3
𝑐𝑗+1 βˆ’ 𝑐𝑗
𝑑𝑗 =
3β„Žπ‘—
12
Completing the System
β€’ Natural boundary condition:
1. 0 = 𝑆 β€²β€² 0 π‘₯0 = 2𝑐0 β†’ 𝑐0 = 0
2. 0 = 𝑆 β€²β€² 𝑛 π‘₯𝑛 = 2𝑐𝑛 β†’ 𝑐𝑛 = 0
β€’ Clamped boundary condition:
a) 𝑆 β€² 0 π‘₯0 = 𝑏0 = 𝑓′(π‘₯0 )
b) 𝑆 β€² π‘›βˆ’1 π‘₯𝑛 = 𝑏𝑛 = π‘π‘›βˆ’1 + β„Žπ‘›βˆ’1 (π‘π‘›βˆ’1 + 𝑐𝑛 ) = 𝑓′(π‘₯𝑛 )
Remark: a) and b) gives additional equations:
3
2β„Ž0 𝑐0 + β„Ž0 𝑐1 = (π‘Ž1 βˆ’ π‘Ž0 ) βˆ’ 3𝑓′(π‘₯0 )
β„Ž0
3
β„Žπ‘›βˆ’1 π‘π‘›βˆ’1 + 2β„Žπ‘›βˆ’1 𝑐𝑛 = βˆ’
π‘Žπ‘› βˆ’ π‘Žπ‘›βˆ’1 + 3𝑓′(π‘₯𝑛 )
β„Ž0
13
Error Bound
If 𝑓 ∈ 𝐢 4 [π‘Ž, 𝑏], let 𝑀 = max |𝑓 4 (π‘₯)|. If 𝑆 is the
π‘Žβ‰€π‘₯≀𝑏
unique clamped cubic spline interpolant to 𝑓 with
respect to the nodes: π‘Ž = π‘₯0 < β‹― < π‘₯𝑛 = 𝑏, then
with
β„Ž = max π‘₯𝑗+1 βˆ’ π‘₯𝑗
0β‰€π‘—β‰€π‘›βˆ’1
max |𝑓 π‘₯ βˆ’ 𝑆(π‘₯)| ≀
π‘Žβ‰€π‘₯≀𝑏
5π‘€β„Ž4
.
384
14