
function demorunge18

f=@(x) 1./(1+x.^2);
ff=chebfun(f,[-5,5]);

eequi =[ ] ;
echeb =[ ] ;
nn =1: 1: 100;
for n=nn
x = linspace ( -5 , 5 , n+1) ;
p = chebfun.interp1 (x, ff(x)) ; % Interpolante di grado n (nodi equi.).
fc = chebfun (ff, n+1); % Interpolante di grado n (nodi cheb.).
eequi=[ eequi norm( ff-p , inf ) ] ;
echeb=[ echeb norm( ff-fc , inf ) ] ;
fprintf('\n \t $%3.0f$ & $%1.3e$ & $%1.3e$',n,eequi(end),echeb(end));
end




clf ;
figure(1);
semilogy ( nn , eequi ,'r-') ;

figure(2);
semilogy ( nn , echeb ,'r-') ;





