part ii lecture notes on - niudattab/math435.2009/interpolation.pdf2 interpolation 2.1 problem...

26
URL: www.math.niu.edu/~dattab DeKalb, IL. 60115 USA E-mail: [email protected] Department of Mathematical Sciences Northern Illinois University MATH 435 Lecture Notes on PART II Professor Biswa Nath Datta Interpolation

Upload: others

Post on 05-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

URL: www.math.niu.edu/~dattab

DeKalb, IL. 60115 USA

E−mail: [email protected]

Department of Mathematical SciencesNorthern Illinois University

MATH 435

Lecture Notes onPART II

Professor Biswa Nath Datta

Interpolation

Page 2: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

PART II.Interpolation

Page 3: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

2 Interpolation

2.1 Problem Statement and Applications

Consider the following table:

x0 f0

x1 f1

x2 f2

......

xk fk

......

xn fn

In the above table, fk, k = 0, · · · , n are assumed to be the values of a certain function f(x),evaluated at xk, k = 0, · · · , n in an interval containing these points. Note that only thefunctional values are known, not the function f(x) itself. The problem is to find fu

corresponding to a nontabulated intermediate value x = u.

Such a problem is called an Interpolation Problem. The numbers x0, x1, · · · , xn arecalled the nodes.

Interpolation Problem

Given (n+1) points: (x0, f0), (x1, f1), · · · (xn, fn),find fu

corresponding to xu, where x0 < xu < xn; assum-ing that

f0, f1, · · · , fn are the values of a certain functionf(x)

at x = x0, x1, · · · , xn, respectively.

The Interpolation problem is also a classical problem and dates back to the time of Newtonand Kepler, who needed to solve such a problem in analyzing data on the positions ofstars and planets. It is also of interest in numerous other practical applications. Here is anexample.

32

Page 4: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

2.2 Existence and Uniqueness

It is well-known that a continuous function f(x) on [a, b] can be approximated as close aspossible by means of a polynomial. Specifically, for each ε > 0, there exists a polynomialP (x) such that |f(x) − P (x)| < ε for all x in [a, b]. This is a classical result, known asWeierstrass Approximation Theorem.Knowing that fk, k = 0, · · · , n are the values of a certain function at xk, the most obviousthing then to do is to construct a polynomial Pn(x) of degree at most n that passes throughthe (n+ 1) points: (x0, f0), (x1, f1), · · · , (xn, fn).Indeed, if the nodes x0, x1, ..., xn are assumed to be distinct, then such a poly-nomial always does exist and is unique, as can be seen from the following.

Let Pn(x) = a0 + a1x + a2x2 + · · · + anx

n be a polynomial of degree at most n. If Pn(x)interpolates at x0, x1, · · · , xn, we must have, by definition

Pn(x0) = f0 = a0 + a1x0 + a2x20 + · · ·+ anx

n0

Pn(x1) = f1 = a0 + a1x1 + a2x21 + · · ·+ anx

n1

...

Pn(xn) = fn = a0 + a1xn + a2x2n + · · ·+ anx

nn

(2.1)

These equations can be written in matrix form:

1 x0 x20 · · ·xn

0

1 x1 x21 · · ·xn

1

...

1 xn x2n · · ·xn

n

a0

a1

a2

...

an

=

f0

f1

...

fn

(2.2)

Because x0, x1, · · · , xn are distinct, it can be shown [Exercise] that the matrix of the abovesystem is nonsingular. Thus, the linear system for the unknowns a0, a1, · · · , an has a uniquesolution, in view of the following well-known result, available in any linear algebra text book.

The n × n algebraic linear system Ax = b has a uniquesolution for every b if and only if A is nonsingular.

This means that Pn(x) exists and is unique.

33

Page 5: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Theorem 2.1 (Existence and Uniqueness Theorem for Polynomial Interpola-tion)

Given (n + 1) distinct points x0, x1, · · · , xn and the associated values f0, f1, · · · , fn ofa function f(x) at these points (that is, f(xi) = fi, i = 0, 1, · · · , n), there is a uniquepolynomial Pn(x) of degree at most n such that Pn(xi) = fi, i = 0, 1, · · · , n. The coefficientsof this polynomial can be obtained by solving the (n+ 1) × (n+ 1) linear system (2.2).

Definition: The polynomial Pn(x) in Theorem 2.1 is called the interpolating polynomial.

2.3 The Lagrange Interpolation

Once we know that the interpolating polynomial exists and is unique, the problem thenbecomes how to construct an interpolating polynomial; that is, how to construct a polynomialPn(x) of degree at most n, such that

Pn(xi) = fi, i = 0, 1, · · · , n.

It is natural to obtain the polynomial by solving the linear system (2.1) in the previoussection. Unfortunately, the matrix of this linear system, known as the VandermondeMatrix, is usually highly ill-conditioned, and the solution of such an ill-conditionedsystem, even by the use of a stable method, may not be accurate. There are,however, several other ways to construct such a polynomial, that do not require solution ofa Vandermonde system. We describe one such in the following:Suppose n = 1, that is, suppose that we have only two points (x0, f0), (x1, f1), then it iseasy to see that the linear polynomial

P1(x) =x− x1

(x0 − x1)f0 +

(x− x0)

(x1 − x0)f1

is an interpolating polynomial, because

P1(x0) = f0, P1(x1) = f1.

For convenience, we shall write the polynomial P1(x) in the form

P1(x) = L0(x)f0 + L1(x)f1,

where, L0(x) =x− x1

x0 − x1, and L1(x) =

x− x0

x1 − x0.

Note that both the polynomials L0(x) and L1(x) are polynomials of degree 1.

34

Page 6: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

The concept can be generalized easily for polynomials of higher degrees.To generate polynomials of higher degrees, let’s define the set of polynomials {Lk(x)} recur-sively, as follows:

Lk(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), k = 0, 1, 2, · · · , n.

(2.3)We will now show that the polynomial Pn(x) defined by

Pn(x) = L0(x)f0 + L1(x)f1 + · · ·+ Ln(x)fn (2.4)

is an interpolating polynomial.To see this, note that

L0(x) =(x− x1) · · · (x− xn)

(x0 − x1) · · · (x0 − xn)

L1(x) =(x− x0)(x− x2) · · · (x− xn)

(x1 − x0)(x1 − x2) · · · (x1 − xn)...

Ln(x) =(x− x0)(x− x1)(x− x2) · · · (x− xn−1)

(xn − x0)(xn − x1)(xn − x2) · · · (xn − xn−1)

Also, note that

L0(x0) = 1, L0(x1) = L0(x2) = · · · = L0(xn) = 0

L1(x1) = 1, L1(x0) = L1(x2) = · · · = Ln(xn) = 0

In general

Lk(xk) = 1 and Lk(xi) = 0, i 6= k.

ThusPn(x0) = L0(x0)f0 + L1(x0)f1 + · · · + Ln(x0)fn = f0

Pn(x1) = L0(x1)f0 + L1(x1)f1 + · · · + Ln(x1)fn = 0 + f1 + · · ·+ 0 = f1...Pn(xn) = L0(xn)f0 + L1(xn)f1 + · · ·+ Ln(xn)fn = 0 + 0 + · · ·+ 0 + fn = fn

That is, the polynomial Pn(x) has the property that Pn(xk) = fk, k = 0, 1, · · · , n.The polynomial Pn(x) defined by (2.3) is known as the Lagrange Interpolating Polyno-mial.

Example 2.1 Interpolate f(3) from the following table using Lagrangian interpolation:

0 71 132 214 43

35

Page 7: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

L0(x) =(x− 1)(x− 2)(x− 4)

(−1)(−2)(−4)

L1(x) =(x− 0)(x− 2)(x− 4)

1 · (−1)(−3)

L2(x) =(x− 0)(x− 1)(x− 4)

2 · 1 · (−2)

L3(x) =(x− 0)(x− 1)(x− 2)

4 · 3 · 2

From (2.4) with n = 3, we haveP3(x) = 7L0(x) + 13L1(x) + 21L2(x) + 43L3(x)

Now, L0(3) =1

4, L1(3) = −1, L2(3) =

3

2, L3(3) =

1

4.

So, P3(3) = 7L0(3) + 13L1(3) + 21L2(3) + 43L3(3) = 31.

Verify: Note that f(x) in this case is f(x) = x2 + 5x + 7, and the exact value of f(x) atx = 3 is 31.

Example 2.2 Given

i xi f(xi)

0 21

2

1 2.51

2.5

2 41

4

Interpolate f(x) at x = 3.

36

Page 8: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

L0(x) =(x− x1)(x− x2)

(x0 − x1)(x0 − x2)=

(x− 2.5)(x− 4)

(−0.5)(−2)= (x− 2.5)(x− 4)

L1(x) =(x− x0)(x− x2)

(x1 − x0)(x1 − x2)=

(x− 2)(x− 4)

(0.5)(−1.5)= − 1

0.75(x− 2)(x− 4)

L2(x) =(x− x1)(x− x0)

(x2 − x1)(x2 − x0)=

1

3(x− 2.5)(x− 2)

So, P2(x) = f(x0)L0(x) + f(x1)L1(x) + f(x2)L2(x) =1

2L0(x) +

1

2.5L1(x) +

1

4L2(x)

Thus, P2(3) =1

2L0(3) +

1

2.5L1(3) +

1

4L2(3) =

1

2(−0.5) +

1

2.5

(

1

0.75

)

+1

4

(

.5

3

)

= 0.3250

Verify: (The value of f(x) at x = 3 is 13≈ 0.3333).

2.4 Error in Interpolation

If f(x) is approximated by an interpolating polynomial Pn(x), we would like to obtain anexpression for the error of interpolation at a give intermediate point, say, x̄.That is, we would like to calculate E(x̄) = f(x̄) − Pn(x̄).Note that, since Pn(xi) = f(xi), E(xi) = 0, i = 0, 1, 2, · · · , n), that is, there are no errorsof interpolating at a tabulated point.Here is a result for the error expression E(x̄).

For proof of Theorem 2.2 we need the following result from Calculus:

Generalized Rolle’s Theorem

Suppose that f(x) is continuous on [a, b] and n times differentiable on (a, b). If f(x)has n distinct zeros in [a, b], then f (n+1)(c) = 0 where a < c < b.

Theorem 2.2 (Interpolation-Error Theorem) Let Pn(x) be the interpolating poly-nomial that interpolates at (n + 1) distinct numbers in [a, b], and let f(x) be (n + 1) timescontinuously differentiable on [a, b]. Then for every x̄ in [a, b], there exists a number ξ = ξ(x̄)in (a, b) (depending on x̄) such that

En(x̄) = f(x̄) − Pn(x̄) =f (n+1)(ξ(x̄))

(n + 1)!

n∏

i=0

(x̄− xi). (2.5)

37

Page 9: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Proof: If x̄ is one of the numbers x0, x1, · · · , xn: then the result follows trivially. Because,the error in this case is zero, and the result will hold for any arbitrary ξ.Next, assume that x̄ is not one of the numbers x0, x1, · · · , xn.Define a function g(t) in variable t in [a, b]:

g(t) = f(t) − Pn(t) − [f(x̄) − Pn(x̄)] ∗[

(t− x0)(t− x1) · · · (t− xn)

(x̄− x0)(x̄− x1) · · · (x̄− xn)

]

. (2.6)

Then, noting that f(xk) = Pn(x), for k = 0, 1, 2, · · · , n, we have

g(xk) = f(xk) − Pn(xk) − [f(x̄) − Pn(x̄)]

[

(xk − x0) · · · (xk − xn)

(x̄− x0) · · · (x̄− xn)

]

= Pn(xk) − Pn(xk) − [f(x̄) − Pn(x̄)] × 0

= 0

(2.7)

(Note that the numerator of the fraction appearing above contains the term (xk − xk) = 0).Furthermore,

g(x̄) = f(x̄) − Pn(x̄) − [f(x̄) − Pn(x̄)] ∗[

(x̄− x0) · · · (x̄− xn)

(x̄− x0) · · · (x̄− xn)

]

= f(x̄) − Pn(x̄) − f(x̄) + Pn(x̄)

= 0

(2.8)

Thus, g(t) becomes identically zero at (n + 2) distinct points: x0, x1, · · · , xn, and x̄. Fur-thermore, g(t) is (n + 1) times continuously differentiable, since f(x) is so.Therefore, by generalized Rolle’s theorem there exists a number ξ(x̄) in (a, b) such thatg(n+1)(ξ) = 0.

Let’s compute g(n+1)(t) now. From (2.5) we have

g(n+1)(t) = f (n+1)(t)−P (n+1)n (t)−[f(x̄)−Pn(x̄)]

dn+1

dtn+1

[

(t− x0)(t− x1) · · · (t− xn)

((x̄− x0)(x̄− x1) · · · (x̄− xn)

]

(2.9)

Then [Exercise]:

dn+1

dtn+1

[

(t− x0)(t− x1) · · · (t− xn)

(x̄− x0)(x̄− x1) · · · (x̄− xn)

]

=1

(x̄− x0)(x̄− x1) · · · (x̄− xn)· d

n+1

dtn+1[(t− x0)(t− x1) · · · (t− xn)]

=1

(x̄− x0)(x̄− x1) · · · (x̄− xn)(n+ 1)!

(note that the expression within [ ] in (2.9) is a polynomial of degree (n+ 1)).

Also, P(n+1)n (t) = 0, because Pn is a polynomial of degree at most n. Thus, P

(n+1)n (ξ) = 0.

38

Page 10: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

So,

g(n+1)(ξ) = f (n+1)(ξ) − (f(x̄) − Pn(x̄))

(x̄− x0) · · · (x̄− xn)(n+ 1)! (2.10)

Since g(n+1)(ξ) = 0, from (2.10), we have En(x̄) = f(x̄)−Pn(x̄) =f (n+1)(ξ)

(n+ 1)!(x̄−x0) · · · (x̄−

xn).

Remark: To obtain the error of interpolation using the above theorem, we need to knowthe (n + 1)th derivative of the f(x) or its absolute maximum value on the interval [a, b].Since in practice this value is hardly known, this error formula is of limited use only.

Example 2.3 Let’s compute the maximum absolute error for Example 2.2.Here n = 2.

E2(x̄) = f(x̄) − P2(x̄)

=f (3)(ξ)

3!(x̄− x0)(x̄− x1)(x̄− x2)

To know the maximum value of E2(x̄), we need to know f (3)(x).Let’s compute this now:

f(x) =1

x, f ′(x) = − 1

x2, f ′′(x)

2

x3, f (3)(x) = − 6

x4.

So, |f (3)(ξ)| < 6

24=

6

16for 2 < x ≤ 4.

Since x̄ = 3, x0 = 2, x1 = 2.5, x2 = 4, we have

|E2(x̄)| ≤ | 6

16× 1

6(3 − 2)(3 − 2.5)(3 − 4)| = 0.03125.

Note that in four-digit arithmetic, the difference between the value obtained by interpolationand the exact value is 0.3333 − 0.3250 = 0.0083.

2.5 Simplification of the Error Bound for Equidistant Nodes

The error formula in Theorem 2.2 can be simplified in case the tabulated points (nodes) areequally spaced; because, in this case it is possible to obtain a nice bound for the expression:(x̄− x0)(x̄− x1) · · · (x̄− xn).Suppose the nodes are equally spaced with spacing h; that is xi+1 − xi = h.

39

Page 11: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

PSfrag replacements

a = x0 x1 x2 b = xn

h hhh h

Then it can be shown [Exercise] that

|(x̄− x0)(x̄− x1) · · · (x̄− xn)| ≤ hn+1

4n!

If we also assume that |f (n+1)(x)| ≤M , then we have

|En(x̄)| = |f(x̄) − Pn(x̄)| ≤ M

(n+ 1)!

hn+1

4n! =

Mhn+1

4(n+ 1). (2.11)

Example 2.4 Suppose a table of values for f(x) = cos x has to be prepared in [0, 2π] withnodes of spacing h, using linear interpolation, with an error of interpolation of at most5 × 10−7. How small should h be?Here n = 1.f(x) = cos x, f ′(x) = − sin x, f 2(x) = f ′′(x) = − cos xmax |f (2)(x)| = 1, for 0 ≤ x ≤ 2πThus M = 1.

So, by (2.11) above we have

|E1(x̄)| = |f(x̄) − P1(x̄)| ≤h2

8.

Since the maximum error has to be 5 × 10−7, we must have:h2

8≤ 5 × 10−7 =

1

2× 10−6. That is, h ≤ 6.3246 × 10−4.

Example 2.5 Suppose a table is to be prepared for the function f(x) =√x on [1, 2]. Deter-

mine the spacing h in a table such that the interpolation with a polynomial of degree 2 willgive accuracy ε = 5 × 10−8.

We first compute the maximum absolute error.

Since f (3)(x) =3

8x−5

2 ,

M =∣

∣f (3)(x)∣

∣ ≤ 3

8for 1 ≤ x ≤ 2.

Thus, taking n = 2 in (2.11) the maximum (absolute) error is3

8× h3

12=

1

32h3.

Thus, to have an accuracy of ε = 5×10−8, we must have1

32h3 < 5×10−8 or h3 < 160×10−8.

This means that a spacing h of about h = 3√

160 × 10−8 = 0.0117 will be needed in the Tableto guarantee the accuracy of 5 × 10−8.

40

Page 12: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

2.6 Divided Differences and the Newton-Interpolation Formula

A major difficulty with the Lagrange Interpolation is that one is not sure about the degreeof interpolating polynomial needed to achieve a certain accuracy. Thus, if the accuracy isnot good enough with polynomial of a certain degree, one needs to increase the degree ofthe polynomial, and computations need to be started all over again.Furthermore, computing various Lagrangian polynomials is an expensive procedure. It is,indeed, desirable to have a formula which makes use of Pk−1(x) in computingPk(x).The following form of interpolation, known as Newton’s interpolation allows us to do so.The idea is to obtain the interpolating polynomial Pn(x) in the following form:

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

The constants a0 through an can be determined as follows:For x = x0, Pn(x0) = a0 = f0

For x = x1, Pn(x1) = a0 + a1(x1 − x0) = f1,which gives

a1 =f1 − a0

x1 − x0=f1 − f0

x1 − x0.

The other numbers ai, i = 2, ..., n can similarly be obtained.It is convenient to introduce the following notation, because we will show how the numbersa0, ..., an can be obtained using these notations.

f [xi] = f(xi) and f [xi, xi+1] =f [xi+1] − f [xi]

xi+1 − xi

Similarly,

f [xi, xi+1, · · · , xi+k−1, xi+k] =f [xi+1, ..., xi+k−1, xi+k] − f [xi, xi+1, ..., xi+k−1]

xi+k − xi

With these notations, we then have

a0 = f0 = f(x0) = f [x0]

a1 =f1 − f0

x1 − x0=f(x1) − f(x0)

x1 − x0=f [x1] − f [x0]

x1 − x0= f [x0, x1].

Continuing this, it can be shown that [Exercise]

ak = f [x0, x1, · · · , xk]. (2.13)

The number f [x0, x1, · · · , xk] is called the k-th divided difference.

Substituting these expressions of ak in (2.13), the interpolating polynomial Pn(x) now canbe written in terms of the divided differences:

Pn(x) = f [x0] + f [x0, x1](x− x0) + f [x0, x1, x2](x− x0)(x− x1) + · · ·+f [x0, x1, · · · , xn](x− x0)(x− x1) · · · (x− xn−1).

(2.14)

41

Page 13: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Notes:

(i) Each divided difference can be obtained from two previous ones of lower orders.

For example, f [x0, x1, x2] can be computed from f [x0, x1], and f [x1, x2], and so on.Indeed, they can be arranged in form of a table as shown below:

Table of Divided Differences (n = 4)

x f(x) 1stDivided 2nd

Divided 3rdDivided 4th

Divided

Difference Difference Difference Difference

x0 f0

f [x0, x1]

x1 f1 f [x0, x1, x2]

f [x1, x2]

f [x0, x1, x2, x3]

x2 f2 f [x1, x2, x3]

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

f [x1, x2, x3, x4]

x3 f3 f [x2, x3, x4]

f [x3, x4]

x4 f4

(ii) Note that in computing Pn(x) we need only the diagonal entries of the above table;that is, we need only f [x0], f [x0, x1], · · · , f [x0, x1, · · · , xn].

(iii) Since the divided differences are generated recursively, the interpolating polynomialsof successively higher degrees can also be generated recursively. Thus the work donepreviously can be used gainfully.For example,P1(x) = f [x0] + f [x0, x1](x− x0)P2(x) = f [x0] + f [x0, x1](x− x0) + f [x0, x1, x2](x− x0)(x− x1)

= P1(x) + f [x0, x1, x2](x− x0)(x− x1).

Similarly, P3(x) = P2(x) + f [x0, x1, x2, x3](x− x0)(x− x1)(x− x2)P4(x) = P3(x) + f [x0, x1, x2, x3, x4](x− x0)(x− x1)(x− x2)(x− x3)

and so on.

Thus, in computing P2(x), P1(x) has been gainfully used; in computing P3(x), P2(x) hasbeen gainfully used, etc.

42

Page 14: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Example 2.6 Interpolate at x = 2.5 using the following Table, with polynomials of degree 3and 4.

i xi fi 1st diff. 2nd diff. 3rd diff. 4th diff. 5th diff.

0 1.0 00.3522

1 1.5 0.17609 −0.10230.2499 0.0265534

2 2.0 0.30103 −0.0491933 −0.0064090.1761 0.01053 −0.001413

3 3.0 0.47712 −0.0281333 −0.0021690.1339 0.005107

4 3.5 0.54407 −0.017920.11598

5 4.0 0.60206

From (2.14), with n = 3, we have

P3(2.5) = 0 + (2.5 − 1.0)(0.35222) + (2.5 − 1.0)(2.5 − 1.5)(−0.1023)

+(2.5 − 1.0)(2.5 − 1.5)(2.5 − 2.0)(.0265534)

= .52827 − .15345 + .019915

= 0.394795

Similarly, with n = 4, we have

P4(2.5) = P3(2.5) + (2.5 − 1.0)(2.5 − 1.5)(2.5 − 2.0)(2.5 − 3.0)(−.006409)

= 0.394795 + .002403 = 0.397198 .

Note that P4(2.5) − P3(2.5) = 0.002403 .

Verification. The above is a table for log(x).The exact value of log(2.5) (correct up to 5 decimal places) is 0.39794.

(Note that in computing P4(2.5), P3(2.5) computed previously has been gainfullyused).If we use the notation Dij = f [xi, . . . , xi+j]. Then

43

Page 15: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Algorithm 2.1 Algorithm for Generating Divided Differences

Inputs:The definite numbers x0, x1, · · · , xn and the values f0, f1, · · · , fn.

Outputs:The Divided Difference D00, D11, · · ·Dnn.

Step 1: (Initialization). SetDi,0 = fi, i = 0, 1, 2, · · · , n.

Step 2: For i = 1, 2, · · · , n doj = 1, 2, · · · i do

Dij =Di,j−1 −Di−1,j−1

xi − xi−j

EndA Relationship Between nth Divided Difference and the nth DerivativeThe following theorem shows how the nth derivative of a function f(x) is related to the nthdivided difference. The proof is omitted. It can be found in any advanced numerical analysistext book (e.g., Atkins on (1978), p. 144).

Theorem 2.3 Suppose f is n times continuously differentiable and x0, x1, · · · , xn are (n+1)distinct numbers in [a, b]. Then there exists a number ξ in (a, b) such that

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

n!

The Newton Interpolation with Equally Spaced NodesSuppose again that x0, · · · , xn are equally spaced with spacing h;that is xi+1 − xi = h, i = 0, 1, 2, ..., n− 1. Let x− x0 = sh.Then x− x0 = sh

x− x1 = x− x0 + x0 − x1 = (x− x0) − (x1 − x0) = sh− h = (s− 1)hIn general, x− xi = (s− i)h.So,

Pn(x) = Pn(x0 + sh) = f [x0] + f [x0, x1](x− x0) + · · ·+ f [x0, x1, · · · , xn](x− x0) · · · (x− xn−1)

= f [x0] + sh f [x0, x1] + s(s− 1)h2f [x0, x1, x2] + · · · + s(s− 1) · · · (s− h + 1)hnf [x0, · · · , xh]

=n

k=0

s(s− 1) · · · (s− k + 1)hkf [x0, · · · , xk].

(2.15)Invoke now the notation:

(

s

k

)

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

k!

44

Page 16: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

We can then write

Pn(x) = Pn(x0 + sh) =

n∑

k=0

(

s

k

)

hkk!f [x0, · · · , xn] (2.16)

The Newton Forward-Difference Formula

Let’s introduce the notations:∆fi = f(xi+1) − f(xi).Then, ∆f0 = f(x1) − f(x0)So,

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

x1 − x0=

∆f0

h. (2.17)

Also, note that

∆2f0 = ∆(∆f0) = ∆(f(x1) − f(x0))

= ∆f(x1) − ∆f(x0)

= f(x2) − f(x1) − f(x1) + f(x0)

= f(x2) − 2f(x1) + f(x0)

(2.18)

So,

f [x0, x1, x2] =f [x1, x2] − f [x0, x1]

(x2 − x0)

=

f(x2)−f(x1)x2−x1

− f(x1)−f(x0)x1−x0

(x2 − x0)

=f(x2) − 2f(x1) + f(x0)

h× 2h=

∆2f0

2h2

(2.19)

In general, we have

Theorem 2.4f [x0, x1, . . . , xk]

=1

k!hk∆kf0.

(2.20)

Proof is by induction on k.

For k = 0, the result is trivially true. We have also proved the result for k = 1, and k = 2.Assume now that the result is true k = m. Then we need to show that the result is also truefor k = m+ 1.

45

Page 17: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Now, f [x0, · · · , xm+1] =f [x1, . . . , xm+1] − f [x0, . . . , xm]

xm+1 − x0=

(

∆mf1

m!hm− ∆mf0

m!hm

)

(m+ 1)h=

∆m(f1 − f0)

m!(m + 1)hm+1=

∆m+1f0

(m+ 1)!hm+1

The numbers ∆kfi are called kth order forward differences of f at x = i.We now show how the interpolating polynomial Pn(x) given by (2.16) can be written usingforward differences.

Pn(x) = Pn(x0 + sh) = f [x0] + shf [x0, x1] + s(s− 1)h2f [x0, x1, x2]

+ · · ·+ s(s− 1) · · · (s− n+ 1)hnf [x0, x1. · · · , xn]

=n

k=0

s(s− 1) · · · (s− k + 1)hkf [x0, x1, · · · , xk]

=

n∑

k=0

(

s

k

)

k!hkf [x0, x1, · · · , xn] =

n∑

k=0

(

s

k

)

∆kf0 using (2.20).

Newton’s Forward-Difference Interpolation Formula

Let x0, x1, ..., xn be (n + 1) equidistant points with distance h; that isxi+1−xi = h. Then Newton’s interpolating polynomial Pn(x) of degreeat most n, using forward-differences ∆kf0, k = 0, 1, 2, ..., n is given by

Pn(x) =n

k=0

(

s

k

)

∆kf0,

where s =x− x0

h.

Illustration: The Forward Difference Table with n = 4

46

Page 18: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

x f(x) ∆f ∆2f ∆3f ∆4f

x0 f0

∆f0

x1 f1 ∆2f0

∆f1 ∆3f0

x2 f2 ∆2f1 ∆4f0

∆f2 ∆3f1

x3 f3 ∆2f2

∆f3

x4 f4

Example 2.7 Let f(x) = ex.

x f ∆f ∆2f ∆3f

0 11.7183

1 2.7183 2.95254.6708 5.0731

2 7.3891 8.0256 8.717612.6964 13.7907

3 20.0855 21.816334.5127

4 54.5982

Let x = 1.5

Then s =x− x0

h=

1.5 − 0

1= 1.5

P4(1.5) =

(

1.50

)

1+

(

1.51

)

1.7183+

(

1.52

)

2.9525+

(

1.53

)

5.0731+

(

1.54

)

8.7176 =

1 + 1.5(1.7183) + 0.3750(2.9525) + (−0.0625)(5.0731) + (0.0234)(8.7176) = 4.5716The correct answer up to 4 decimal digits is 4.4817.

Interpolation using Newton-Backward DifferencesWhile interpolating at some value of x near the end of the difference table, it is logical toreorder the nodes so that the end-differences can be used in computation. The backwarddifferences allow us to do so.

The backward differences are defined by

47

Page 19: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

∇fn = fn − fn−1, n = 1, 2, 3, . . . ,

and

∇kfn = ∇(∇k−1fn), k = 2, 3, . . .

Thus, ∇2fn = ∇(∇fn) = ∇(fn − fn−1)= fn − fn−1 − (fn−1 − fn−2)= fn − 2fn−1 + fn−2,

and so on.The following a relationship between the backward-differences and the divided differencescan be obtained.

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

k!hk∇kfn.

Using these backward-differences, we can write the Newton interpolation formula as:

Pn(x) = fn + s∇fn +s(s+ 1)

2!∇2fn + ...+

s(s+ 1)...(s+ n− 1)

n!∇nfn.

Again, using the notation(

−s

k

)

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

k!we can rewrite the above formula as:

Newton’s Backward-DifferenceInterpolations Formula

Pn(x) =n

k=0

(−1)k

(−sk

)

5k fn.

2.7 Spline-Interpolation

So far we have been considering interpolation by means of a single polynomial in the entirerange.Let’s now consider interpolation using different polynomials (but of the same degree) atdifferent intervals. Let the function f(x) be defined at the nodes a = x0, x1, x2, ..., xn = b.The problem now is to construct piecewise polynomials Sj(x) on each interval [xj, xj+1],j = 0, 1, 2, ..., n − 1, so that the resulting function S(x) is an interpolant for the functionf(x).The simplest such polynomials are of course, linear polynomials (straight lines). The inter-polating polynomial in this case is called linear spline. The two biggest disadvantages ofa linear spline are (i) the convergence is rather slow, and (ii) not suitable for applicationsdemanding smooth approximations, since these splines have corner at the knots.

48

Page 20: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

“Just imagine a cross section of an airplane wing in the form of a linear spline and youquickly decide to go by rail. (Stewart (1998), p. 93).”Likewise the quadratic splines have also certain disadvantages.The most common and widely used splines are cubic splines. Assume that the cubicpolynomial Sj(x), has the following form:

Sj(x) = aj + bj(x− xj) + cj(x− xj)2 + dj(x− xj)

3, j = 0, 1, . . . , n− 1.

Since Sj(x) contains four unknowns, to construct n cubic polynomials S0(x), S1(x), ..., Sn−1(x),we need 4n conditions. To have these 4n conditions, a cubic spline S(x) for the functionf(x) can be conveniently defined as follows:

Cubic Spline Interpolant

A function S(x), denoted by Sj(x), over the interval [xj, xj+1], j = 0, 1, ..., n − 1 iscalled a cubic spline interpolant if the following conditions hold:

(i) Sj(xj) = fj, j = 0, 1, 2, ..., n.

(ii) Sj+1(xj+1) = Sj(xj+1), j = 0, 1, 2, ..., n− 2.

(iii) S ′

j+1(xj+1) = S ′

j(xj+1), j = 0, 1, 2, ..., n− 2.

(iv) S ′′

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

j (xj+1), j = 0, 1, 2, ..., n− 2.

Then, since for j there are four unkowns: aj, bj, cj, and dj and there are n such polynomialsto be determined, all together there are 4n unknowns. However, conditions (i)-(iv) abovegive only (4n−2) equations: (i) gives n+1, and each of (ii)-(iv) gives n−1. So, to completelydetermine the cubic spline, we must need two more equations. To obtain these two additionalequations, we can invoke boundary conditions.

• If the second derivative of S(x) can be approximated, than we can take: S ′′(x0) =S ′′(xn) = 0 (free or natural boundary).

• On the other hand, if only the first derivative can be estimated, we can use the followingboundary condition: S ′(x0) = f ′(x0), and S ′(xn) = f ′(xn) (clamped boundary).

We will discuss only the clamped cubic spline here.From the condition (i), it immediately follows that

aj = fj, j = 0, 1, 2, ..., n− 1.

49

Page 21: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Set hj = xj+1−xj .With some mathematical manipulations, it can then be shown (see for e.g.,Burden and Faires, pp. 144-145), that once aj’s are known, the coefficients cj, j = 0, 1, 2, ..., ncan be found by solving the following linear algebraic system of equations:

Ax = r,

whereA =

2h0 h0 0 0

h0 2(h0 + h1) h1. . .

0 h1 2(h1 + h2) h2. . .

. . .. . .

. . .. . . 0

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

0 0 hn−1 2hn−1

x =

c0c1...cn

, r =

3h0

(a1 − a0) − 3f ′(a)

3h1

(a2 − a1) − 3h0

(a1 − a0)

...

3f ′(b) − 3hn−1

(an − an−1)

.

Once c0, c1, ..., cn are known by solving the above system of equations, the quantities bj anddj can be computed as follows:

bj =(aj+1 − aj)

hj

− hj

3(cj+1 + 2cj), j = n− 1, n− 2, · · · , 0

dj =cj+1 − cj

3hj

, j = n− 1, n− 2, · · · , 0.

Definition: A matrix A = (aij) is strictly column diagonally dominant if

|a11| > |a21| + |a31| + · · ·+ |an1||a22| > |a12| + |a32| + · · ·+ |an2|

...

|ann| > |a1n| + |a2n| + · · ·+ |an−1,n|

50

Page 22: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

A row diagonally dominant matrix can be similarly defined.

An important property of a strictly column diagonally dominant matrix is:

Solving Ax = b with A Strictly Column Diagonally Dominant.

If A is strictly column diagonally dominant, then

· Solution of Ax = b using Gaussian elimination does not need pivoting

· Gaussian elimination process is numerically stable.

For details, see “Numerical Linear Algebra and Applications” by B. N. Datta, Brooks/ColePublishing Co., California, 1995 (Second edition is to be published by SIAM in 2009 ).

51

Page 23: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Algorithm 2.2 Computing Clamped Cubic Spline

Inputs:

(i) The nodes x0, x1, ..., xn.

(ii) The functional values:f(xi) = fi, i = 0, 1, ..., n.

(Note that a = x0 and b = xn).

(iii) f ′(x0) = f ′(a) and f ′(xn) = f ′(b).

Outputs: The coefficients a0, ..., an; b0, ..., bn; c0, c1, ..., cn, and d0, d1, ..., dn of the n polyno-mials S0(x), S1(x), ..., Sn−1(x) of which the cubic interpolant S(x) is composed.

Step 1. For i = 0, 1, ..., n− 1 doSet hj = xj+1 − xj

Step 2. Compute a0, a1, ..., an:For i = 0, 1, ..., n− 1 do

ai = f(xi), i = 0, 1, ..., n.

EndStep 3. Compute the coefficients c0, c1, ..., cn by solving the system Ax = r, where A, x,and r are as defined above.

Step 4. Compute the coefficients b0, ..., bn and d0, d1, ..., dn as given in the box above.

52

Page 24: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

Exercises

1. Prove that the Vandermonde matrix of system 2.1 is nonsingular if xk, k = 0, 1, . . . , nare all distinct.

2. Prove by induction thatdn+1

dtn+1

n∏

i=0

(t− xi)

n∏

i=0

(x− xi)

=(n + 1)!

n∏

i=0

(x− xi)

3. Consider the following tablex f(x)1 01.01 0.011.02 0.01981.03 0.0296

(a) Find an approximation of f(1.025) using

i. The associated Vandermonde linear system

ii. Lagrangian interpolating polynomial of degree 3

iii. Newton interpolating polynomial of degree 3

(b) Compute the maximum error in interpolation using the interpolating error for-mula.

(c) Compare the error made in each case (i)-(iii) with the maximum error.

4. Suppose that a table is to be prepared for the function f(x) = ln x on [1, 3.5] withequal spacing nodes such that the interpolation with third degree polynomial will givean accuracy of ε = 5× 10−8. Determine how small h has to be to guarantee the aboveaccuracy.

53

Page 25: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

5. Prove by induction that

(a) f [x0, x1, · · · , xk] =∆kf0

k!hk.

(b) ak = f [x0, x1, · · · , xk], where ak’s are the coefficients of the Newton interpolatingpolynomial.

6. (a) Find an approximate value of log10(5) using Newton’s forward difference formulawith x0 = 1, x1 = 2.5, x2 = 4, and x3 = 5.5.

(b) Repeat part (a) using Newton’s backward differences.

(c) Compare the results.

7. Using the data of problem 2, estimate f(1.025) with linear and quadratic splines andcompare your results with those obtained there.

54

Page 26: PART II Lecture Notes on - NIUdattab/math435.2009/INTERPOLATION.pdf2 Interpolation 2.1 Problem Statement and Applications Consider the following table: x0 f0 x1 f1 x2 f2 xk fk xn fn

8. Show that f [x0, x1, · · · , xn] does not change if the nodes are rearranged.

9. Let ψn(x) = (x− x0)(x− x1) · · · (x− xn). Let xi+1 − xi = h, i = 0, 1, · · · , n− 1. Thenprove that

(a) max |ψ1(x)| =h2

4x0 ≤ x ≤ x1

(b) max |ψ2(x)| =2√

3

9h3

x0 ≤ x ≤ x2

[Hint: To bound |ψ2(x)|, shift this polynomial along the x-axis:ψ̂2(x) = (x+ h)x(x− h) and obtain the bound of ψ̂2(x)].

(c) max |ψ3(x)| = h4

x0 ≤ x ≤ x3

max |ψ3(x)| =9

16h4.

x1 ≤ x ≤ x2

(d) Using the results of (a), (b), and (c), obtain the maximum absolute error in eachcase for the functions:

f(x) = ex, 0 ≤ x ≤ 2

f(x) = sin x 0 ≤ x ≤ Π

2

(e) The interpretation of the result of Part (c) is that if the interpolation nodes arechosen so that the interpolation point x is chosen close to the midpoint of [x0, x3],then the interpolation error is smaller than if n were chosen anywhere between x0

and x3. Verify this statement with the data of Problem 2.

55