y=atan(x);
%formthedifferencestable
forj=2:n,
y(1:n+1-j,j)=diff(y(1:n+2-j,j-1))/((j-1)*h);end
%newtoncoeff
y=y(1,:);formatlonge
fprintf(’\nthecoefficientsofNewtoninterpolationis:\n\n’);fprintf(’%12.9f’,y);pz=[];
v=linspace(0,8,33);fort=v,
z=y(n);
forj=n-1:-1:1,
z=z*(t-x(j))+y(j);end
pz=[pzz];end
plot(v,pz,’g*-’,v,atan(v),’b+:’);fprintf(’\nxip(xi)atan(xi)error\n’);forj=1:length(v),
fprintf(’%12.6f%12.6f%12.6f%12.6f\n’,...
v(j),pz(j),atan(v(j)),abs(pz(j)-atan(v(j))));
end
[1,6]
arctanx
:
2.
2-16
17