Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We proved in class that where Pn is the interpolating polynomial of f at the nod

ID: 3856164 • Letter: W

Question

We proved in class that where Pn is the interpolating polynomial of f at the nodes xo, , xn, P* is the best approximation of f, in the maximum (infinity) norm, by a polynomial of degree at most n, and An is the Lebesgue constant, i.e. An- |L"|0, where (a) Write a computer code to evaluate the Lebesgue function (2) associated to a given set of pairwise distinct nodes zo, .. . , Tn. (b) Consider the equidistributed points x,-1+j(2/n) for j - 0,... ,n. Write a com puter code that uses (a) to evaluate and plot Ln(x) (evaluate Ln(x) at a large number of points-k to have a good plotting resolution, c.g. xk =-1+ k(2/ne), k = 0, . . . , ne

Explanation / Answer

barylag.m % % Interpolates the given data using the Barycentric % Lagrange Interpolation formula. Vectorized to remove all loops % % data - a two column vector where column one contains the % nodes and column two contains the function value % at the nodes % p - interpolated data. Column one is just the % fine mesh x, and column two is interpolated data % % Reference: % % (1) Jean-Paul Berrut & Lloyd N. Trefethen, "Barycentric Lagrange % Interpolation" % http://web.comlab.ox.ac.uk/oucl/work/nick.trefethen/berrut.ps.gz % (2) Walter Gaustschi, "Numerical Analysis, An Introduction" (1997) pp. 94-95 % % % Written by: Greg von Winckel 03/07/04 % Contact: gregvw@chtm.unm.edu % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% M=length(data); N=length(x); % Compute the barycentric weights X=repmat(data(:,1),1,M); % matrix of weights W=repmat(1./prod(X-X.'+eye(M),1),N,1); % Get distances between nodes and interpolation points xdist=repmat(x,1,M)-repmat(data(:,1).',N,1); % Find all of the elements where the interpolation point is on a node [fixi,fixj]=find(xdist==0); % Use NaNs as a place-holder xdist(fixi,fixj)=NaN; H=W./xdist; % Compute the interpolated polynomial p=(H*data(:,2))./sum(H,2); % Replace NaNs with the given exact values. p(fixi)=data(fixj,2);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote