% Matlab diary from cs111, Oct 8 2007. % % This is what I typed in class. % % Type it into Matlab yourself to % reproduce the output I showed. diary on x = 49 \ 147 x = 147 / 49 A = [10 -7 0 ; -3 2 6 ; 5 -1 5] b = [7 ; 4 ; 6] 49 \ 147 (1/49) * 147 ans ans - 3 1/49 format long 1/49 A b x = A \ b A * x - b B = inv(A) xx = B * b x xx - x A * xx - b A \ b A b A(2,3) A(2,:) A(2,:) = A(2,:) - (-3/10) * A(1,:) format short A b(2) = b(2) - (-3/10) * b(1) A(3,:) = A(3,:) - (5/10) * A(1,:) b(3) = b(3) - (5/10) * b(1) A \ b A A(3,:) = A(3,:) - (-25) * A(2,:) b(3) = b(3) - (-25) * b(2) x3 = b(3) / A(3,3) x2 = (b(2) - A(2,3) * x3 ) / A(2,2) x1 = (b(1) - (-7)*x2 - 0*x3 ) / A(1,1) x = [x1; x2; x3] A * x - b U = A L = [ 1 0 0 ; -3/10 1 0 ; 5/10 -25 1 ] A = [10 -7 0 ; -3 2 6 ; 5 -1 5] L * U A = [4 4 2 ; 2 2 2 ; 1 0 1] b = [10 ; 6 ; 2 ] A \ b det(A) A(2,:) = A(2,:) - (1/2) * A(1,:) A(3,:) = A(3,:) - (1/4) * A(1,:) A= rand(3) P = eye(3) P * A P = [0 1 0 ; 1 0 0 ; 0 0 1] A P*A A A * P diary off