![]()
![]()
Lab for Lagrange Polynomial Approximation
![]()
Background. The
Lagrange polynomial of degree n passes through the n+1 points
for
.
Algorithm for the Lagrange
Polynomial. To construct the Lagrange polynomial
![]()
of degree n, based on the n+1 points
for
.
The Lagrange coefficient polynomials for degree n are:
for
.
Use the following Mathematica subroutine.
Load in Mathematica's graphics package "Colors".
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.txtgr14.gif]](la.txtgr14.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.txtgr19.gif]](la.txtgr19.gif)
Notice that the two polynomials of degree n = 1 were different.
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.
Compare with Mathematica's Fit procedure.
![]()
![[Graphics:la.txtgr28.gif]](la.txtgr28.gif)
Second, construct the Lagrange interpolation polynomial of degree n = 3.
![]()
![[Graphics:la.txtgr35.gif]](la.txtgr35.gif)
Third, construct the Lagrange interpolation polynomial of degree n = 4.
![]()
![[Graphics:la.txtgr42.gif]](la.txtgr42.gif)
Fourth, construct the Lagrange interpolation polynomial of degree n = 5.
![]()
![[Graphics:la.txtgr49.gif]](la.txtgr49.gif)
Exercise 3. Error Analysis. Investigate the error for the Lagrange polynomial approximations in Exercise 3.
![]()
![[Graphics:la.txtgr54.gif]](la.txtgr54.gif)
![]()
![[Graphics:la.txtgr59.gif]](la.txtgr59.gif)
![]()
![[Graphics:la.txtgr64.gif]](la.txtgr64.gif)
![]()
![[Graphics:la.txtgr69.gif]](la.txtgr69.gif)
Exercise 4. What is the maximum over the interval [0.0, 1.2] for each of the quantities
![]()
![]()
(c) John H. Mathews, 1998