%Minimalist elimination routine for augmented matrix

function x = gsolve(A,b)
    n=size(A,1);
    for k=1:(n-1)
        for i=(k+1):n
            for j=(k+1):n
                A(i,j)=A(i,j)-(A(i,k)/A(k,k))*A(k,j);
            end;
            b(i)=b(i)-(A(i,k)/A(k,k))*b(k);
        end;
    end;
    x=zeros(n,1);
    x(n)=b(n)/A(n,n);
    for i=(n-1):-1:1
        sumAx=0;
        for j=(i+1):n
            sumAx=sumAx+A(i,j)*x(j);
        end;
        x(i)=(b(i)-sumAx)/A(i,i);
    end;
end