%% Fenomeno de Runge clear clc y = @(x) 1./(1+25*x.^2); vec = linspace(-1,1,1000)'; enes = [2 3 5 8 10 12 15 19 23]; for n = enes x = linspace(-1,1,n); % x = -cos(pi*(x+1)/2); pol = interpolante(x,y(x),vec); plot(x,y(x),'ok', 'MarkerSize', 8,'MarkerFaceColor', 'k') hold on plot(vec, y(vec),'-k', 'LineWidth', 2); plot(vec,pol,'-r', 'LineWidth', 2) axis([-1 1 -0.5 1.5]) title(['n = ', num2str(n)], 'FontSize',14); hold off pause close all end