• 沒有找到結果。

Interpolation and Polynomial Approximation

N/A
N/A
Protected

Academic year: 2022

Share "Interpolation and Polynomial Approximation"

Copied!
60
0
0

加載中.... (立即查看全文)

全文

(1)

師大

Interpolation and Polynomial Approximation

Tsung-Ming Huang

Department of Mathematics National Taiwan Normal University, Taiwan

November 18, 2007

(2)

師大

Outline

1 Interpolation and the Lagrange polynomial

2 Divided Differences

3 Hermite Interpolation

4 Cubic spline interpolation

(3)

師大

Introduction

Question

In reviewing these data, how to provide a reasonable estimate of the population, say, in 1965, or even in 2010.

(4)

師大

Interpolation

Suppose we do not know the function f , but a few information (data) about f , now we try to compute a function g that approximates f . Theorem (Weierstrass Approximation Theorem)

Suppose that f is defined and continuous on [a, b]. For any ε > 0, there exists a polynomial P (x), defined on [a, b], with the property that

|f (x) − P (x)| < ε, for all x in [a, b].

Reason for using polynomial

1 They uniformly approximate continuous function (Weierstrass Theorem)

2 The derivatives and indefinite integral of a polynomial are easy to determine and are also polynomials.

(5)

師大

Interpolation and the Lagrange polynomial

Property

The linear function passing through (x0, f (x0)) and (x1, f (x1)) is unique.

Let

L0(x) = x − x1

x0− x1, L1(x) = x − x0 x1− x0 and

P (x) = L0(x)f (x0) + L1(x)f (x1).

Then

P (x0) = f (x0), P (x1) = f (x1).

(6)

師大

Question

How to find the polynomial of degree n that passes through

(x0, f (x0)), . . . , (xn, f (xn))?

Theorem

If (xi, yi), xi, yi ∈ R, i = 0, 1, . . . , n, are n + 1 distinct pairs of data point, then there is a unique polynomial Pn of degree at most n such that

Pn(xi) = yi, (0 ≤ i ≤ n). (1)

(7)

師大

Proof of Existence (by mathematical induction)

1 The theorem clearly holds for n = 0 (only one data point (x0, y0)) since one may choose the constant polynomial P0(x) = y0 for all x.

2 Assume that the theorem holds for n ≤ k, that is, there is a polynomial Pk, deg(Pk) ≤ k, such that yi= Pk(xi), for 0 ≤ i ≤ k.

3 Next we try to construct a polynomial of degree at most k + 1 to interpolate (xi, yi), 0 ≤ i ≤ k + 1. Let

Pk+1(x) = Pk(x) + c(x − x0)(x − x1) · · · (x − xk), where

c = yk+1− Pk(xk+1)

(xk+1− x0)(xk+1− x1) · · · (xk+1− xk). Since xi are distinct, the polynomial Pk+1(x) is well-defined and deg(Pk+1) ≤ k + 1. It is easy to verify that

Pk+1(xi) = yi, 0 ≤ i ≤ k + 1.

(8)

師大

Proof of Uniqueness

Suppose there are two such polynomials Pn and Qn satisfying (1). Define Sn(x) = Pn(x) − Qn(x).

Since both deg(Pn) ≤ n and deg(Qn) ≤ n, deg(Sn) ≤ n. Moreover Sn(xi) = Pn(xi) − Qn(xi) = yi− yi= 0,

for 0 ≤ i ≤ n. This means that Sn has at least n + 1 zeros, it therefore must be Sn= 0. Hence Pn= Qn.

(9)

師大

Idea

Construct polynomial P (x) with deg(P ) ≤ n as

P (x) = Ln,0(x)f (x0) + · · · + Ln,n(x)f (xn), where

1 Ln,k(x) are polynomial with degree n for 0 ≤ k ≤ n.

2 Ln,k(xk) = 1 and Ln,k(xi) = 0 for i 6= k.

Then

P (xk) = f (xk) for k = 0, 1, . . . , n.

1 deg(Ln,k) = n and Ln,k(xi) = 0 for i 6= k:

Ln,k(x) = ck(x − x0)(x − x1) · · · (x − xk−1)(x − xk+1) · · · (x − xn)

2 Ln,k(xk) = 1:

Ln,k(x) = (x − x0)(x − x1) · · · (x − xk−1)(x − xk+1) · · · (x − xn) (xk− x0)(xk− x1) · · · (xk− xk−1)(xk− xk+1) · · · (xk− xn)

(10)

師大

Theorem

If x0, x1, . . . , xn are n + 1 distinct numbers and f is a function whose values are given at these numbers, then a unique polynomial of degree at most n exists with

f (xk) = P (xk), for k = 0, 1, . . . , n.

This polynomial is given by P (x) =

n

X

k=0

f (xk)Ln,k(x)

which is called the nth Lagrange interpolating polynomial.

Note that we will write Ln,k(x) simply as Lk(x) when there is no confusion as to its degree.

(11)

師大

Example

Given the following 4 data points,

xi 0 1 3 5

yi 1 2 6 7

find a polynomial in Lagrange form to interpolate these data.

Solution: The interpolating polynomial in the Lagrange form is P3(x) = L0(x) + 2L1(x) + 6L2(x) + 7L3(x) with L0(x) = (x − 1)(x − 3)(x − 5)

(0 − 1)(0 − 3)(0 − 5) = − 1

15(x − 1)(x − 3)(x − 5), L1(x) = (x − 0)(x − 3)(x − 5)

(1 − 0)(1 − 3)(1 − 5) = 1

8x(x − 3)(x − 5), L2(x) = (x − 0)(x − 1)(x − 5)

(3 − 0)(3 − 1)(3 − 5) = − 1

12x(x − 1)(x − 5), L3(x) = (x − 0)(x − 1)(x − 3)

(5 − 0)(5 − 1)(5 − 3) = 1

40x(x − 1)(x − 3).

(12)

師大

Question

What’s the error involved in approximating f (x) by the interpolating polynomial P (x)?

Theorem Suppose

1 x0, . . . , xn are distinct numbers in [a, b],

2 f ∈ Cn+1[a, b].

Then, ∀x ∈ [a, b], ∃ ξ(x) ∈ (a, b) such that f (x) = P (x) +fn+1(ξ(x))

(n + 1)! (x − x0)(x − x1) · · · (x − xn). (2) Proof: If x = xk, for any k = 0, 1, . . . , n, then f (xk) = P (xk) and (2) is satisfied.

(13)

師大

If x 6= xk, for all k = 0, 1, . . . , n, define

g(t) = f (t) − P (t) − [f (x) − P (x)]

n

Y

i=0

t − xi

x − xi.

Since f ∈ Cn+1[a, b] and P ∈ C[a, b], it follows that g ∈ Cn+1[a, b].

Since

g(xk) = [f (xk) − P (xk)] − [f (x) − P (x)]

n

Y

i=0

xk− xi x − xi = 0, and

g(x) = [f (x) − P (x)] − [f (x) − P (x)]

n

Y

i=0

x − xi

x − xi = 0,

it implies that g is zero at x, x0, x1, . . . , xn. By the Generalized Rolle’s Theorem, ∃ ξ ∈ (a, b) such that gn+1(ξ) = 0. That is

(14)

師大

0 = g(n+1)(ξ) (3)

= f(n+1)(ξ) − P(n+1)(ξ) − [f (x) − P (x)] dn+1 dtn+1

" n Y

i=0

(t − xi) (x − xi)

#

t=ξ

.

Since deg(P ) ≤ n, it implies that P(n+1)(ξ) = 0. On the other hand, Qn

i=0[(t − xi)/(x − xi)] is a polynomial of degree (n + 1), so

n

Y

i=0

(t − xi) (x − xi) =

 1

Qn

i=0(x − xi)



tn+1+ (lower-degree terms in t),

and

dn+1 dtn+1

" n Y

i=0

(t − xi) (x − xi)

#

= (n + 1)!

Qn

i=0(x − xi).

(15)

師大

Equation (3) becomes

0 = f(n+1)(ξ) − [f (x) − P (x)] (n + 1)!

Qn

i=0(x − xi), i.e.,

f (x) = P (x) + f(n+1)(ξ) (n + 1)!

n

Y

i=0

(x − xi).

Example

1 Goal: Prepare a table for the function f (x) = ex for x ∈ [0, 1].

2 xj+1− xj = h for j = 0, 1, . . . , n − 1.

3 What should h be for linear interpolation to give an absolute error of at most 10−6?

(16)

師大

Suppose x ∈ [xj, xj+1]. Equation (2) implies that

|f (x) − P (x)| =

f(2)(ξ)

2! (x − xj)(x − xj+1)

= |f(2)(ξ)|

2! |x − xj||x − xj+1|

= eξ

2|x − jh||x − (j + 1)h|

≤ 1

2

 max

ξ∈[0,1]eξ

 

xj≤x≤xmaxj+1|x − jh||x − (j + 1)h|



= e

2



xj≤x≤xmaxj+1|x − jh||x − (j + 1)h|

 .

(17)

師大

Let

g(x) = (x − jh)(x − (j + 1)h), for jh ≤ x ≤ (j + 1)h.

Then

xj≤x≤xmaxj+1|g(x)| = g



j + 1 2

 h



= h2 4 . Consequently,

|f (x) − P (x)| ≤ eh2

8 ≤ 10−6, which implies that

h < 1.72 × 10−3.

Since n = (1 − 0)/h must be an integer, one logical choice for the step size is h = 0.001.

(18)

師大

Difficulty for the Lagrange interpolation

1 If more data points are added to the interpolation problem, all the cardinal functions Lk have to be recalculated.

2 We shall now derive the interpolating polynomials in a manner that uses the previous calculations to greater advantage.

Definition

1 f is a function defined at x0, x1, . . . , xn

2 Suppose that m1, m2, . . . , mk are k distinct integers with 0 ≤ mi ≤ n for each i.

The Lagrange polynomial that interpolates f at the k points xm1, xm2, . . . , xmk is denoted Pm1,m2,...,mk(x).

(19)

師大

Theorem

Let f be defined at distinct points x0, x1, . . . , xk, and 0 ≤ i, j ≤ k, i 6= j.

Then

P (x) = (x − xj)

(xi− xj)P0,1,...,j−1,j+1,...,k(x) − (x − xi)

(xi− xj)P0,1,...,i−1,i+1,...,k(x) describes the k-th Lagrange polynomial that interpolates f at the k + 1 points x0, x1, . . . , xk.

Proof: Since

deg(P0,1,...,j−1,j+1,...,k) ≤ k − 1 and

deg(P0,1,...,i−1,i+1,...,k) ≤ k − 1,

it implies that deg(P ) ≤ k. If 0 ≤ r ≤ k and r 6= i, j, then

(20)

師大

P (xr) = (xr− xj)

(xi− xj)P0,1,...,j−1,j+1,...,k(xr) −(xr− xi)

(xi− xj)P0,1,...,i−1,i+1,...,k(xr)

= (xr− xj)

(xi− xj)f (xr) − (xr− xi)

(xi− xj)f (xr) = f (xr).

Moreover

P (xi) = (xi− xj)

(xi− xj)P0,1,...,j−1,j+1,...,k(xi) − (xi− xi)

(xi− xj)P0,1,...,i−1,i+1,...,k(xi)

= f (xi) and

P (xj) = (xj− xj)

(xi− xj)P0,1,...,j−1,j+1,...,k(xj) −(xj− xi)

(xi− xj)P0,1,...,i−1,i+1,...,k(xj)

= f (xj).

Therefore P (x) agrees with f at all points x0, x1, . . . , xk. By the uniqueness theorem, P (x) is the k-th Lagrange polynomial that interpolates f at the k + 1 points x0, x1, . . . , xk, i.e., P ≡ P0,1,...,k.

(21)

師大

Neville’s method

The theorem implies that the Lagrange interpolating polynomial can be generated recursively. The procedure is called the Neville’s method.

1 Denote

Qi,j = Pi−j,i−j+1,...,i−1,i.

2 Hence Qi,j, 0 ≤ j ≤ i, denotes the interpolating polynomial of degree j on the j + 1 points xi−j, xi−j+1, . . . , xi−1, xi.

3 The polynomials can be computed in a manner as shown in the following table.

x0 P0= Q0,0

x1 P1= Q1,0 P0,1 = Q1,1

x2 P2= Q2,0 P1,2 = Q2,1 P0,1,2= Q2,2

x3 P3= Q3,0 P2,3 = Q3,1 P1,2,3= Q3,2 P0,1,2,3 = Q3,3

x4 P4= Q4,0 P3,4 = Q4,1 P2,3,4= Q4,2 P1,2,3,4 = Q4,3 P0,1,2,3,4= Q4,4

(22)

師大

x0 P0= Q0,0

x1 P1= Q1,0 P0,1 = Q1,1

x2 P2= Q2,0 P1,2 = Q2,1 P0,1,2= Q2,2

x3 P3= Q3,0 P2,3 = Q3,1 P1,2,3= Q3,2 P0,1,2,3 = Q3,3

x4 P4= Q4,0 P3,4 = Q4,1 P2,3,4= Q4,2 P1,2,3,4 = Q4,3 P0,1,2,3,4= Q4,4

P0,1(x) = (x − x1)P0(x) − (x − x0)P1(x)

x0− x1 ,

P1,2(x) = (x − x2)P1(x) − (x − x1)P2(x)

x1− x2 ,

...

P0,1,2(x) = (x − x2)P0,1(x) − (x − x0)P1,2(x) x0− x2

...

(23)

師大

Example

Compute approximate value of f (1.5) by using the following datas:

x f (x)

1.0 0.7651977 1.3 0.6200860 1.6 0.4554022 1.9 0.2818186 2.2 0.1103623

(24)

師大 1 The first-degree approximation:

Q1,1(1.5) = (x − x0)Q1,0− (x − x1)Q0,0

x1− x0

= (1.5 − 1.0)Q1,0− (1.5 − 1.3)Q0,0

1.3 − 1.0 = 0.5233449,

Q2,1(1.5) = (x − x1)Q2,0− (x − x2)Q1,0

x2− x1

= (1.5 − 1.3)Q2,0− (1.5 − 1.6)Q1,0

1.6 − 1.3 = 0.5102968,

Q3,1(1.5) = (x − x2)Q3,0− (x − x3)Q2,0

x3− x2

= (1.5 − 1.6)Q3,0− (1.5 − 1.9)Q2,0

1.9 − 1.6 = 0.5132634,

Q4,1(1.5) = (x − x3)Q4,0− (x − x4)Q3,0 x4− x3

= (1.5 − 1.9)Q4,0− (1.5 − 2.2)Q3,0

2.2 − 1.9 = 0.5104270.

(25)

師大 1 The second-degree approximation:

Q2,2(1.5) = (x − x1)Q2,1− (x − x2)Q1,1 x2− x1

= (1.5 − 1.3)Q2,1− (1.5 − 1.6)Q1,1

1.6 − 1.3 = 0.5124715,

Q3,2(1.5) = (x − x2)Q3,1− (x − x3)Q2,1 x3− x2

= (1.5 − 1.6)Q3,1− (1.5 − 1.9)Q2,1

1.9 − 1.6 = 0.5112857,

Q4,2(1.5) = (x − x3)Q4,1− (x − x4)Q3,1

x4− x3

= (1.5 − 1.9)Q4,1− (1.5 − 2.2)Q3,1

2.2 − 1.9 = 0.5137361.

(26)

師大

x f (x) 1st-deg 2nd-deg 3rd-deg 4th-deg 1.0 0.7651977

1.3 0.6200860 0.5233449

1.6 0.4554022 0.5102968 0.5124715

1.9 0.2818186 0.5132634 0.5112857 0.5118127

2.2 0.1103623 0.5104270 0.5137361 0.5118302 0.5118200 Table: Results of the higher-degree approximations

x f (x) 1st-deg 2nd-deg 3rd-deg 4th-deg 5th-deg

1.0 0.7651977

1.3 0.6200860 0.5233449

1.6 0.4554022 0.5102968 0.5124715

1.9 0.2818186 0.5132634 0.5112857 0.5118127

2.2 0.1103623 0.5104270 0.5137361 0.5118302 0.5118200

2.5 −0.0483838 0.4807699 0.5301984 0.5119070 0.5118430 0.5118277 Table: Results of adding (x5, f (x5))

(27)

師大

Divided Differences

Neville’s method: generate successively higher-degree polynomial approximations at a specific point.

Divided-difference methods: successively generate the polynomials themselves.

Suppose that Pn(x) is the nth Lagrange polynomial that agrees with f at distinct x0, x1, . . . , xn. Express Pn(x) in the form

Pn(x) = a0+ a1(x − x0) + a2(x − x0)(x − x1) + · · · +an(x − x0)(x − x1) · · · (x − xn−1).

Determine constant a0:

a0 = Pn(x0) = f (x0) Determine a1:

f (x0) + a1(x1− x0) = Pn(x1) = f (x1) ⇒ a1 = f (x1) − f (x0) x1− x0 .

(28)

師大

The zero divided difference of the function f with respect to xi: f [xi] = f (xi)

The first divided difference of f with respect to xi and xi+1 is denoted and defined as

f [xi, xi+1] = f [xi+1] − f [xi] xi+1− xi . The second divided difference of f is defined as

f [xi, xi+1, xi+2] = f [xi+1, xi+2] − f [xi, xi+1] xi+2− xi .

The k-th divided difference relative to xi, xi+1, . . . , xi+k is given by f [xi, xi+1, . . . , xi+k] = f [xi+1, xi+2, . . . , xi+k] − f [xi, xi+1, . . . , xi+k−1]

xi+k− xi .

(29)

師大

As might be expected from the evaluation of a0, a1, . . . , an in Pn(x), the required coefficients are given by

ak= f [x0, x1, . . . , xk], k = 0, 1, . . . , n.

Therefore Pn(x) can be expressed as Pn(x) = f [x0] +

n

X

k=1

f [x0, x1, . . . , xk](x − x0)(x − x1) · · · (x − xk−1).

This formula is known as the Newton’s divided-difference formula.

xi k = 0 k = 1 k = 2 k = 3

x0 f [x0]

> f [x0, x1]

x1 f [x1] > f [x0, x1, x2]

> f [x1, x2] > f [x0, x1, x2, x3] x2 f [x2] > f [x1, x2, x3]

> f [x2, x3] x3 f [x3]

Table: Outline for the generation of the divided differences

(30)

師大

Example

Given the following 4 points (n = 3)

xi 0 1 3 5

yi 1 2 6 7

find a polynomial of degree 3 in Newton’s form to interpolate these data.

Solution:

xi k = 0 k = 1 k = 2 k = 3

0 1

> 1

1 2 > 13

> 2 > −12017

3 6 > −38

> 12

5 7

So,

P (x) = 1 + x +1

3x(x − 1) − 17

120x(x − 1)(x − 3).

(31)

師大

Theorem

Suppose f ∈ Cn[a, b] and x0, x1, . . . , xn are distinct numbers in [a, b].

Then there exists ξ ∈ (a, b) such that

f [x0, x1, . . . , xn] = f(n)(ξ) n! . Proof: Define

g(x) = f (x) − Pn(x).

Since Pn(xi) = f (xi) for i = 0, 1, . . . , n, g has n + 1 distinct zeros in [a, b]. By the generalized Rolle’s Theorem, ∃ ξ ∈ (a, b) such that

0 = g(n)(ξ) = f(n)(ξ) − Pn(n)(ξ).

Note that

Pn(n)(x) = n!f [x0, x1, . . . , xn].

As a consequence

f [x0, x1, . . . , xn] = f(n)(ξ) n! .

(32)

師大

Let

h = xn− x0

n = xi+1− xi, i = 0, 1, . . . , n − 1.

Then each xi= x0+ ih, i = 0, 1, . . . , n. For any x ∈ [a, b], write x = x0+ sh, s ∈ R.

Hence x − xi = (s − i)h and Pn(x) = f [x0] +

n

X

k=1

f [x0, x1, . . . , xk](x − x0)(x − x1) · · · (x − xk−1)

= f (x0) +

n

X

k=1

f [x0, x1, . . . , xk](s − 0)h(s − 1)h · · · (s − k + 1)h

= f (x0) +

n

X

k=1

f [x0, x1, . . . , xk]s(s − 1) · · · (s − k + 1)hk

= f (x0) +

n

X

k=1

f [x0, x1, . . . , xk]k!s k



hk, (4)

(33)

師大

The binomial formula

s k



= s(s − 1) · · · (s − k + 1) k!

The forward difference notation 4

4f (xi) = f (xi+1) − f (xi) and

4kf (xi) = 4k−1f (xi+1) − 4k−1f (xi) = 4



4k−1f (xi)

 , for i = 0, 1, . . . , n − 1.

With this notation,

f [x0, x1] = f (x1) − f (x0) x1− x0 = 1

h4f (x0) f [x0, x1, x2] = f [x1, x2] − f [x0, x1]

x2− x0

=

1

h4f (x1) −h14f (x0)

2h = 1

2h242f (x0),

(34)

師大

In general

f [x0, x1, . . . , xk] = 1

k! hk4kf (x0).

The Newton forward-difference formula:

Pn(x) = f (x0) +

n

X

k=1

s k



4kf (x0).

The interpolation nodes are arranged as xn, xn−1, . . . , x0: Pn(x) = f [xn] + f [xn, xn−1](x − xn)

+f [xn, xn−1, xn−2](x − xn)(x − xn−1) + · · · +f [xn, . . . , x0](x − xn)(x − xn−1) · · · (x − x1).

(35)

師大

If the nodes are equally spaced with h = xn− x0

n , xi = xn− (n − i)h, x = xn+ sh, then

Pn(x) = f [xn] +

n

X

k=1

f [xn, xn−1, . . . , xn−k]sh(s + 1)h · · · (s + k − 1)h

= f (xn) +

n

X

k=1

f [xn, xn−1, . . . , xn−k](−1)kk!−s k

 hk

Binomial formula:

−s k



= −s(−s − 1) · · · (−s − k + 1)

k! = (−1)ks(s + 1) · · · (s + k − 1)

k! .

(36)

師大

Backward-difference:

kf (xi) = ∇k−1f (xi) − ∇k−1f (xi−1) = ∇

k−1f (xi) , then

f [xn, xn−1] = 1

h∇f (xn), f [xn, xn−1, xn−2] = 1

2h22f (xn), and, in general,

f [xn, xn−1, . . . , xn−k] = 1

k! hkkf (xn).

Newton backward-difference formula:

Pn(x) = f (x0) +

n

X

k=1

(−1)k−s k



kf (xk).

(37)

師大

Hermite Interpolation

Given n + 1 data points x0 < x1< · · · < xn, and

y0(0)= f (x0) y1(0) = f (x1) · · · yn(0)= f (xn) y(1)0 = f0(x0) y1(1)= f0(x1) · · · y(1)n = f0(xn)

... ... ...

y0(m0) = f(m0)(x0) y(m1 1)= f(m1)(x1) · · · yn(mn)= f(mn)(xn)

↓ ↓ ↓

m0+ 1 conditions m1+ 1 conditions · · · mn+ 1 conditions for some function f ∈ Cm[a, b] where m = max{m0, m1, . . . , mn}.

(38)

師大

Determine a polynomial P of degree at most N , where N =

n

X

i=0

mi

!

+ n, (5)

to satisfy the following interpolation conditions:

P(k)(xi) = y(k)i , k = 0, 1, . . . mi, i = 0, 1, . . . , n. (6) If n = 0, then P is the m0th Taylor polynomial for f at x0.

If mi = 0 for each i, then P is the nth Lagrange polynomial interpolating f on x0, . . . , xn.

If mi = 1 for each i, then P is called the Hermite polynomials.

(39)

師大

Theorem

If f ∈ C1[a, b] and x0, . . . , xn∈ [a, b] are distinct, then the polynomial of least degree agreeing with f and f0 at x0, . . . , xn is unique and is given by

H2n+1(x) =

n

X

j=0

f (xj)Hn,j(x) +

n

X

j=0

f0(xj) bHn,j(x),

where

Hn,j(x) =1 − 2(x − xj)L0n,j(xj) L2n,j(x), Hbn,j(x) = (x − xj)L2n,j(x), and

Ln,j(x) = (x − x0) · · · (x − xj−1)(x − xj+1) · · · (x − xn) (xj− x0) · · · (xj− xj−1)(xj − xj+1) · · · (xj− xn). Moreover, if f ∈ C2n+2[a, b], then ∃ ξ(x) ∈ [a, b] s.t.

f (x) = H2n+1(x) + (x − x0)2· · · (x − xn)2

(2n + 2)! f(2n+2)(ξ(x)).

(40)

師大

Proof:

Since

Ln,j(xi) =

 0, if i 6= j, 1, if i = j, it implies that

Hn,j(xi) =

 0, if i 6= j,

1, if i = j, Hbn,j(xi) = 0 ∀ i, j.

As a consequence, H2n+1(xi) =

n

X

j=0,j6=1

f (xj) · 0 + f (xi) · 1 +

n

X

j=0

f0(xj) · 0 = f (xi), ∀ i.

By definitions of Hn,j(x) and bHn,j(x),

Hn,j0 (x) = −2L0n,j(xj)L2n,j(x) + 21 − 2(x − xj)L0n,j(xj) Ln,j(x)L0n,j(x), Hbn,j0 (x) = L2n,j(x) + 2(x − xj)Ln,j(x)L0n,j(x).

(41)

師大

It implies that if i 6= j,

Hn,j0 (xi) = −2L0n,j(xj)L2n,j(xi) + 21 − 2(xi− xj)L0n,j(xj) Ln,j(xi)L0n,j(xi)

= −2L0n,j(xj) · 0 + 21 − 2(xi− xj)L0n,j(xj) · 0 · L0n,j(xi) = 0, Hbn,j0 (xi) = L2n,j(xi) + 2(xi− xj)Ln,j(xi)L0n,j(xi)

= 0 + 2(xi− xj) · 0 · L0n,j(xi) = 0 and

Hn,i0 (xi) = −2L0n,i(xi)L2n,i(xi) + 21 − 2(xi− xi)L0n,i(xi) Ln,i(xi)L0n,i(xi)

= −2L0n,i(xi) + 2L0n,i(xi) = 0,

Hbn,i0 (xi) = L2n,i(xi) + 2(xi− xi)Ln,i(xi)L0n,i(xi) = 1.

Therefore, ∀ i, H2n+10 (xi) =

n

X

j=0

f (xj)Hn,j0 (xi) +

n

X

j=0,j6=i

f0(xj) bHn,j0 (xi) + f0(xi) bHn,i0 (xi) = f0(xi).

That is H2n+1 agrees with f and H2n+10 with f0 at x0, . . . , xn.

(42)

師大

Proof of uniqueness:

Since deg(P ) ≤ 2n + 1, write

P (x) = a0+ a1x + · · · + a2n+1x2n+1.

2n + 2 coefficients, a0, a1, . . . , a2n+1, to be determined and 2n + 2 conditions given

P (xi) = f (xi), P0(xi) = f0(xi), for i = 0, . . . , n.

⇒ 2n + 2 linear equations in 2n + 2 unknowns to solve

⇒ show that the coefficient matrix A of this system is nonsingular.

To prove A is nonsingular, it suffices to prove that Au = 0 has only the trivial solution u = 0.

Au = 0 iff

P (xi) = 0, P0(xi) = 0, for i = 0, . . . , n.

⇒ P is a multiple of the polynomial given by q(x) =

n

Y

i=0

(x − xi)2.

(43)

師大

However, deg(q) = 2n + 2 whereas P has degree at most N . Therefore, P (x) = 0, i.e. u = 0.

That is, A is nonsingular, and the Hermite interpolation problem has a unique solution.

(44)

師大

Divided Difference Method for Hermite Interpolation

Denote the N + 1 conditions pairs

(x0, f (x0)), (x0, f0(x0)), (x1, f (x1)), (x1, f0(x1)), . . . , (xn, f (xn)), (xn, f0(xn)) by consecutive coordinate pairs

(z0, f (x0)), (z1, f0(x0)), (z2, f (x1)), (z3, f0(x1)), . . . , (zN −1, f (xn)), (zN, f0(xn)).

Note that z0 ≤ z1 ≤ · · · ≤ zN. The unique Hermite interpolating polynomial in Newton’s form can then be written as

H2n+1(x) = f [z0] +

N

X

k=1

f [z0, z1, . . . , zk](x − z0)(x − z1) · · · (x − zk−1).

If zi 6= zi+k, then

f [zi, zi+1, . . . , zi+k] = f [zi+1, zi+2, . . . , zi+k] − f [zi, zi+1, . . . , zi+k−1]

zi+k− zi .

(45)

師大

However the divided-difference formula has to be modified because there may be repetitions among zi. Since z2i= z2i+1= xi for each i, let

ξ2i< ξ2i+1

be distinct coordinates and ξj → zj, for 2i ≤ j ≤ 2i + 1. Then, by applying Theorem 3.6,

f [z2i, z2i+1] = lim

ξj→zj

2i≤j≤2i+1

f [ξ2i, ξ2i+1] = f0(z2i) = f0(xi)

(46)

師大

z f (z)

z0= x0 f [z0] = f (x0)

f [z0, z1] = f0(x0)

z1= x0 f [z1] = f (x0) f [z0, z1, z2] =f [z1,zz2]−f [z0,z1]

2−z0

f [z1, z2] = f [zz2]−f [z1]

2−z1

z2= x1 f [z2] = f (x1) f [z1, z2, z3] =f [z2,zz3]−f [z1,z2]

3−z1

f [z2, z3] = f0(x1)

z3= x1 f [z3] = f (x1) f [z2, z3, z4] =f [z3,zz4]−f [z2,z3]

4−z2

f [z3, z4] = f [zz4]−f [z3]

4−z3

z4= x2 f [z4] = f (x2) f [z3, z4, z5] =f [z4,zz5]−f [z3,z4]

5−z3

f [z4, z5] = f0(x2) z5= x2 f [z5] = f (x2)

(47)

師大

Cubic spline interpolation

The previous sections concern the approximation of an arbitrary function on a closed interval by a polynomial. However, the oscillatory nature of high-degree polynomials restricts their use.

Piecewise polynomial interpolation: divide the interval into a collection of subintervals and construct different approximation on each subinterval.

The simplest piecewise polynomial approximation is piecewise linear interpolation.

A disadvantage of linear function approximation is that the

interpolating function is not smooth at each of the endpoints of the subintervals. It is often required that the approximating function is continuously differentiable.

An alternative procedure is to use a piecewise polynomial of Hermite type. However, to use Hermite piecewise polynomials for general interpolation, we need to know the derivatives of the function being approximated, which is frequently not available.

(48)

師大

The most common piecewise-polynomial use cubic polynomials between each successive pair of nodes and is called cubic spline interpolation.

Definition

Given a function f defined on [a, b], and a set of nodes

a = x0 < x1 < · · · < xn= b, a cubic spline interpolation S for f is a function that satisfies the following conditions:

(a) S is a cubic polynomial, denoted Sj(x), on [xj, xj+1] for each j = 0, 1, . . . , n − 1;

(b) Sj(xj) = f (xj) and Sj(xj+1) = f (xj+1) ∀ j = 0, 1, . . . , n − 1;

(c) Sj+1(xj+1) = Sj(xj+1)∀ j = 0, 1, . . . , n − 2;

(d) Sj+10 (xj+1) = Sj0(xj+1)∀ j = 0, 1, . . . , n − 2;

(e) Sj+100 (xj+1) = Sj00(xj+1)∀ j = 0, 1, . . . , n − 2;

(f) One of the following sets of boundary conditions is satisfied:

(i) S00(x0) = S00(xn) = 0 (free or natural boundary);

(ii) S0(x0) = f0(x0) and S0(xn) = f0(xn) (clamped boundary).

(49)

師大

Construction of cubic spline interpolation

Remark

In general, clamped boundary conditions lead to more accurate

approximations since they include more information about the function.

Write

Sj(x) = aj+ bj(x − xj) + cj(x − xj)2+ dj(x − xj)3, ∀ j = 0, 1, . . . , n − 1.

That is

aj = Sj(xj) = f (xj).

Since Sj+1(xj+1) = Sj(xj+1), it implies that

aj+1= aj+ bj(xj+1− xj) + cj(xj+1− xj)2+ dj(xj+1− xj)3. Let

hj = xj+1− xj, ∀ j = 0, 1, . . . , n − 1.

Then

aj+1= aj+ bjhj + cjh2j + djh3j. (7)

(50)

師大

Define bn= S0(xn) and observe that

Sj0(x) = bj+ 2cj(x − xj) + 3dj(x − xj)2 implies that

bj = Sj0(xj), ∀ j = 0, 1, . . . , n − 1.

Applying Sj+10 (xj+1) = Sj0(xj+1) gives

bj+1= bj+ 2cjhj+ 3djh2j, ∀ j = 0, 1, . . . , n − 1. (8) Defining cn= S00(xn)/2 and applying Sj+100 (xj+1) = Sj00(xj+1), we get

cj+1 = cj+ 3djhj, ∀ j = 0, 1, . . . , n − 1.

Hence

dj = cj+1− cj 3hj

. (9)

(51)

師大

Substituting dj in (9) into (7) and (8), it obtains aj+1= aj+ bjhj +h2j

3 (2cj+ cj+1) (10)

and

bj+1 = bj+ hj(cj+ cj+1). (11) Eq. (10) implies that

bj = 1

hj(aj+1− aj) − hj

3 (2cj+ cj+1), (12) and then

bj−1 = 1

hj−1(aj− aj−1) −hj−1

3 (2cj−1+ cj). (13)

(52)

師大

Substituting (12) and (13) into (11), we get hj−1cj−1+ 2(hj−1+ hj)cj+ hjcj+1 = 3

hj(aj+1− aj) − 3

hj−1(aj− aj−1).(14) for each j = 1, 2, . . . , n − 1.

Theorem

If f is defined at a = x0 < x1 < · · · < xn= b, then f has a unique natural spline interpolant S on the nodes x0, x1, . . . , xn that satisfies

S00(a) = S00(b) = 0.

Proof: The boundary conditions imply that cn = S00(xn)/2 = 0,

0 = S00(x0) = 2c0+ 6d0(x0− x0) ⇒ c0= 0.

(53)

師大

Substituting c0= cn= 0 into (14), it produces a linear system Ax = b, where A is an (n + 1) × (n + 1) matrix

A =

1 0

h0 2(h0+ h1) h1

h1 2(h1+ h2) h2

. .. . .. . ..

hn−2 2(hn−2+ hn−1) hn−1

0 1

 ,

b =

0

3

h1(a2− a1) −h3

0(a1− a0) ...

3

hn−1(an− an−1) −h3

n−2(an−1− an−2) 0

, x =

 c0 c1 ... cn

 .

The matrix A is strictly diagonally dominant, so A is nonsingular and the linear system has a unique solution for c0, c1, . . . , cn.

(54)

師大

Solving tridiagonal linear system

Let

A = LU ≡

`11

`21 `22

. .. . ..

`n,n−1 `nn

1 u12 1 u23

. .. ...

. .. un−1,n 1

 .

Comparing the coefficients of matrix in both sides, we have a11 = `11,

ai,i−1 = `i,i−1, for i = 2, 3, . . . , n,

aii = `i,i−1ui−1,i+ `ii, for i = 2, 3, . . . , n, ai,i+1 = `iiui,i+1, for i = 1, 2, . . . , n − 1.

(55)

師大

It implies that

`11= a11, u12= a12/`11, and, for i = 2, . . . , n − 1,

`i,i−1 = ai,i−1,

`ii = aii− `i,i−1ui−1,i, ui,i+1 = ai,i+1/`ii, and

`n,n−1 = an,n−1,

`nn = ann− `n,n−1un−1,n.

(56)

師大

Forward substitution

Solve Ly = b









`11y1 = b1,

`21y1+ `22y2 = b2, ...

`n,n−1yn−1+ `nnyn = bn.









y1 = b1/`11,

y2 = (b2− `21y1)/`22, ...

yn = (bn− `n,n−1yn−1)/`nn.

 y1 = b1/`11,

yi = (bi− `i,i−1yi−1)/`ii, for i = 2, . . . , n.

(57)

師大

Back substitution

Solve U x = y,









x1+ u12x2 = y1, ...

xn−1+ un−1,nxn = yn−1, xn = yn,









xn = yn,

xn−1 = yn−1− un−1,nxn, ...

x1 = y1− u12x2,

 xn = yn,

xi = yi− ui,i+1xi+1, for i = n − 1, . . . , 1.

(58)

師大

Theorem

If f is defined at a = x0 < x1< · · · < xn= b and differentiable at a and b, then f has a unique clamped spline interpolant S on the nodes

x0, x1, . . . , xn that satisfies S0(a) = f0(a) and S0(b) = f0(b).

Proof: Since f0(a) = S0(a) = S0(x0) = b0, Eq. (12) with j = 0 implies f0(a) = 1

h0

(a1− a0) −h0

3 (2c0+ c1).

Consequently,

2h0c0+ h0c1= 3 h0

(a1− a0) − 3f0(a).

Similarly,

f0(b) = bn= bn−1+ hn−1(cn−1+ cn),

(59)

師大

so Eq. (12) with j = n − 1 implies that f0(b) = an− an−1

hn−1

−hn−1

3 (2cn−1+ cn) + hn−1(cn−1+ cn)

= an− an−1

hn−1 +hn−1

3 (cn−1+ 2cn), and

hn−1cn−1+ 2hn−1cn= 3f0(b) − 3 hn−1

(an− an−1).

Eq. (14) together with the equations 2h0c0+ h0c1 = 3

h0

(a1− a0) − 3f0(a) and

hn−1cn−1+ 2hn−1cn= 3f0(b) − 3

hn−1(an− an−1)

參考文獻

相關文件

• By definition, a pseudo-polynomial-time algorithm becomes polynomial-time if each integer parameter is limited to having a value polynomial in the input length.. • Corollary 42

• A language has uniformly polynomial circuits if there is a uniform family of polynomial circuits that decide

Given a shift κ, if we want to compute the eigenvalue λ of A which is closest to κ, then we need to compute the eigenvalue δ of (11) such that |δ| is the smallest value of all of

Basing on the observation and assessment results, this study analyzes and discusses the effects and problems of learning the polynomial derivatives on different level students

If P6=NP, then for any constant ρ ≥ 1, there is no polynomial-time approximation algorithm with approximation ratio ρ for the general traveling-salesman problem...

The set of concrete decision problems that are polynomial-

Given an undirected graph with nonnegative edge lengths and nonnegative vertex weights, the routing requirement of a pair of vertices is assumed to be the product of their weights.

 The class of languages decided by polynomial- time algorithms是the class of languages. accepted by