14
3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation 1

3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

  • Upload
    others

  • View
    21

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

1

Page 2: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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

Page 3: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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

𝑓 π‘₯ = 𝐻2𝑛+1 π‘₯ +π‘₯ βˆ’ π‘₯0

2… π‘₯ βˆ’ π‘₯𝑛2

2𝑛 + 2 !𝑓 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

Page 4: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

3rd Degree Hermite Polynomial

β€’ Given distinct π‘₯0, π‘₯1 and values of 𝑓 and 𝑓′ at these numbers.

𝐻3 π‘₯ = 1 + 2π‘₯ βˆ’ π‘₯0π‘₯1 βˆ’ π‘₯0

π‘₯1 βˆ’ π‘₯

π‘₯1 βˆ’ π‘₯0

2

𝑓 π‘₯0

+ π‘₯ βˆ’ π‘₯0π‘₯1 βˆ’ π‘₯

π‘₯1 βˆ’ π‘₯0

2

𝑓′ π‘₯0

+ 1 + 2π‘₯1 βˆ’ π‘₯

π‘₯1 βˆ’ π‘₯0

π‘₯0 βˆ’ π‘₯

π‘₯0 βˆ’ π‘₯1

2

𝑓 π‘₯1

+ π‘₯ βˆ’ π‘₯1π‘₯0 βˆ’ π‘₯

π‘₯0 βˆ’ π‘₯1

2

𝑓′ π‘₯1

4

Page 5: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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 π‘₯ = 𝑓 𝑧0 + 𝑓 𝑧0, … , π‘§π‘˜ π‘₯ βˆ’ 𝑧0 …(π‘₯ βˆ’ π‘§π‘˜βˆ’1)

2𝑛+1

π‘˜=1

5

Page 6: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

Divided Difference Notation for Hermite Interpolation

β€’ Divided difference notation: 𝐻3 π‘₯

= 𝑓 π‘₯0 + 𝑓′ π‘₯0 π‘₯ βˆ’ π‘₯0+ 𝑓 π‘₯0, π‘₯0, π‘₯1 π‘₯ βˆ’ π‘₯0

2

+ 𝑓[π‘₯0, π‘₯0, π‘₯1, π‘₯1] π‘₯ βˆ’ π‘₯02(π‘₯ βˆ’ π‘₯1)

6

Page 7: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

Problems with High Order Polynomial Interpolation

β€’ 21 equal-spaced numbers to interpolate

𝑓 π‘₯ =1

1+16π‘₯2. The interpolating polynomial

oscillates between interpolation points.

7

Page 8: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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

Page 9: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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

Page 10: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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

Page 11: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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

Page 12: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

Solving the Resulting Equations

βˆ€π‘— = 1,… , 𝑛 βˆ’ 1

β„Žπ‘—βˆ’1π‘π‘—βˆ’1 + 2 β„Žπ‘—βˆ’1 + β„Žπ‘— 𝑐𝑗 + β„Žπ‘—π‘π‘—+1

=3

β„Žπ‘—π‘Žπ‘—+1 βˆ’ π‘Žπ‘— βˆ’

3

β„Žπ‘—βˆ’1π‘Žπ‘— βˆ’ π‘Žπ‘—βˆ’1

Remark: (n-1) equations for (n+1) unknowns {𝑐𝑗}𝑗=0𝑛 .

Once compute 𝑐𝑗, we then compute:

𝑏𝑗 = π‘Žπ‘—+1βˆ’π‘Žπ‘—

β„Žπ‘—βˆ’

β„Žπ‘— 2𝑐𝑗+𝑐𝑗+1

3

𝑑𝑗 =𝑐𝑗+1 βˆ’ 𝑐𝑗

3β„Žπ‘—

12

Page 13: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

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:

2β„Ž0𝑐0 + β„Ž0𝑐1 =3

β„Ž0(π‘Ž1 βˆ’ π‘Ž0) βˆ’ 3𝑓′(π‘₯0)

β„Žπ‘›βˆ’1π‘π‘›βˆ’1 + 2β„Žπ‘›βˆ’1𝑐𝑛 = βˆ’3

β„Ž0π‘Žπ‘› βˆ’ π‘Žπ‘›βˆ’1 + 3𝑓′(π‘₯𝑛)

13

Page 14: 3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

Error Bound

If 𝑓 ∈ 𝐢4[π‘Ž, 𝑏], let 𝑀 = maxπ‘Žβ‰€π‘₯≀𝑏

|𝑓4(π‘₯)|. If 𝑆 is the

unique clamped cubic spline interpolant to 𝑓 with respect to the nodes: π‘Ž = π‘₯0 < β‹― < π‘₯𝑛 = 𝑏, then with

β„Ž = max0β‰€π‘—β‰€π‘›βˆ’1

π‘₯𝑗+1 βˆ’ π‘₯𝑗

maxπ‘Žβ‰€π‘₯≀𝑏

|𝑓 π‘₯ βˆ’ 𝑆(π‘₯)| ≀5π‘€β„Ž4

384.

14