

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Datta; Class: Numerical Analysis; Subject: MATHEMATICAL SCIENCES; University: Northern Illinois University; Term: Spring 2009;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


function [P, Z] = lgrnintp (X, Y ),
where X and Y are vectors containing respectively x- and y-values, P is the vector containing the coefficients of the Lagrangian interpolating polynomial and Z is the vector containing values of the interpolating polynomial at the nontabulated points x = z.
Data for Problem 1
Presentation of Results The results should be presented in the following format:
TABLE 1: Results for Lagrangian Interpolation
P : The coefficient of the in- terpolation polynomial
z P (z) f (z) Error = f (z) − P (z)
Practice with MATLAB Functions
Y I = interp1(X, Y, Z, ‘method’ )
interpolates to find Y I at the values contained in the vector Z from a table of values of X and Y (X and Y are vectors containing the x- and y-values). The available methods are: nearest - nearest neighbor interpolation linear - linear interpolation spline - cubic spline interpolation cubic - cubic interpolation.
Using this function and each of the available methods, find the approximate values of both the functions cos x and e−x^ at the points contained in the vector Z of TABLE 1.
Compare the results with those obtained by Lagrangian method and write your observations.
x = 0 : 20; y = ex; xi = 0 : .50 : 10; yi = interp1 (x, y, xi); plot (x, y, ‘o’, xi, yi).