function Pols = LagrangePolynomialBasis(nodes)

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

n = length(nodes);
Pols = cell(n,1);
for i = 1:n
	nodes_nr = setdiff(1:n,i);
	Pols{i} = [1 / (nodes(i) - nodes(nodes_nr(1))); -nodes(nodes_nr(1)) / (nodes(i) - nodes(nodes_nr(1)))]';
	if n > 2
		for j = 2:(n - 1)
			Pols{i} = conv(Pols{i},[1 / (nodes(i) - nodes(nodes_nr(j))); -nodes(nodes_nr(j)) / (nodes(i) - nodes(nodes_nr(j)))]');
		end
	end	
end

end
