function Pol = LagrangePolynomial(nodes, values)

% computes the Lagrange interpolating polynomial on the given set of nodes for given function values

Pols = LagrangePolynomialBasis(nodes);
Pol = values(1) * Pols{1} + values(2) * Pols{2};
n = length(nodes);
if n > 2
	for i = 3:n
		Pol = Pol + values(i) * Pols{i};
	end
end

end