Chapter 10: Polynomial Interpolationascher/ag_2012/ag_slides/chap10.pdf · {(xi,yi)}=...

Preview:

Citation preview

July 20, 2013

Chapter 10: Polynomial Interpolation

Uri M. Ascher and Chen GreifDepartment of Computer ScienceThe University of British Columbia

{ascher,greif}@cs.ubc.ca

Slides for the bookA First Course in Numerical Methods (published by SIAM, 2011)

http://www.ec-securehost.com/SIAM/CS07.html

Polynomial Interpolation Goals

Goals of this chapter

• To motivate the need for interpolation of data and of functions;

• to derive three(!) different methods for computing a polynomial interpolant,each particularly suitable for certain circumstances;

• to derive error expressions for the polynomial interpolation process;

• to construct Chebyshev interpolants, which can provide very accurateapproximations for complex functions using stable high degree polynomialinterpolation at special points; and

• to consider cases where not only function values but also their derivativevalues are to be interpolated.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 1 / 1

Polynomial Interpolation Outline

Outline

• Monomial basis

• Lagrange basis

• Newton basis and divided differences

• Interpolation error

• Chebyshev interpolation

• Interpolating also derivative values

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 2 / 1

Polynomial Interpolation Motivation

Interpolating data

We are given a collection of data samples {(xi, yi)}ni=0.

• The {xi}ni=0 are called the abscissae (singular: abscissa),the {yi}ni=0 are called the data values.

• Want to find a function v(x) which can be used to estimate sampled functionfor x ̸= xi. Interpolation: v(xi) = yi, i = 0, 1, . . . , n.

• Why?• We often get discrete data from sensors or computation, but want information

as if the function were not discretely sampled.• May need to plot, differentiate or integrate data trend.• May require an economical approximation for the data.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 3 / 1

Polynomial Interpolation Motivation

Interpolating data

We are given a collection of data samples {(xi, yi)}ni=0.

• The {xi}ni=0 are called the abscissae (singular: abscissa),the {yi}ni=0 are called the data values.

• Want to find a function v(x) which can be used to estimate sampled functionfor x ̸= xi. Interpolation: v(xi) = yi, i = 0, 1, . . . , n.

• Why?• We often get discrete data from sensors or computation, but want information

as if the function were not discretely sampled.• May need to plot, differentiate or integrate data trend.• May require an economical approximation for the data.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 3 / 1

Polynomial Interpolation Motivation

Interpolating data wish list

• Want a reasonable looking interpolant. Example:

0 1 2 3 4 5 6 70

0.5

1

1.5

2

2.5

x

v

0 1 2 3 4 5 6 70

0.5

1

1.5

2

2.5

x

v

The interplant in the left figure above looks, somehow, more reasonable thanthe right one.

• If possible, v should be inexpensive to construct.

• If possible, v(x) should be inexpensive to evaluate for a given x.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 4 / 1

Polynomial Interpolation Motivation

Interpolating functions

A function f(x) may be given on an interval, a ≤ x ≤ b, explicitly or implicitly.Want interpolant v(x) such that

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

at points xi ∈ [a, b].

Same algorithms as for interpolating data apply, but (importantly) here we may beable to

• choose the abscissae xi;

• estimate interpolation error.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 5 / 1

Polynomial Interpolation Motivation

Interpolating functions

A function f(x) may be given on an interval, a ≤ x ≤ b, explicitly or implicitly.Want interpolant v(x) such that

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

at points xi ∈ [a, b].

Same algorithms as for interpolating data apply, but (importantly) here we may beable to

• choose the abscissae xi;

• estimate interpolation error.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 5 / 1

Polynomial Interpolation Motivation

Interpolation formulation

There are lots of ways to define a function v(x) to interpolate the data:Polynomials, trigonometric, exponential, rational (fractions),wavelets/curvelets/ridgelets, radial basis functions, . . .Consider a linear combination of linearly independent basis functions {ϕj(x)}

v(x) = c0ϕ0(x) + c1ϕ1(x) + · · ·+ cnϕn(x) =n∑

j=0

cjϕj(x)

where cj are the interpolation coefficients or interpolation weights.Then the interpolation conditions yield

ϕ0(x0) ϕ1(x0) ϕ2(x0) · · · ϕn(x0)ϕ0(x1) ϕ1(x1) ϕ2(x1) · · · ϕn(x1)

......

......

ϕ0(xn) ϕ1(xn) ϕ2(xn) · · · ϕn(xn)

c0c1...cn

=

y0y1...yn

.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 6 / 1

Polynomial Interpolation Motivation

Interpolation formulation

There are lots of ways to define a function v(x) to interpolate the data:Polynomials, trigonometric, exponential, rational (fractions),wavelets/curvelets/ridgelets, radial basis functions, . . .Consider a linear combination of linearly independent basis functions {ϕj(x)}

v(x) = c0ϕ0(x) + c1ϕ1(x) + · · ·+ cnϕn(x) =n∑

j=0

cjϕj(x)

where cj are the interpolation coefficients or interpolation weights.Then the interpolation conditions yield

ϕ0(x0) ϕ1(x0) ϕ2(x0) · · · ϕn(x0)ϕ0(x1) ϕ1(x1) ϕ2(x1) · · · ϕn(x1)

......

......

ϕ0(xn) ϕ1(xn) ϕ2(xn) · · · ϕn(xn)

c0c1...cn

=

y0y1...yn

.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 6 / 1

Polynomial Interpolation Motivation

Interpolation formulation

There are lots of ways to define a function v(x) to interpolate the data:Polynomials, trigonometric, exponential, rational (fractions),wavelets/curvelets/ridgelets, radial basis functions, . . .Consider a linear combination of linearly independent basis functions {ϕj(x)}

v(x) = c0ϕ0(x) + c1ϕ1(x) + · · ·+ cnϕn(x) =n∑

j=0

cjϕj(x)

where cj are the interpolation coefficients or interpolation weights.Then the interpolation conditions yield

ϕ0(x0) ϕ1(x0) ϕ2(x0) · · · ϕn(x0)ϕ0(x1) ϕ1(x1) ϕ2(x1) · · · ϕn(x1)

......

......

ϕ0(xn) ϕ1(xn) ϕ2(xn) · · · ϕn(xn)

c0c1...cn

=

y0y1...yn

.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 6 / 1

Polynomial Interpolation Motivation

Polynomial interpolation

• Special case: the functions ϕ0(x), ϕ1(x), . . . , ϕn(x) form a basis for allpolynomials of degree at most n.

• This is the simplest, most basic form of interpolation.

• Used as building block for other methods for interpolation, integration,solution of differential equations, etc.

• Our goal here is therefore to develop methods for polynomial interpolation, tobe repeatedly used in later chapters (e.g., 11, 14, 15, 16).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 7 / 1

Polynomial Interpolation Motivation

Polynomial interpolation

• Special case: the functions ϕ0(x), ϕ1(x), . . . , ϕn(x) form a basis for allpolynomials of degree at most n.

• This is the simplest, most basic form of interpolation.

• Used as building block for other methods for interpolation, integration,solution of differential equations, etc.

• Our goal here is therefore to develop methods for polynomial interpolation, tobe repeatedly used in later chapters (e.g., 11, 14, 15, 16).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 7 / 1

Polynomial Interpolation Monomial basis

Outline

• Monomial basis

• Lagrange basis

• Newton basis and divided differences

• Interpolation error

• Chebyshev interpolation

• Interpolating also derivative values

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 8 / 1

Polynomial Interpolation Monomial basis

Monomial basis

v(x) = p(x) = pn(x) =n∑

j=0

cjϕj(x).

Choose

ϕj(x) = xj .

Then

v(x) = p(x) = pn(x) =n∑

j=0

cjxj .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 9 / 1

Polynomial Interpolation Monomial basis

Example

{(xi, yi)} = {(2, 14), (6, 24), (4, 25), (7, 15)}

In particular, n = 3.

• Requires four basis functions: {ϕj(x)} = {1, x, x2, x3}.The interpolant will be p(x) = c0 + c1x+ c2x

2 + c3x3.

• Construct linear system

A =

1 2 4 81 6 36 2161 4 16 641 7 49 343

y =

14242515

• Solve c = A\y.

We find c ≈ (−0.267, 1.700, 2.767, 3.800)T .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 10 / 1

Polynomial Interpolation Monomial basis

Monomial basis assessment

• Simple!

• Matrix A is a Vandermonde: nonsingular. Hence uniqueness: there isprecisely one interpolating polynomial.

• Construction cost is O(n3) flops (high if n is large).

• Evaluation cost (per point x) using Horner’s rule is O(n) flops (low).

• Coefficients cj are not indicative of f(x), and all change if one data value ismodified.

• Potential stability difficulties if degree is large or abscissae spread apart.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 11 / 1

Polynomial Interpolation Lagrange basis

Outline

• Monomial basis

• Lagrange basis

• Newton basis and divided differences

• Interpolation error

• Chebyshev interpolation

• Interpolating also derivative values

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 12 / 1

Polynomial Interpolation Lagrange basis

Lagrange form

In several ways, the opposite of monomials! Choose coefficients cj = yj .For this define Lagrange polynomials ϕj(x) = Lj(x)

ϕj(x) =(x− x0) · · · (x− xj−1)(x− xj+1) · · · (x− xn)

(xj − x0) · · · (xj − xj−1)(xj − xj+1) · · · (xj − xn)=

n∏i=0i ̸=j

(x− xi)(xj − xi)

.

Then

ϕj(xi) =

{0 i ̸= j

1 i = j,

so

p(x) =n∑

j=0

yjϕj(x).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 13 / 1

Polynomial Interpolation Lagrange basis

Example redux

{(xi, yi)} = {(2, 14), (6, 24), (4, 25), (7, 15)}

Use the Lagrange basis.

• Four basis functions

ϕ0(x) =(x− 6)(x− 4)(x− 7)(2− 6)(2− 4)(2− 7)

, ϕ1(x) =(x− 2)(x− 4)(x− 7)(6− 2)(6− 4)(6− 7)

,

ϕ2(x) =(x− 2)(x− 6)(x− 7)(4− 2)(4− 6)(4− 7)

, ϕ3(x) =(x− 2)(x− 6)(x− 4)(7− 2)(7− 6)(7− 4)

.

• Interpolant will be

p(x) =14(x− 6)(x− 4)(x− 7)

(−4)(−2)(−5)+ 24

(x− 2)(x− 4)(x− 7)(+4)(+2)(−1)

+ 25(x− 2)(x− 6)(x− 7)

(+2)(−2)(−3)+ 15

(x− 2)(x− 6)(x− 4)(+5)(+1)(+3)

.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 14 / 1

Polynomial Interpolation Lagrange basis

Ordering the operations

• Construction: barycentric weights.

w0 =1

(2− 6)(2− 4)(2− 7), w1 =

1(6− 2)(6− 4)(6− 7)

,

w2 =1

(4− 2)(4− 6)(4− 7), w3 =

1(7− 2)(7− 6)(7− 4)

.

• Evaluation: at a point x define

ψ(x) = (x− 2)(x− 6)(x− 4)(x− 7),

p(x) = ψ(x)[

14w0

x− 2+

24w1

x− 6+

25w2

x− 4+

15w3

x− 7

].

• In general

ψ(x) =n∏

i=0

(x− xi), p(x) = ψ(x)n∑

j=0

yjwj

x− xj.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 15 / 1

Polynomial Interpolation Lagrange basis

Ordering the operations

• Construction: barycentric weights.

w0 =1

(2− 6)(2− 4)(2− 7), w1 =

1(6− 2)(6− 4)(6− 7)

,

w2 =1

(4− 2)(4− 6)(4− 7), w3 =

1(7− 2)(7− 6)(7− 4)

.

• Evaluation: at a point x define

ψ(x) = (x− 2)(x− 6)(x− 4)(x− 7),

p(x) = ψ(x)[

14w0

x− 2+

24w1

x− 6+

25w2

x− 4+

15w3

x− 7

].

• In general

ψ(x) =n∏

i=0

(x− xi), p(x) = ψ(x)n∑

j=0

yjwj

x− xj.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 15 / 1

Polynomial Interpolation Lagrange basis

Lagrange basis assessment

• Not as simple as monomial basis.

• Matrix A is the identity: the coefficients are immediately obtained.

• Construction cost is O(n2) flops (OK even if n is large).

• Evaluation cost for each x is O(n) flops (low but not lowest).

• Coefficients cj indicative of data and useful for function manipulation such asintegration and differentiation!

• Stable even if degree is large or abscissae spread apart!

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 16 / 1

Polynomial Interpolation Newton basis & divided differences

Outline

• Monomial basis

• Lagrange basis

• Newton basis and divided differences

• Interpolation error

• Chebyshev interpolation

• Interpolating also derivative values

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 17 / 1

Polynomial Interpolation Newton basis & divided differences

Newton form

Can we add a new data point without changing the entire interpolant?

• Need n→ n+ 1, easy to construct and evaluate.

• To this end require

• New basis function cannot disturb prior interpolation: ϕj(xi) = 0 for i < j.• Old basis function does not need information about new data values: ϕj(x) is

independent of (xi, yi) for i > j.

• Newton basis functions

ϕj(x) =j−1∏i=0

(x− xi), j = 0, 1, . . . , n.

• Leads to lower triangular matrix A .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 18 / 1

Polynomial Interpolation Newton basis & divided differences

Newton form

Can we add a new data point without changing the entire interpolant?

• Need n→ n+ 1, easy to construct and evaluate.

• To this end require

• New basis function cannot disturb prior interpolation: ϕj(xi) = 0 for i < j.• Old basis function does not need information about new data values: ϕj(x) is

independent of (xi, yi) for i > j.

• Newton basis functions

ϕj(x) =j−1∏i=0

(x− xi), j = 0, 1, . . . , n.

• Leads to lower triangular matrix A .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 18 / 1

Polynomial Interpolation Newton basis & divided differences

Newton form

Can we add a new data point without changing the entire interpolant?

• Need n→ n+ 1, easy to construct and evaluate.

• To this end require

• New basis function cannot disturb prior interpolation: ϕj(xi) = 0 for i < j.• Old basis function does not need information about new data values: ϕj(x) is

independent of (xi, yi) for i > j.

• Newton basis functions

ϕj(x) =j−1∏i=0

(x− xi), j = 0, 1, . . . , n.

• Leads to lower triangular matrix A .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 18 / 1

Polynomial Interpolation Newton basis & divided differences

Example redux

{(xi, yi)} = {(2, 14), (6, 24), (4, 25), (7, 15)}

Use the Newton basis.

• Four basis functions

ϕ0(x) = 1, ϕ1(x) = (x− 2),ϕ2(x) = (x− 2)(x− 6), ϕ3(x) = (x− 2)(x− 6)(x− 4).

• Construct linear system

A =

1 0 0 01 4 0 01 2 −4 01 5 5 15

and solve Ac = y to find c ≈ (14, 2.5,−1.5,−0.2667)T .

• Note it is the same polynomial as before, just another form!

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 19 / 1

Polynomial Interpolation Newton basis & divided differences

Example redux

{(xi, yi)} = {(2, 14), (6, 24), (4, 25), (7, 15)}

Use the Newton basis.

• Four basis functions

ϕ0(x) = 1, ϕ1(x) = (x− 2),ϕ2(x) = (x− 2)(x− 6), ϕ3(x) = (x− 2)(x− 6)(x− 4).

• Construct linear system

A =

1 0 0 01 4 0 01 2 −4 01 5 5 15

and solve Ac = y to find c ≈ (14, 2.5,−1.5,−0.2667)T .

• Note it is the same polynomial as before, just another form!

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 19 / 1

Polynomial Interpolation Newton basis & divided differences

Example redux

{(xi, yi)} = {(2, 14), (6, 24), (4, 25), (7, 15)}

Use the Newton basis.

• Four basis functions

ϕ0(x) = 1, ϕ1(x) = (x− 2),ϕ2(x) = (x− 2)(x− 6), ϕ3(x) = (x− 2)(x− 6)(x− 4).

• Construct linear system

A =

1 0 0 01 4 0 01 2 −4 01 5 5 15

and solve Ac = y to find c ≈ (14, 2.5,−1.5,−0.2667)T .

• Note it is the same polynomial as before, just another form!

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 19 / 1

Polynomial Interpolation Newton basis & divided differences

Divided differences

• An alternative method of determining the coefficients for a Newton basisinterpolating polynomial.

• Used more often than solving a linear system.

• Makes it easier to add and delete data points.

• Divided differences have an interesting connection with function derivatives,and provide a tool with which we will analyze interpolation error .

• Divided differences are defined recursively

f [xi] = yi, f [xi, . . . , xj ] =f [xi+1, . . . , xj ]− f [xi, . . . , xj−1]

xj − xi.

• The coefficients for Newton interpolation are just cj = f [x0, . . . , xj ] (thediagonal elements in the table).

• To add another data point (n→ n+ 1), just add another row to the table(assuming that the abscissae are distinct) .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 20 / 1

Polynomial Interpolation Newton basis & divided differences

Divided differences

• An alternative method of determining the coefficients for a Newton basisinterpolating polynomial.

• Used more often than solving a linear system.

• Makes it easier to add and delete data points.

• Divided differences have an interesting connection with function derivatives,and provide a tool with which we will analyze interpolation error .

• Divided differences are defined recursively

f [xi] = yi, f [xi, . . . , xj ] =f [xi+1, . . . , xj ]− f [xi, . . . , xj−1]

xj − xi.

• The coefficients for Newton interpolation are just cj = f [x0, . . . , xj ] (thediagonal elements in the table).

• To add another data point (n→ n+ 1), just add another row to the table(assuming that the abscissae are distinct) .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 20 / 1

Polynomial Interpolation Newton basis & divided differences

Divided differences

• An alternative method of determining the coefficients for a Newton basisinterpolating polynomial.

• Used more often than solving a linear system.

• Makes it easier to add and delete data points.

• Divided differences have an interesting connection with function derivatives,and provide a tool with which we will analyze interpolation error .

• Divided differences are defined recursively

f [xi] = yi, f [xi, . . . , xj ] =f [xi+1, . . . , xj ]− f [xi, . . . , xj−1]

xj − xi.

• The coefficients for Newton interpolation are just cj = f [x0, . . . , xj ] (thediagonal elements in the table).

• To add another data point (n→ n+ 1), just add another row to the table(assuming that the abscissae are distinct) .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 20 / 1

Polynomial Interpolation Newton basis & divided differences

Divided difference table

i xi f [xi] f [xi−1, xi] f [xi−2, xi−1, xi] · · · f [xi−n, . . . , xi]

0 x0 f(x0)

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

x1−x0

2 x2 f(x2)f [x2]−f [x1]

x2−x1f [x0, x1, x2]

......

......

.... . .

n xn f(xn)f [xn]−f [xn−1]

xn−xn−1f [xn−2, xn−1, xn] · · · f [x0, x1, . . . , xn]

The diagonal entries yield the coefficients cj = f [x0, . . . , xj ], j = 0, 1, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 21 / 1

Polynomial Interpolation Newton basis & divided differences

Basis comparison

Basis construction evaluation sellingname ϕj(x) cost cost feature

Monomial xj 23n

3 2n simple

Lagrange Lj(x) n2 5ncj = yj

most stable

Newton

j−1∏i=0

(x− xi) 32n

2 2n adaptive

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 22 / 1

Polynomial Interpolation Polynomial interpolation error

Outline

• Monomial basis

• Lagrange basis

• Newton basis and divided differences

• Interpolation error

• Chebyshev interpolation

• Interpolating also derivative values

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 23 / 1

Polynomial Interpolation Polynomial interpolation error

Error expression

• Assume that f is the function to be interpolated andyi = f(xi), i = 0, 1, 2, . . . , n. Denote interpolant by pn(x).For any evaluation point x, want to estimate error

en(x) = f(x)− pn(x)

and see how it depends on the choice of n and the properties of f .

• Fixing x /∈ {xi}ni=0, pretend we are adding as new data point (x, f(x)) .

• Using the properties of the Newton basis and divided differences,

f(x) = pn+1(x) = pn(x) + f [x0, . . . , xn, x]n∏

j=0

(x− xj)

or, by rearranging,

en(x) = f(x)− pn(x) = f [x0, . . . , xn, x]ψ(x).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 24 / 1

Polynomial Interpolation Polynomial interpolation error

Error expression

• Assume that f is the function to be interpolated andyi = f(xi), i = 0, 1, 2, . . . , n. Denote interpolant by pn(x).For any evaluation point x, want to estimate error

en(x) = f(x)− pn(x)

and see how it depends on the choice of n and the properties of f .

• Fixing x /∈ {xi}ni=0, pretend we are adding as new data point (x, f(x)) .

• Using the properties of the Newton basis and divided differences,

f(x) = pn+1(x) = pn(x) + f [x0, . . . , xn, x]n∏

j=0

(x− xj)

or, by rearranging,

en(x) = f(x)− pn(x) = f [x0, . . . , xn, x]ψ(x).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 24 / 1

Polynomial Interpolation Polynomial interpolation error

Error estimate and bound

• Let a = mini xi, b = maxi xi and assume x ∈ [a, b] (otherwise pn(x) is“extrapolating”)

• Relationship between divided differences and derivatives:

∃ξ ∈ [a, b] such that f [x0, . . . , xn, x] = f(n+1)(ξ)(n+1)! .

• So take upper bounds to find

|en(x)| ≤ maxt∈[a,b]

|f (n+1)(t)|(n+ 1)!

maxs∈[a,b]

∣∣∣∣∣∣n∏

j=0

(s− xj)

∣∣∣∣∣∣ =∥f (n+1)∥∞(n+ 1)!

∥ψ∥∞;

∥en∥∞ ≤∥f (n+1)∥∞(n+ 1)!

(b− a)n+1.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 25 / 1

Polynomial Interpolation Polynomial interpolation error

Example

Consider {(x0, y0), (x1, y1)}.So n = 1, hence n+ 1 = 2.

∥en∥ ≤12∥f ′′∥max

s|(s− x0)(s− x1)|.

Max at s = x0+x12 , so maxs |(s− x0)(s− x1)| = 1

4 (x1 − x0)2.Thus

∥en∥ ≤18(x1 − x0)2∥f ′′∥.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 26 / 1

Polynomial Interpolation Polynomial interpolation error

Example

Consider {(x0, y0), (x1, y1)}.So n = 1, hence n+ 1 = 2.

∥en∥ ≤12∥f ′′∥max

s|(s− x0)(s− x1)|.

Max at s = x0+x12 , so maxs |(s− x0)(s− x1)| = 1

4 (x1 − x0)2.Thus

∥en∥ ≤18(x1 − x0)2∥f ′′∥.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 26 / 1

Polynomial Interpolation Polynomial interpolation error

Example

Consider {(x0, y0), (x1, y1)}.So n = 1, hence n+ 1 = 2.

∥en∥ ≤12∥f ′′∥max

s|(s− x0)(s− x1)|.

Max at s = x0+x12 , so maxs |(s− x0)(s− x1)| = 1

4 (x1 − x0)2.Thus

∥en∥ ≤18(x1 − x0)2∥f ′′∥.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 26 / 1

Polynomial Interpolation Polynomial interpolation error

Example

Consider {(x0, y0), (x1, y1)}.So n = 1, hence n+ 1 = 2.

∥en∥ ≤12∥f ′′∥max

s|(s− x0)(s− x1)|.

Max at s = x0+x12 , so maxs |(s− x0)(s− x1)| = 1

4 (x1 − x0)2.Thus

∥en∥ ≤18(x1 − x0)2∥f ′′∥.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 26 / 1

Polynomial Interpolation Chebyshev interpolation

Outline

• Monomial basis

• Lagrange basis

• Newton basis and divided differences

• Interpolation error

• Chebyshev interpolation

• Interpolating also derivative values

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 27 / 1

Polynomial Interpolation Chebyshev interpolation

Chebyshev interpolation

Can we minimize error bound? i.e., the right hand side of

maxa≤x≤b

|en(x)| ≤ maxt∈[a,b]

|f (n+1)(t)|(n+ 1)!

maxs∈[a,b]

∣∣∣∣∣∣n∏

j=0

(s− xj)

∣∣∣∣∣∣• Assume we can evaluate f(x) at any n+ 1 points xi. What should those be?

• Knowing nothing more about the interpolated function f(x), choose the

abscissae xi attempting to minimize maxs∈[a,b]

∣∣∣∏nj=0(s− xj)

∣∣∣.• This leads to Chebyshev points: over a = −1, b = 1 they are

xi = cos(

2i+ 12(n+ 1)

π

), i = 0, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 28 / 1

Polynomial Interpolation Chebyshev interpolation

Chebyshev interpolation

Can we minimize error bound? i.e., the right hand side of

maxa≤x≤b

|en(x)| ≤ maxt∈[a,b]

|f (n+1)(t)|(n+ 1)!

maxs∈[a,b]

∣∣∣∣∣∣n∏

j=0

(s− xj)

∣∣∣∣∣∣• Assume we can evaluate f(x) at any n+ 1 points xi. What should those be?

• Knowing nothing more about the interpolated function f(x), choose the

abscissae xi attempting to minimize maxs∈[a,b]

∣∣∣∏nj=0(s− xj)

∣∣∣.• This leads to Chebyshev points: over a = −1, b = 1 they are

xi = cos(

2i+ 12(n+ 1)

π

), i = 0, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 28 / 1

Polynomial Interpolation Chebyshev interpolation

Chebyshev interpolation

Can we minimize error bound? i.e., the right hand side of

maxa≤x≤b

|en(x)| ≤ maxt∈[a,b]

|f (n+1)(t)|(n+ 1)!

maxs∈[a,b]

∣∣∣∣∣∣n∏

j=0

(s− xj)

∣∣∣∣∣∣• Assume we can evaluate f(x) at any n+ 1 points xi. What should those be?

• Knowing nothing more about the interpolated function f(x), choose the

abscissae xi attempting to minimize maxs∈[a,b]

∣∣∣∏nj=0(s− xj)

∣∣∣.• This leads to Chebyshev points: over a = −1, b = 1 they are

xi = cos(

2i+ 12(n+ 1)

π

), i = 0, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 28 / 1

Polynomial Interpolation Chebyshev interpolation

Chebyshev points

• These points solve the min-max problem

β = minx0,x1,...,xn

max−1≤x≤1

|(x− x0)(x− x1) · · · (x− xn)|,

yielding the value β = 2−n.

• This leads to the Chebyshev interpolation error bound

max−1≤x≤1

|f(x)− pn(x)| ≤ 12n(n+ 1)!

max−1≤t≤1

|f (n+1)(t)|.

• For a general interval [a, b], scale and translate [−1, 1] onto [a, b]

x = a+b− a

2(t+ 1), t ∈ [−1, 1].

Thus, shift and scale the Chebyshev points by

xi ←− a+b− a

2(xi + 1), i = 0, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 29 / 1

Polynomial Interpolation Chebyshev interpolation

Chebyshev points

• These points solve the min-max problem

β = minx0,x1,...,xn

max−1≤x≤1

|(x− x0)(x− x1) · · · (x− xn)|,

yielding the value β = 2−n.

• This leads to the Chebyshev interpolation error bound

max−1≤x≤1

|f(x)− pn(x)| ≤ 12n(n+ 1)!

max−1≤t≤1

|f (n+1)(t)|.

• For a general interval [a, b], scale and translate [−1, 1] onto [a, b]

x = a+b− a

2(t+ 1), t ∈ [−1, 1].

Thus, shift and scale the Chebyshev points by

xi ←− a+b− a

2(xi + 1), i = 0, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 29 / 1

Polynomial Interpolation Chebyshev interpolation

Chebyshev points

• These points solve the min-max problem

β = minx0,x1,...,xn

max−1≤x≤1

|(x− x0)(x− x1) · · · (x− xn)|,

yielding the value β = 2−n.

• This leads to the Chebyshev interpolation error bound

max−1≤x≤1

|f(x)− pn(x)| ≤ 12n(n+ 1)!

max−1≤t≤1

|f (n+1)(t)|.

• For a general interval [a, b], scale and translate [−1, 1] onto [a, b]

x = a+b− a

2(t+ 1), t ∈ [−1, 1].

Thus, shift and scale the Chebyshev points by

xi ←− a+b− a

2(xi + 1), i = 0, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 29 / 1

Polynomial Interpolation Chebyshev interpolation

Runge example

f(x) =1

1 + 25x2, −1 ≤ x ≤ 1.

Equi-distant points, n = 4, 9.

−1 −0.5 0 0.5 1−0.5

0

0.5

1

x

p

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 30 / 1

Polynomial Interpolation Chebyshev interpolation

Runge example

f(x) =1

1 + 25x2, −1 ≤ x ≤ 1.

Equi-distant points, n = 19.

−1 −0.5 0 0.5 1−1

0

1

2

3

4

5

6

7

8

9

x

p

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 31 / 1

Polynomial Interpolation Chebyshev interpolation

Runge example

f(x) =1

1 + 25x2, −1 ≤ x ≤ 1.

Chebyshev points, n = 4, 9.

−1 −0.5 0 0.5 1−0.5

0

0.5

1

x

p

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 32 / 1

Polynomial Interpolation Chebyshev interpolation

Runge example

f(x) =1

1 + 25x2, −1 ≤ x ≤ 1.

Chebyshev points, n = 19.

−1 −0.5 0 0.5 1−0.5

0

0.5

1

x

p

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 33 / 1

Polynomial Interpolation Chebyshev interpolation

More difficult example

f(x) = e3x sin(200x2)/(1 + 20x2), 0 ≤ x ≤ 1.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−2

−1

0

1

2

x

p 200

50 100 150 20010

−20

10−10

100

1010

n

max

err

or

Error does not change much at first as n increases, but then it decreases veryrapidly: spectral accuracy.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 34 / 1

Polynomial Interpolation Interpolating also derivative values

Outline

• Monomial basis

• Lagrange basis

• Newton basis and divided differences

• Interpolation error

• Chebyshev interpolation

• Interpolating also derivative values

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 35 / 1

Polynomial Interpolation Interpolating also derivative values

Interpolating also derivative values

Example: quadratic interpolant for

f(0) = 1.5, f ′(0) = 1, f(20) = 0.

Hence

{(xi, yi)} = {(0, 1.5), (0, 1), (20, 0)}.

• Using the simplest basis, monomial:

p(x) = c0 + c1x+ c2x2.

Then

1.5 = p(0) = c0,

1 = p′(0) = c1,

0 = p(20) = c0 + 20c1 + 400c2.Hence c2 = (−1.5− 20)/400 = −21.5

400 and

p(x) = 1.5 + x− 21.5400

x2.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 36 / 1

Polynomial Interpolation Interpolating also derivative values

Interpolating also derivative values

Example: quadratic interpolant for

f(0) = 1.5, f ′(0) = 1, f(20) = 0.

Hence

{(xi, yi)} = {(0, 1.5), (0, 1), (20, 0)}.

• Using the simplest basis, monomial:

p(x) = c0 + c1x+ c2x2.

Then

1.5 = p(0) = c0,

1 = p′(0) = c1,

0 = p(20) = c0 + 20c1 + 400c2.Hence c2 = (−1.5− 20)/400 = −21.5

400 and

p(x) = 1.5 + x− 21.5400

x2.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 36 / 1

Polynomial Interpolation Interpolating also derivative values

Hermite cubic

An important building block in computer aided design (CAD).

{(xi, yi)} = {(t0, f(t0)), (t0, f ′(t0)), (t1, f(t1)), (t1, f ′(t1))}.

• Using the simplest basis, monomial:

p(x) = c0 + c1x+ c2x2 + c3x

3.

• Then form linear equations

c0 + c1t0 + c2t20 + c3t

30 = f(t0), c1 + 2c2t0 + 3c3t20 = f ′(t0),

c0 + c1t1 + c2t21 + c3t

31 = f(t1), c1 + 2c2t1 + 3c3t21 = f ′(t1),

and solve for the coefficients cj .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 37 / 1

Polynomial Interpolation Interpolating also derivative values

Hermite cubic

An important building block in computer aided design (CAD).

{(xi, yi)} = {(t0, f(t0)), (t0, f ′(t0)), (t1, f(t1)), (t1, f ′(t1))}.

• Using the simplest basis, monomial:

p(x) = c0 + c1x+ c2x2 + c3x

3.

• Then form linear equations

c0 + c1t0 + c2t20 + c3t

30 = f(t0), c1 + 2c2t0 + 3c3t20 = f ′(t0),

c0 + c1t1 + c2t21 + c3t

31 = f(t1), c1 + 2c2t1 + 3c3t21 = f ′(t1),

and solve for the coefficients cj .

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 37 / 1

Polynomial Interpolation Interpolating also derivative values

General algorithm

...1 Construction: Given data {(xi, yi)}ni=0, where the abscissae are notnecessarily distinct;

for j = 0, 1, . . . , nfor l = 0, 1, . . . , j

γj,l =

{γj,l−1−γj−1,l−1

xj−xj−lif xj ̸= xj−l,

f(l)(xj)l! otherwise

...2 Evaluation: Given an evaluation point x,

p = γn,n

for j = n− 1, n− 2, . . . , 0,p = p (x− xj) + γj,j

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 38 / 1

Polynomial Interpolation Interpolating also derivative values

Example

Given five data values

ti f(ti) f ′(ti) f ′′(ti)8.3 17.564921 3.116256 0.1204828.6 18.505155 3.151762

set up

(x0, x1, x2, x3, x4) =

8.3, 8.3, 8.3︸ ︷︷ ︸m0=2

, 8.6, 8.6︸ ︷︷ ︸m1=1

,

Obtain

xi f [·] f [·, ·] f [·, ·, ·] f [·, ·, ·, ·] f [·, ·, ·, ·, ·]8.3 17.5649218.3 17.564921 3.1162568.3 17.564921 3.116256 0.0602418.6 18.505155 3.130780 0.048413 -0.0394268.6 18.505155 3.151762 0.069400 0.071756 0.370604

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 39 / 1

Recommended