function x = backsubs(U, b)
%BACKSUBS. Back substitution.
% For upper triangular U, x = backsubs(U, b) solves U*x = b.
    [~, n] = size(U);
    x = zeros(n,1);
	for k = n:-1:1
		j = k+1:n;
		x(k) = (b(k) - U(k,j)*x(j))/U(k,k);
	end
end
