Lab for Lagrange Polynomial Approximation

Module for Lagrange Polynomials

   Check out the new Numerical Analysis Projects page.

Background. The Lagrange polynomial of degree n passes through the n+1 points [Graphics:la.txtgr1.gif] for [Graphics:la.txtgr2.gif].

 

Algorithm for the Lagrange Polynomial. To construct the Lagrange polynomial [Graphics:la.txtgr3.gif]
of degree n, based on the n+1 points [Graphics:la.txtgr4.gif] for [Graphics:la.txtgr5.gif]. The Lagrange coefficient polynomials for degree n are:
[Graphics:la.txtgr6.gif]for [Graphics:la.txtgr7.gif].

 

Use the following Mathematica subroutine.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr8.gif]

Load in Mathematica's graphics package "Colors".

[Graphics:la.txtgr9.gif][Graphics:la.txtgr10.gif]
 
 

Report to be handed in.

Computer Exercises

 

Exercise 1. Construct two linear Lagrange interpolating polynomials for the function f[x] = cos(x) over [0.0, 1.2].
Use the different interpolation nodes {{0.0, f[0.0]},{1.2, f[1.2]}} and {{0.2, f[0.2]},{1.0, f[1.0]}}, respectively.

First, construct the other Lagrange polynomials of degree n = 1 using the nodes {{0.0,f[0.0]},{1.2,f[1.2]}}.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr11.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr12.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr13.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr14.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr15.gif]
 

Second, construct the other Lagrange polynomials of degree n = 1 using the nodes {{0.2, f[0.2]},{1.0, f[1.0]}}.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr16.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr17.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr18.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr19.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr20.gif]
 

Notice that the two polynomials of degree n = 1 were different.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr21.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr22.gif]
 
 

Exercise 2. Form several Lagrange polynomials of degree n = 2, 3, 4, and 5 for the function f[x] = cos(x) over the interval [0.0, 1.2] using equally spaced nodes.

Remark. We will use the algorithm for the case n = 2 and observe that it is the same as the result used with the built in Mathematica procedure "Fit". For the other cases we will use Mathematica's procedure.

First, construct the Lagrange interpolation polynomial of degree n = 2.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr23.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr24.gif]

Compare with Mathematica's Fit procedure.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr25.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr26.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr27.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr28.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr29.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr30.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr31.gif]
 

Second, construct the Lagrange interpolation polynomial of degree n = 3.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr32.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr33.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr34.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr35.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr36.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr37.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr38.gif]
 

Third, construct the Lagrange interpolation polynomial of degree n = 4.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr39.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr40.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr41.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr42.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr43.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr44.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr45.gif]
 

Fourth, construct the Lagrange interpolation polynomial of degree n = 5.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr46.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr47.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr48.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr49.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr50.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr51.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr52.gif]
 
 

Exercise 3. Error Analysis. Investigate the error for the Lagrange polynomial approximations in Exercise 3.

[Graphics:la.txtgr9.gif][Graphics:la.txtgr53.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr54.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr55.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr56.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr57.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr58.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr59.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr60.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr61.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr62.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr63.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr64.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr65.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr66.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr67.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr68.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr69.gif]

[Graphics:la.txtgr9.gif][Graphics:la.txtgr70.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr71.gif]
[Graphics:la.txtgr9.gif][Graphics:la.txtgr72.gif]
 
 

Exercise 4. What is the maximum over the interval [0.0, 1.2] for each of the quantities

[Graphics:la.txtgr9.gif][Graphics:la.txtgr73.gif]
 
 

 

(c) John H. Mathews, 1998