function x = GEdemo(A,b,prec,ptol) % GEshow Show steps in Gauss elimination and back substitution % No pivoting is used. % % Synopsis: x = GEshow(A,b) % x = GEshow(A,b,ptol) % % Input: A,b = coefficient matrix and right hand side vector % prec = number of sig dig precision arithmetic used % ptol = (optional) tolerance for detection of zero pivot % Default: ptol = 50*eps % % Output: x = solution vector, if solution exists if nargin<4, ptol = 50*eps; end [m,n] = size(A); if m~=n, error('A matrix needs to be square'); end nb = n+1; Ab = [A b]; % Augmented system fprintf('\nBegin forward elmination with Augmented system:\n'); disp(Ab); % --- Elimination for i = 1:n-1 % loop over pivot rows pivot = chop(Ab(i,i),prec); if abs(pivot)