function l = lagrange( x, y, x2 )

[~, n] = size(x);
l = 0;
for i = 1:n
    nevezo = prod(ones(1, n-1) * x(i) - [ x(1:i-1), x(i+1:end)]);
    szamlalo = prod(ones(1, n-1) * x2 - [ x(1:i-1), x(i+1:end)]);
    l = l + szamlalo * y(i) / nevezo;
end

end

