3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation
1 Hermite Polynomial
1 Definition. Suppose 푓 ∈ 퐶 [푎, 푏]. 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 st also 1 derivative values at 푥푖, 푖 = 0, … , 푛.
2 1 Theorem. If 푓 ∈ 퐶 푎, 푏 and 푥0, … , 푥푛 ∈ 푎, 푏 distinct numbers, the Hermite polynomial is: 푛 푛
퐻2푛+1 푥 = 푓 푥푗 퐻푛,푗(푥) + 푓′ 푥푗 퐻 푛,푗(푥) 푗=0 푗=0 Where ′ 2 퐻푛,푗 푥 = [1 − 2(푥 − 푥푗)퐿 푛,푗(푥푗)]퐿푛,푗(푥) 2 퐻푛,푗 푥 = 푥 − 푥푗 퐿푛,푗 푥 Moreover, if 푓 ∈ 퐶2푛+2 푎, 푏 , then 2 2 푥 − 푥 … 푥 − 푥푛 푓 푥 = 퐻 푥 + 0 푓 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 푛. 푥−푥 2… 푥−푥 2 3. 0 푛 푓 2푛+2 (휉(푥)) is the error term. 2푛+2 ! 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 2 푥1 − 푥 ′ + 푥 − 푥0 푓 푥0 푥1 − 푥0 2 푥1 − 푥 푥0 − 푥 + 1 + 2 푓 푥1 푥1 − 푥0 푥0 − 푥1 2 푥0 − 푥 ′ + 푥 − 푥1 푓 푥1 푥0 − 푥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 2 + 푓 푥0, 푥0, 푥1 푥 − 푥0 2 + 푓[푥0, 푥0, 푥1, 푥1] 푥 − 푥0 (푥 − 푥1)
6 Problems with High Order Polynomial Interpolation
• 21 equal-spaced numbers to interpolate 1 푓 푥 = . The interpolating polynomial 1+16푥2 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 3 2. 푆푗+1 푥푗+1 = 푎푗+1 = 푎푗 + 푏푗ℎ푗 + 푐푗(ℎ푗) +푑푗(ℎ푗) ′ 2 3. 푆 푗 푥푗 = 푏푗, also 푏푗+1 = 푏푗 + 2푐푗ℎ푗 + 3푑푗(ℎ푗) ′′ 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 5푀ℎ4 max |푓 푥 − 푆(푥)| ≤ . 푎≤푥≤푏 384
14