Question
Please help me solve this. #4 a&b. thanks

media%2F262%2F262dcc61-f064-44af-b4a2-a1
eilymai retine, or you m yur ova rodinT ur pl nda listing of your code. (b) Repeat part (a) with a polynomial of degree 12 th
points other than the interpolation points in the interval [-5, 5]. Turn in your plot and a listing of your code.

eilymai retine, or you m yur ova rodinT ur pl nda listing of your code. (b) Repeat part (a) with a polynomial of degree 12 that interpolates f at 13 scaled Chebyshev points, x 5 cos 12 Again you may use MATLAB's polyfit and polyval routines to fit the polyno- mial to the function at these points and evaluate the result at points throughout the interval, or you may use the barycentric interpolation formula (8.6) with weights defined by (8.5) or (8.16) to evaluate the interpolation polynomial at
points other than the interpolation points in the interval [-5, 5]. Turn in your plot and a listing of your code.
0 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code for answering question 4a. and 4b. clear all close all %function for which interpolation have to do 13 equally spPlotting for Runge function equally spaced point O Actual data 3-1 -2 Plotting for Runge function Chebyshev points O Actual d

%%Matlab code for answering question 4a. and 4b.
clear all
close all
%function for which interpolation have to do
f=@(x) 1./(1+x.^2);

%13 equally spaced points between -5 to 5
xx=[-5:5/6:5];
yy=f(xx);
%12th degree polynomial coefficients
p = polyfit(xx,yy,12);

%polyval code
x1 = linspace(-5,5,1001);
y1 = polyval(p,x1);
figure(1)
plot(xx,yy,'ro')
hold on
plot(x1,y1,'linewidth',2)
hold off

title('Plotting for Runge function equally spaced point')
xlabel('x')
ylabel('f(x)')
legend('Actual data','polynomial fit')

%13 Chebyshev points between -5 to 5
for j=1:13
  
    xx(j)=5*cos(pi*(j-1)/12);
  
end
yy=f(xx);
%12th degree polynomial coefficients
p = polyfit(xx,yy,12);

%polyval code
x1 = linspace(-5,5,1001);
y1 = polyval(p,x1);
figure(2)
plot(xx,yy,'ro')
hold on
plot(x1,y1,'linewidth',2)
hold off

title('Plotting for Runge function Chebyshev points')
xlabel('x')
ylabel('f(x)')
legend('Actual data','polynomial fit')


%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
Eilymai retine, or you m yur ova rodinT ur pl nda listing of your code. (b) Repeat part (a) with ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT