Reference no: EM132400657
COMP 350 Numerical Computing Assignment - McGill University, Canada
Assignment - Polynomial Interpolation, Spline Interpolation, and Least Squares Approximation
Q1. Use your hand to find the Vandermonde form, the Lagrange form, and the Newton form of the interpolating polynomial for these data
Q2. (Programming by MATLAB) Let f(x) = 1/(1 + 25x2).
(a) Using 7 equally spaced nodes (or knots) on the interval [-1, 1],
i. Find the interpolating polynomial p(x) of degree 6 for f(x) by the Newton approach.
ii. Find the natural cubic spline function S(x) to interpolate f(x).
iii. Find the function g(x) = a + bx2 + cx4 to approximate f(x) by the least squares method.
Print the coefficients of p(x), S(x) and g(x).
Print the four values f(x), f(x) - p(x), f(x) - S(x), and f(x) - g(x) at 13 equally spaced points xi = -1 + (1/6)i for i = 0, 1, . . . , 12.
Plot y = f(x), y = p(x), y = S(x) and y = g(x) on the same plot.
In additional to submitting your MATLAB programs, please put them in a PDF file so that it will be easy for the TA to read (note that the TA may or may not run your MATLAB programs).
(b) Using 7 Chebyshev nodes
xi = cos((2i+1/2n+2)π), i = 0, 1, . . . , n, n = 6
to do the same things as in (a).
(c) Comparing the two plots obtained in (a) and (b), what do you observe?
Note: You are not allowed to use MATLAB built-in functions polyfit, polyval, and spline.