计算方法实验报告三
一、实验名称: 用Chebyshev点插值
二、实验目的:
学会运用chebyshev点进行插值
三、实验内容及要求:
四、实验步骤(或记录)
clear;
n=[4,8,16,20];
for i=1:4
if i==1
for j=1:n(i)
x1(j)=cos((2*j-1)*pi/(2*n(i)));
end
y1=1./(1+25.*x1.^2);
elseif i==2
for j=1:n(i)
x2(j)=cos((2*j-1)*pi/(2*n(i)));
end
y2=1./(1+25.*x2.^2);
elseif i==3
for j=1:n(i)
x3(j)=cos((2*j-1)*pi/(2*n(i)));
end
y3=1./(1+25.*x3.^2);
elseif i==4
for j=1:n(i)
x4(j)=cos((2*j-1)*pi/(2*n(i)));
end
y4=1./(1+25.*x4.^2);
end
end
x5=-1:0.005:1;
y5=1./(1+25.*x5.^2);
plot(x1,y1,'g',x2,y2,'b',x3,y3,'r',x4,y4,'b',x5,y5,'y')
