% Lagrangen 2. asteen polynomit
%
X=[-1 0 1];
x=linspace(-1,1);
L0=(x-X(2)).*(x-X(3))/((X(1)-X(2))*(X(1)-X(3)));
L1=(x-X(1)).*(x-X(3))/((X(2)-X(1))*(X(2)-X(3)));
L2=(x-X(1)).*(x-X(2))/((X(3)-X(1))*(X(3)-X(2)));
plot(x,L0,'r',x,L1,'k',x,L2,'b')
grid on
legend('L_0','L_1','L_2')
