function x = backsubs(R,b)
% BACKSUBS Substitution inverse 

[m,~] = size(R);
x = zeros(m,1);

for j = m:-1:1
    xr = R(j,(j+1):m)*x((j+1):m);
    x(j) = (b(j)-xr)/R(j,j);
end