3.4 hermite interpolation 3.5 cubic spline interpolationzxu2/acms40390f15/lec-3.4-5.pdfΒ Β· hermite...

26
3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation 1

Upload: others

Post on 07-Jan-2020

53 views

Category:

Documents


8 download

TRANSCRIPT

3.4 Hermite Interpolation 3.5 Cubic Spline Interpolation

1

Illustration. Consider to interpolate tanh(π‘₯π‘₯) using Lagrange polynomial and nodes π‘₯π‘₯0 = βˆ’1.5, π‘₯π‘₯1 = 0, π‘₯π‘₯2 = 1.5.

2

Now interpolate tanh(π‘₯π‘₯)using nodes π‘₯π‘₯0 = βˆ’1.5, π‘₯π‘₯1 =0, π‘₯π‘₯2 = 1.5. Moreover, Let 1st

derivative of interpolating polynomial agree with derivative of tanh(π‘₯π‘₯) at these nodes.Remark:This is called Hermiteinterpolating polynomial.

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, … ,𝑛𝑛.

3

Osculating Polynomials

Definition 3.8 Let π‘₯π‘₯0, … , π‘₯π‘₯𝑛𝑛 be distinct numbers in π‘Žπ‘Ž, 𝑏𝑏and for 𝑖𝑖 = 0, … ,𝑛𝑛, let π‘šπ‘šπ‘–π‘– be a nonnegative integer. Suppose that 𝑓𝑓 ∈ πΆπΆπ‘šπ‘š π‘Žπ‘Ž, 𝑏𝑏 , where π‘šπ‘š = max

0β‰€π‘–π‘–β‰€π‘›π‘›π‘šπ‘šπ‘–π‘–. The

osculating polynomial approximating 𝑓𝑓 is the polynomial

𝑃𝑃(π‘₯π‘₯) of least degree such that π‘‘π‘‘π‘˜π‘˜π‘ƒπ‘ƒ π‘₯π‘₯𝑖𝑖𝑑𝑑π‘₯π‘₯π‘˜π‘˜

= π‘‘π‘‘π‘˜π‘˜π‘‘π‘‘ π‘₯π‘₯𝑖𝑖𝑑𝑑π‘₯π‘₯π‘˜π‘˜

for each 𝑖𝑖 = 0, … ,𝑛𝑛 and k= 0, … ,π‘šπ‘šπ‘–π‘– .

Remark: the degree of 𝑃𝑃(π‘₯π‘₯) is at most 𝑀𝑀 = βˆ‘π‘–π‘–=0𝑛𝑛 π‘šπ‘šπ‘–π‘– + 𝑛𝑛.

4

Theorem 3.9 If 𝑓𝑓 ∈ 𝐢𝐢1 π‘Žπ‘Ž, 𝑏𝑏 and π‘₯π‘₯0, … , π‘₯π‘₯𝑛𝑛 ∈ π‘Žπ‘Ž, 𝑏𝑏 distinct numbers, the Hermite polynomial of degree at most 2𝑛𝑛 + 1 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.

5

6

Remark:

1. When 𝑖𝑖 β‰  𝑗𝑗: 𝐻𝐻𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑖𝑖 = 0; �𝐻𝐻𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑖𝑖 = 0.2. When 𝑖𝑖 = 𝑗𝑗:

�𝐻𝐻𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑗𝑗 = 1 βˆ’ 2 π‘₯π‘₯𝑗𝑗 βˆ’ π‘₯π‘₯𝑗𝑗 𝐿𝐿′𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑗𝑗 𝐿𝐿𝑛𝑛,𝑗𝑗

2 π‘₯π‘₯𝑗𝑗 = 1�𝐻𝐻𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑗𝑗 = π‘₯π‘₯𝑗𝑗 βˆ’ π‘₯π‘₯𝑗𝑗 𝐿𝐿𝑛𝑛,𝑗𝑗

2 π‘₯π‘₯𝑗𝑗 = 0

⟹𝐻𝐻2𝑛𝑛+1 π‘₯π‘₯𝑗𝑗 = 𝑓𝑓(π‘₯π‘₯𝑗𝑗).

3. 𝐻𝐻′𝑛𝑛,𝑗𝑗 π‘₯π‘₯ = 𝐿𝐿𝑛𝑛,𝑗𝑗 π‘₯π‘₯ βˆ’2𝐿𝐿𝑛𝑛,𝑗𝑗′ π‘₯π‘₯𝑗𝑗 𝐿𝐿𝑛𝑛,𝑗𝑗 π‘₯π‘₯ + 1 βˆ’ 2 π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗 𝐿𝐿𝑛𝑛,𝑗𝑗

β€² π‘₯π‘₯𝑗𝑗 2𝐿𝐿𝑛𝑛,𝑗𝑗′ π‘₯π‘₯

⟹ When 𝑖𝑖 β‰  𝑗𝑗:𝐻𝐻′𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑖𝑖 = 0; When 𝑖𝑖 = 𝑗𝑗:𝐻𝐻′

𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑗𝑗 = 0.

4. �𝐻𝐻′𝑛𝑛,𝑗𝑗 π‘₯π‘₯ = 𝐿𝐿𝑛𝑛,𝑗𝑗2 π‘₯π‘₯ + 2 π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗 𝐿𝐿𝑛𝑛,𝑗𝑗(π‘₯π‘₯)𝐿𝐿′𝑛𝑛,𝑗𝑗 π‘₯π‘₯

⟹ When 𝑖𝑖 β‰  𝑗𝑗: �𝐻𝐻′𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑖𝑖 = 0; When 𝑖𝑖 = 𝑗𝑗: �𝐻𝐻′𝑛𝑛,𝑗𝑗 π‘₯π‘₯𝑗𝑗 = 1.

Example 3.4.1 Use Hermite polynomial that agrees with the data in the table to find an approximation of 𝑓𝑓 1.5

7

π‘˜π‘˜ π‘₯π‘₯π‘˜π‘˜ 𝑓𝑓(π‘₯π‘₯π‘˜π‘˜) 𝑓𝑓′(π‘₯π‘₯π‘˜π‘˜)0 1.3 0.6200860 βˆ’0.52202321 1.6 0.4554022 βˆ’0.56989592 1.9 0.2818186 βˆ’0.5811571

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

8

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 .

Namely, 𝑓𝑓 𝑧𝑧0, 𝑧𝑧1 = 𝑓𝑓′ π‘₯π‘₯0 , 𝑓𝑓 𝑧𝑧2, 𝑧𝑧3 = 𝑓𝑓′ π‘₯π‘₯1 , …𝑓𝑓 𝑧𝑧2𝑛𝑛, 𝑧𝑧2𝑛𝑛+1 = 𝑓𝑓′ π‘₯π‘₯𝑛𝑛 .

The Hermite polynomial is

𝐻𝐻2𝑛𝑛+1 π‘₯π‘₯ = 𝑓𝑓 𝑧𝑧0 + οΏ½π‘˜π‘˜=1

2𝑛𝑛+1

𝑓𝑓 𝑧𝑧0, … , π‘§π‘§π‘˜π‘˜ π‘₯π‘₯ βˆ’ 𝑧𝑧0 … (π‘₯π‘₯ βˆ’ π‘§π‘§π‘˜π‘˜βˆ’1)9

Example 3.4.2 Use divided difference method to determine the Hermite polynomial that agrees with the data in the table to find an approximation of 𝑓𝑓 1.5

10

π‘˜π‘˜ π‘₯π‘₯π‘˜π‘˜ 𝑓𝑓(π‘₯π‘₯π‘˜π‘˜) 𝑓𝑓′(π‘₯π‘₯π‘˜π‘˜)0 1.3 0.6200860 βˆ’0.52202321 1.6 0.4554022 βˆ’0.56989592 1.9 0.2818186 βˆ’0.5811571

Divided Difference Notation for HermiteInterpolation

β€’ Divided difference notation for Hermitepolynomial interpolating 2 nodes: π‘₯π‘₯0, π‘₯π‘₯1.

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

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

11

Problems with High Order Polynomial Interpolation

β€’ 21 equal-spaced numbers to interpolate 𝑓𝑓 π‘₯π‘₯ = 1

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

oscillates between interpolation points.

12

3.5 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.

Example. Piecewise-linear interpolation

13

β€’ Challenge: If 𝑓𝑓′(π‘₯π‘₯𝑖𝑖) are not known, can we still generate interpolating polynomial with continuous derivatives?

β€’ Spline: A spline consists of a long strip of wood (a lath) fixed in position at a number of points. The lath will take the shape which minimizes the energy required for bending it between the fixed points, and thus adopt the smoothest possible shape.

14

β€’ In mathematics, a spline is a function that is piecewise-defined by polynomial functions, and which possesses a high degree of smoothness at the places where the polynomial pieces connect.

β€’ Example. Irwin-Hall distribution. Nodes are -2, -1, 0, 1, 2.

𝑓𝑓 π‘₯π‘₯ =

14π‘₯π‘₯ + 2 3 βˆ’ 2 ≀ π‘₯π‘₯ ≀ βˆ’1

14

3 π‘₯π‘₯ 3 βˆ’ 6π‘₯π‘₯2 + 4 βˆ’ 1 ≀ π‘₯π‘₯ ≀ 114

2 βˆ’ π‘₯π‘₯ 3 1 ≀ π‘₯π‘₯ ≀ 2

Notice: 𝑓𝑓′ βˆ’1 = 34

, 𝑓𝑓′ 1 = βˆ’34

,𝑓𝑓′′ βˆ’1 = 64

,𝑓𝑓′′ 1 = 64

.

15

β€’ Piecewise-polynomial approximation using cubic polynomials between each successive pair of nodes is called cubic spline interpolation.

Definition 3.10 Given a function 𝑓𝑓 on [π‘Žπ‘Ž, 𝑏𝑏] and nodes π‘Žπ‘Ž = π‘₯π‘₯0 <β‹― < π‘₯π‘₯𝑛𝑛 = 𝑏𝑏, a cubic spline interpolant 𝑆𝑆 for 𝑓𝑓 satisfies:(a) 𝑆𝑆(π‘₯π‘₯) is a cubic polynomial 𝑆𝑆𝑗𝑗(π‘₯π‘₯) on [π‘₯π‘₯𝑗𝑗 , π‘₯π‘₯𝑗𝑗+1] with:

𝑆𝑆𝑗𝑗 π‘₯π‘₯ = π‘Žπ‘Žπ‘—π‘— + 𝑏𝑏𝑗𝑗 π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗 + 𝑐𝑐𝑗𝑗 π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗2 + 𝑑𝑑𝑗𝑗 π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗

3

βˆ€π‘—π‘— = 0,1, … ,𝑛𝑛 βˆ’ 1.(b) 𝑆𝑆𝑗𝑗 π‘₯π‘₯𝑗𝑗 = 𝑓𝑓(π‘₯π‘₯𝑗𝑗) and 𝑆𝑆𝑗𝑗 π‘₯π‘₯𝑗𝑗+1 = 𝑓𝑓 π‘₯π‘₯𝑗𝑗+1 , βˆ€π‘—π‘— = 0,1, … ,𝑛𝑛 βˆ’ 1.(c) 𝑆𝑆𝑗𝑗 π‘₯π‘₯𝑗𝑗+1 = 𝑆𝑆𝑗𝑗+1 π‘₯π‘₯𝑗𝑗+1 , βˆ€π‘—π‘— = 0,1, … ,𝑛𝑛 βˆ’ 2.

Remark: (c) is derived from (b).(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)

16

The spline segment 𝑆𝑆𝑗𝑗(π‘₯π‘₯) is on π‘₯π‘₯𝑗𝑗 , π‘₯π‘₯𝑗𝑗+1 . The spline segment 𝑆𝑆𝑗𝑗+1(π‘₯π‘₯) is on π‘₯π‘₯𝑗𝑗+1, π‘₯π‘₯𝑗𝑗+2 . Things to match at interior point π‘₯π‘₯𝑗𝑗+1:β€’ Their function values: 𝑆𝑆𝑗𝑗 π‘₯π‘₯𝑗𝑗+1 = 𝑆𝑆𝑗𝑗+1 π‘₯π‘₯𝑗𝑗+1 =𝑓𝑓 π‘₯π‘₯𝑗𝑗+1

β€’ First derivative values: 𝑆𝑆′𝑗𝑗 π‘₯π‘₯𝑗𝑗+1 = 𝑆𝑆′𝑗𝑗+1 π‘₯π‘₯𝑗𝑗+1β€’ Second derivative values: 𝑆𝑆′′𝑗𝑗 π‘₯π‘₯𝑗𝑗+1 = 𝑆𝑆′′𝑗𝑗+1 π‘₯π‘₯𝑗𝑗+1

17

Example 3.5.1 Construct a natural spline 𝑆𝑆 π‘₯π‘₯through (1,2), (2,3) and (3.5).

18

Building Cubic Splinesβ€’ Define: 𝑆𝑆𝑗𝑗 π‘₯π‘₯ = π‘Žπ‘Žπ‘—π‘— + 𝑏𝑏𝑗𝑗 π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗 + 𝑐𝑐𝑗𝑗(π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗)2+𝑑𝑑𝑗𝑗(π‘₯π‘₯ βˆ’ π‘₯π‘₯𝑗𝑗)3

and β„Žπ‘—π‘— = π‘₯π‘₯𝑗𝑗+1 βˆ’ π‘₯π‘₯𝑗𝑗, βˆ€π‘—π‘— = 0,1, … , (𝑛𝑛 βˆ’ 1).β€’ Also define π‘Žπ‘Žπ‘›π‘› = 𝑓𝑓 π‘₯π‘₯𝑛𝑛 ; 𝑏𝑏𝑛𝑛 = 𝑆𝑆′ π‘₯π‘₯𝑛𝑛 ; 𝑐𝑐𝑛𝑛 = 𝑆𝑆′′(π‘₯π‘₯𝑛𝑛)/2.From Definition 3.10:1) 𝑆𝑆𝑗𝑗 π‘₯π‘₯𝑗𝑗 = π‘Žπ‘Žπ‘—π‘— = 𝑓𝑓 π‘₯π‘₯𝑗𝑗 for 𝑗𝑗 = 0,1, … , (𝑛𝑛 βˆ’ 1).2) 𝑆𝑆𝑗𝑗+1 π‘₯π‘₯𝑗𝑗+1 = π‘Žπ‘Žπ‘—π‘—+1 = π‘Žπ‘Žπ‘—π‘— + π‘π‘π‘—π‘—β„Žπ‘—π‘— + 𝑐𝑐𝑗𝑗(β„Žπ‘—π‘— )2+𝑑𝑑𝑗𝑗(β„Žπ‘—π‘— )3

for 𝑗𝑗 = 0,1, … , (𝑛𝑛 βˆ’ 1).𝑁𝑁𝑁𝑁𝑁𝑁𝑁𝑁: π‘Žπ‘Žπ‘›π‘› = π‘Žπ‘Žπ‘›π‘›βˆ’1 + π‘π‘π‘›π‘›βˆ’1β„Žπ‘›π‘›βˆ’1 + π‘π‘π‘›π‘›βˆ’1(β„Žπ‘›π‘›βˆ’1)2+π‘‘π‘‘π‘›π‘›βˆ’1(β„Žπ‘›π‘›βˆ’1)3

3) 𝑆𝑆′𝑗𝑗 π‘₯π‘₯𝑗𝑗 = 𝑏𝑏𝑗𝑗, also 𝑏𝑏𝑗𝑗+1 = 𝑏𝑏𝑗𝑗 + 2π‘π‘π‘—π‘—β„Žπ‘—π‘— + 3𝑑𝑑𝑗𝑗(β„Žπ‘—π‘— )2for 𝑗𝑗 = 0,1, … , (𝑛𝑛 βˆ’ 1).

4) 𝑆𝑆′′𝑗𝑗 π‘₯π‘₯𝑗𝑗 = 2𝑐𝑐𝑗𝑗, also 𝑐𝑐𝑗𝑗+1 = 𝑐𝑐𝑗𝑗 + 3π‘‘π‘‘π‘—π‘—β„Žπ‘—π‘—for 𝑗𝑗 = 0,1, … , 𝑛𝑛 βˆ’ 1 .

5) Natural or clamped boundary conditions19

Solve π‘Žπ‘Žπ‘—π‘— , 𝑏𝑏𝑗𝑗 , 𝑐𝑐𝑗𝑗 ,𝑑𝑑𝑗𝑗 by substitution:1. Solve Eq. 4) for 𝑑𝑑𝑗𝑗 =

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

, and substitute into Eqs. 2) and 3) to get:

2. π‘Žπ‘Žπ‘—π‘—+1 = π‘Žπ‘Žπ‘—π‘— + π‘π‘π‘—π‘—β„Žπ‘—π‘— +β„Žπ‘—π‘—2

32𝑐𝑐𝑗𝑗 + 𝑐𝑐𝑗𝑗+1 ; (3.18)

𝑏𝑏𝑗𝑗+1 = 𝑏𝑏𝑗𝑗 + β„Žπ‘—π‘— 𝑐𝑐𝑗𝑗 + 𝑐𝑐𝑗𝑗+1 . (3.19)3. Solve for 𝑏𝑏𝑗𝑗 in Eq. (3.18) to get:

𝑏𝑏𝑗𝑗 = 1β„Žπ‘—π‘—

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

2𝑐𝑐𝑗𝑗 + 𝑐𝑐𝑗𝑗+1 . (3.20)Reduce the index by 1 to get:

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

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

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

4. Substitute 𝑏𝑏𝑗𝑗 and π‘π‘π‘—π‘—βˆ’1 into Eq. (3.19):β„Žπ‘—π‘—βˆ’1π‘π‘π‘—π‘—βˆ’1 + 2 β„Žπ‘—π‘—βˆ’1 + β„Žπ‘—π‘— 𝑐𝑐𝑗𝑗 + β„Žπ‘—π‘—π‘π‘π‘—π‘—+1 = (3.21)

3β„Žπ‘—π‘—

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

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

for 𝑗𝑗 = 1,2, … , 𝑛𝑛 βˆ’ 1 .20

Solving the Resulting Equationsβˆ€π‘—π‘— = 1,2, … , (𝑛𝑛 βˆ’ 1)

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

=3β„Žπ‘—π‘—

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

β„Žπ‘—π‘—βˆ’1π‘Žπ‘Žπ‘—π‘— βˆ’ π‘Žπ‘Žπ‘—π‘—βˆ’1 (3.21)

Remark: (n-1) equations for (n+1) unknowns {𝑐𝑐𝑗𝑗}𝑗𝑗=0𝑛𝑛 . Eq. (3.21) is solved with boundary conditions. β€’ Once compute 𝑐𝑐𝑗𝑗, we then compute:

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

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

(3.20)

and

𝑑𝑑𝑗𝑗 = 𝑐𝑐𝑗𝑗+1βˆ’π‘π‘π‘—π‘—3β„Žπ‘—π‘—

(3.17) for 𝑗𝑗 = 0,1,2, … , (𝑛𝑛 βˆ’ 1)21

Building Natural Cubic Spline β€’ Natural boundary condition:

1. 0 = 𝑆𝑆′′0 π‘₯π‘₯0 = 2𝑐𝑐0 β†’ 𝑐𝑐0 = 02. 0 = 𝑆𝑆′′𝑛𝑛 π‘₯π‘₯𝑛𝑛 = 2𝑐𝑐𝑛𝑛 β†’ 𝑐𝑐𝑛𝑛 = 0

Step 1. Solve Eq. (3.21) together with 𝑐𝑐0 = 0 and 𝑐𝑐𝑛𝑛 = 0 to obtain {𝑐𝑐𝑗𝑗}𝑗𝑗=0𝑛𝑛 .

Step 2. Solve Eq. (3.20) to obtain {𝑏𝑏𝑗𝑗}𝑗𝑗=0π‘›π‘›βˆ’1.

Step 3. Solve Eq. (3.17) to obtain {𝑑𝑑𝑗𝑗}𝑗𝑗=0π‘›π‘›βˆ’1.

22

Building Clamped Cubic Splineβ€’ 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

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

Step 1. Solve Eq. (3.21) together with Eqs. (a) and (b) to obtain {𝑐𝑐𝑗𝑗}𝑗𝑗=0𝑛𝑛 .Step 2. Solve Eq. (3.20) to obtain {𝑏𝑏𝑗𝑗}𝑗𝑗=0π‘›π‘›βˆ’1.Step 3. Solve Eq. (3.17) to obtain {𝑑𝑑𝑗𝑗}𝑗𝑗=0π‘›π‘›βˆ’1.

23

Example 3.5.4 Let (π‘₯π‘₯0,𝑓𝑓(π‘₯π‘₯0)) =(0,1), (π‘₯π‘₯1, 𝑓𝑓(π‘₯π‘₯1)) = (1, 𝑁𝑁), (π‘₯π‘₯2, 𝑓𝑓(π‘₯π‘₯2)) = (2, 𝑁𝑁2),(π‘₯π‘₯3, 𝑓𝑓(π‘₯π‘₯3)) = (3, 𝑁𝑁3). And 𝑓𝑓′ π‘₯π‘₯0 = 𝑁𝑁, 𝑓𝑓′ π‘₯π‘₯3 = 𝑁𝑁3.Determine the clamped spline 𝑆𝑆 π‘₯π‘₯ .

24

Theorem 3.11 If 𝑓𝑓 is defined at the nodes: π‘Žπ‘Ž =π‘₯π‘₯0 < β‹― < π‘₯π‘₯𝑛𝑛 = 𝑏𝑏, then 𝑓𝑓 has a unique natural spline interpolant 𝑆𝑆 on the nodes; that is a spline interpolant that satisfied the natural boundary conditions 𝑆𝑆′′ π‘Žπ‘Ž = 0, 𝑆𝑆′′ 𝑏𝑏 = 0.

Theorem 3.12 If 𝑓𝑓 is defined at the nodes: π‘Žπ‘Ž =π‘₯π‘₯0 < β‹― < π‘₯π‘₯𝑛𝑛 = 𝑏𝑏 and differentiable at π‘Žπ‘Ž and 𝑏𝑏, then 𝑓𝑓 has a unique clamped spline interpolant 𝑆𝑆on the nodes; that is a spline interpolant that satisfied the clamped boundary conditions 𝑆𝑆′ π‘Žπ‘Ž = 𝑓𝑓′(π‘Žπ‘Ž), 𝑆𝑆′ 𝑏𝑏 = 𝑓𝑓′(𝑏𝑏).

25

Error BoundTheorem 3.13 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.

26