% preg. 2, lab. 6, 521230, S2-2013

% interpolar a f(x) = ln(x) en 1,2,3
x = [1 2 3];
y = log(x);

% funcion, polinomio, puntos de interpolacion
xplot = linspace(1,3);
plot(x,y,'o');
hold on
plot(xplot,log(xplot));
p2 = polyfit(x,y,2);
plot(xplot,polyval(p2,xplot),'r');

% error y cota error
figure(2)
i = 0:100;
xplot = 1+i*(1/50);
plot(xplot,abs(log(xplot)-polyval(p2,xplot)));
hold on
% cota error
plot(xplot,(2/6)*abs((xplot-1).*(xplot-2).*(xplot-3)),'r');
