Docsity

Interpolation with Lagrange Polynomials: Approximating Functions using Distinct Points, Study notes of Mathematical Methods for Numerical Analysis and Optimization

Partial preview of the text

Download Interpolation with Lagrange Polynomials: Approximating Functions using Distinct Points and more Study notes Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Interpolation With Lagrange Polynomials

MATH 375

J. Robert Buchanan

Department of Mathematics

Fall 2006

Introduction

Often choose polynomials to approximate other classes of functions. Theorem (Weierstrass Approximation Theorem) If f ∈ C[ a , b ] and ǫ > 0 then there exists a polynomial P such that | f ( x ) − P ( x )| < ǫ, ∀ x ∈ [ a , b ].

We have used Taylor polynomials to approximate functions. P ( x ) =

∑^ n

k = 0

f ( k )( x 0 ) k! ( x − x 0 ) k

Away from x 0 the approximation may be very poor.

Example

If xi = i for i = 0 , 1 , 2 then we can create three different Lagrange Basis Polynomials.

L 2 , 0 ( x ) = x − 1 0 − 1

x − 2 0 − 2

( x − 1 )( x − 2 )

L 2 , 1 ( x ) = x − 0 1 − 0

x − 2 1 − 2

= x ( 2 − x )

L 2 , 2 ( x ) =

x − 0 2 − 0

x − 1 2 − 1

x ( x − 1 )

-1 1 2 3 x

1

2

3

y

Example

Let f ( x ) = sin x , n = 3, and xk = k π/3 for k = 0 , 1 , 2 , 3. The four Lagrange Basis Polynomials are listed below.

L 3 , 0 ( x ) =

2 π^3

(π − 3 x )( 2 π − 3 x )(π − x )

L 3 , 1 ( x ) =

2 π^3

x ( 2 π − 3 x )(π − x )

L 3 , 2 ( x ) = −

2 π^3

x (π − 3 x )(π − x )

L 3 , 3 ( x ) =

2 π^3 x (π − 3 x )( 2 π − 3 x )

Example (continued)

The Lagrange Interpolating Polynomial of degree 3 for f ( x ) = sin x and xk = k π/3 for k = 0 , 1 , 2 , 3 is

P ( x ) = (sin 0) L 3 , 0 ( x ) +

sin π 3

L 3 , 1 ( x ) +

sin 2 π 3

L 3 , 2 ( x )

  • (sin π) L 3 , 3 ( x )

=

4 π^2 x (π − x )

Lagrange Polynomial with Error Term

Theorem Suppose x 0 , x 1 ,... , xn are distinct numbers in the interval [ a , b ] and suppose f ∈ C n +^1 [ a , b ]. Then for each x ∈ [ a , b ] there exists a number z ≡ z ( x ) ∈ ( a , b ) for which

f ( x ) = P ( x ) + f ( n +^1 )( z ( x )) ( n + 1 )!

( x − x 0 )( x − x 1 ) · · · ( x − xn ),

where P ( x ) is the Lagrange Interpolating Polynomial.

Application

Example Suppose we are preparing a table of values for cos x on [ 0 , π]. The entries in the table will have eight accurate decimal places and we will linearly interpolate between adjacent entries to determine intermediate values. What should the spacing between adjacent x -values be to preserve the eight-decimal-place accuracy in the interpolation?

Interpolation from Data

Suppose we had only the following table of data for f ( x ):

x f ( x )

  1. 1 0. 17537
  2. 2 0. 37784
  3. 0 0. 52992
  4. 6 0. 66393
  5. 5 0. 63608

Approximate f ( 27. 5 ) using polynomial interpolation. Linear approximation:

P 1 ( 27. 5 ) =

f ( 22. 2 )+

f ( 32. 0 ) ≈ 0. 46009

Higher Order Approximations

Quadratic approximation: (two choices)

P 2 ( 27. 5 ) =

f ( 10. 1 )

f ( 22. 2 )

f ( 32. 0 ) ≈ 0. 46141

P^ ˆ 2 ( 27. 5 ) = (^27.^5 −^32.^0 )(^27.^5 −^41.^6 )

f ( 22. 2 )

f ( 32. 0 )

f ( 41. 6 )+ ≈ 0. 46200

There are also two potential cubic interpolating polynomials and a single quartic polynomial.

Definition

If f is a function defined at x 0 , x 1 ,... , xn distinct real numbers and m 1 , m 2 ,... , mk are k distinct integers with 0 ≤ mi ≤ n , then the Lagrange polynomial that agrees with f at the k points xm 1 , xm 2 ,... , xmk is denoted Pm 1 , m 2 ,··· , mk.

Theorem

Let f be defined at x 0 , x 1 ,... , xk and xi and xj be two distinct real numbers in this set. Then the kth^ degree Lagrange polynomial that interpolates f at x 0 , x 1 ,... , xk is

P ( x ) =

( x − xj ) ( xi − xj )

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

P 0 , 1 ,..., i − 1 , i + 1 ,..., k ( x ).

Proof.

Let Q ( x ) = P 0 , 1 ,..., j − 1 , j + 1 ,..., k ( x ) and Q ˆ( x ) = P 0 , 1 ,..., i − 1 , i + 1 ,..., k ( x ), then

P ( x ) =

( x − xj ) Q ( x ) − ( x − xi ) Q ˆ( x ) ( xi − xj )

If x = xi , then P ( xi ) = Q ( xi ) = f ( xi ). If x = xj , then

P ( xj ) = Q ˆ( xj ) = f ( xj ). If l ∈ { 0 , 1 ,... , k } with i 6 = l 6 = j then

P ( xl ) =

( xl − xj ) Q ( xl ) − ( xl − xi ) Q ˆ( xl ) ( xi − xj )

=

( xl − xj ) f ( xl ) − ( xl − xi ) f ( xl ) ( xi − xj )

= f ( xl ).

Thus P ( x ) is a polynomial of degree at most k + 1 which interpolates f ( x ) at xi for i = 0 , 1 ,... , k and thus

P ( x ) = P 0 , 1 ,..., k ( x ).

Tabular Calculation

Given x 0 , x 1 ,... , xn and f ( x 0 ), f ( x 1 ),... f ( xn ) we can arrange the Lagrange interpolating polynomials in the following table. x 0 f ( x 0 ) = P 0 = Q 0 , 0 x 1 f ( x 1 ) = P 1 = Q 1 , 0 P 0 , 1 = Q 1 , 1 x 2 f ( x 2 ) = P 2 = Q 2 , 0 P 1 , 2 = Q 2 , 1 P 0 , 1 , 2 = Q 2 , 2 ... ... ... ... xn f ( xn ) = Pn = Qn , 0 Pn − 1 , n = Qn , 1 Pn − 2 , n − 1 , n = Qn , 2 · · · P 0 , 1 ,..., n = Qn , n

Example

Approximate f ( 27. 5 ) from the following data.

xi f ( xi )

  1. 1 0. 17537
  2. 2 0. 37784
  3. 0 0. 52992
  4. 6 0. 66393
  5. 5 0. 63608