%section 8.1 computer problem #11

A = [1,0,0,0;3,1,0,0;5,2,1,0;7,4,-3,1];
A = [A,eye(4)];

[m,n] = size(A);       %A is m by n

%forward elimination

for k=1:m-1
    for i=k+1:m
        c = A(i,k)/A(k,k);   %c = multiple of row k to subtract from row i
        for j=k:n
            A(i,j) = A(i,j)-c*A(k,j);
        end
    end
end

disp('the inverse of A is the right half of this augmented matrix...')
A