Cubic spline interpolation High-degree polynomial fitting has strong - - PowerPoint PPT Presentation

cubic spline interpolation
SMART_READER_LITE
LIVE PREVIEW

Cubic spline interpolation High-degree polynomial fitting has strong - - PowerPoint PPT Presentation

Cubic spline interpolation High-degree polynomial fitting has strong oscillations. Can we get a piecewise low degree polynomial interpolation instead? S ( x ) S n 2 S n 1 S j S 1 S j 1 S 0 S j ( x j 1 ) f ( x j 1 )


slide-1
SLIDE 1

Cubic spline interpolation

High-degree polynomial fitting has strong oscillations. Can we get a piecewise “low degree” polynomial interpolation instead?

x0 x1 x2 xj xj1 xj2 xn1 xn . . . . . . S(x) x xn2 S0 S1 Sj Sj1 Sn1 Sn2 Sj(xj1) f(xj1) Sj1(xj1) Sj(xj1) Sj1(xj1)

  • Sj (xj1) Sj1(xj1)
  • Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University

122

slide-2
SLIDE 2

Cubic spline interpolation

Suppose we are given x0, . . . , xn and f (xi), ∀ i, we want to find a cubic spline interpolation S(x), s.t.

  • 1. S(x) is a cubic polynomial, denoted by Sj(x), on [xj, xj+1];
  • 2. Sj(xj) = f (xj), Sj(xj+1) = f (xj+1)
  • 3. Sj(xj) = Sj+1(xj) for all j (consequence of Item 2.)
  • 4. S′

j+1(xj+1) = S′ j(xj+1) for all j

  • 5. S′′

j+1(xj+1) = S′′ j (xj+1) for all j

  • 6. One of the following boundary condition is satisfied:

◮ S′′(x0) = S′′(xn) = 0 (natural/free boundary condition) ◮ S′(x0) = f ′(x0) and S′(xn) = f ′(xn) (clamped boundary condition)

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 123

slide-3
SLIDE 3

Cubic spline interpolation

Remarks

  • 1. S(x) only agrees with f (x) at xi, not necessarily f ′(x).
  • 2. Clamped BC is more accurate than natural BC, but needs

f ′(a), f ′(b).

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 124

slide-4
SLIDE 4

Example

Example (Construct a natural cubic spline)

Construct natural cubic spline for f (x) = ex using xi = i for i = 0, 1, 2, 3.

x y

1

1 2 3

e e e

3 2

y = S(x) y = e x

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 125

slide-5
SLIDE 5

Construction of cubic splines

Given {(xi, f (xi)) : i = 0, . . . , n}, we need to construct n cubic polynomials, each with 4 coefficients Sj(x) = aj + bj(x − xj) + cj(x − xj)2 + dj(x − xj)3 on [xj, xj+1], ∀j So we have 4n unknowns to determine: aj, bj, cj, dj, for j = 0, . . . , n − 1

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 126

slide-6
SLIDE 6

Construction of cubic splines

The cubic spline conditions will determine these 4n coefficients uniquely (hj := xj+1 − xj) according to the 6 rules:

  • 1. By definition of Sj.
  • 2. Since Sj(xj) = aj = f (xj), we get aj for j = 0, . . . , n − 1.
  • 3. aj+1 = Sj+1(xj+1) = Sj(xj+1) = aj + bjhj + cjh2

j + djh3 j .

  • 4. S′

j(x) = bj + 2cj(x − xj) + 3dj(x − xj)2, therefore S′ j(xj) = bj

and bj+1 = S′

j+1(xj+1) = S′ j(xj+1) = bj + 2cjhj + 3djh2 j .

  • 5. S′′

j (x) = 2cj + 6dj(x − xj). Then we have S′′ j (xj) = 2cj. So

2cj+1 = S′′

j+1(xj+1) = S′′ j (xj) = 2cj + 6djhj.

  • 6. Use the required boundary condition.

◮ Natural BC: c0 = cn = 0 ◮ Clamped BC: b0 = f ′(a), bn = f ′(b).

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 127

slide-7
SLIDE 7

Construction of cubic splines

As we have known the values of aj, we can combine equations from the last 3 items to solve for cj and obtain hj−1cj−1 +2(hj−1 +hj)cj +hjcj+1 = 3 hj (aj+1 −aj)− 3 hj−1 (aj −aj−1) for each j = 1, . . . , n − 1. If we assume natural splines with S′′

0 (x0) = S′′ n−1(xn) = 0, then c0 = cn = 0.

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 128