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

4. Using the MATLAB command Uniform vs.Chebyshev Interp on the Math Linux networ

ID: 3283256 • Letter: 4

Question

4. Using the MATLAB command Uniform vs.Chebyshev Interp on the Math Linux network, report on the maximum absolute error in polynomial interpolation for the function f(x) = 1/(1 +r2) on the interval 5,5], for the equidistant (uniform, evenly spaced) nodes and the Chebyshev nodes, for n 5, 15, 25, 35, i.e., report on (4) Report on the value obtained with Chebyshev points for n-25. Which subdivision is best (equidistant or Chebyshev)? (4) )1.49 10-2, (2)1.441 102 (3)1.39 102, (4) 1.341 102, (5) 1.292, (6124 0-2, (7) 1.191 102, (8) 1.141 02, (9) .091 102, (10 1.04 102

Explanation / Answer

function [] = lagranges_interpolation ()
a=[5,10,20];
error=[];
for i=a
error=[error,lagranges(i,-5,5)];
end
plot(a,error);
end


function [error]=lagranges(N,x1,x2)
i=x2-x1/N;
a=x1:i:x2;
dim=size(a);
y=(1)./(1+a.^2);
approx=zeros(1,dim(2));
k=0;
for i=1:dim(2)
approx(i)=ind_lag(a,a(i));
end
  
error=sqrt(sum((approx-y).^2))/dim(2);
end

function [approx]=ind_lag(a,x)
sum=0;
for i=1:size(a)
mult=1;
for j=1:size(a)
if(i!=j)
buf=(x-a(j))/(a(i)-a(j));
mult=mult*buf;
end

end
sum=sum+mult;
end
approx=sum;
end

%yes the approximation gets better with increase in number of points

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