n=12;               % GRADO.
x=-5:10/n:5; x=x';        % NODI INTERP. (EQUISPAZ.).
y=runge(x);         % FUNZIONE NEI NODI EQUISP.
s=-5:10/(2000*n):5; s=s';   % NODI TEST.  
t=barylag([x y],s);  % INTERPOLANTE NEI NODI TEST.

xcheb=cheb(-5,5,n+1); xcheb=xcheb'; % NODI CHEB.
ycheb=runge(xcheb); % FUNZIONE NEI NODI CHEB.
tcheb=barylag([xcheb ycheb],s);  % INTP. CHEB.

plot(s,runge(s),s,t,s,tcheb);   % PLOT INTP. VS RUNGE.
legend('Runge','Equisp.','Gauss-Cheb-Lob.');
pause;
semilogy(s,abs(runge(s)-t),s,abs(runge(s)-tcheb))
legend('Equisp.','Gauss-Cheb-Lob.');
err_eqs=norm(runge(s)-t,inf);     % ABS. ERR. EQUISPAZ.
err_cheb=norm(runge(s)-tcheb,inf); % ABS. ERR. CHEB.
fprintf('\n \t [ABS.ERR.][EQS]: %2.2e [CHEB]: %2.2e',err_eqs,err_cheb);

fprintf('\n \t [EQS]: %6.0f [CHEB]: %6.0f',length(x),length(xcheb));