function []=matfact() %Computation done in class %type matfact at a MATLAB command prompt after %insuring that matfact.m is in the MATLAB path... P=[[1,0,0];[0,0,1];[0,1,0]] L=[[1,0,0];[-2,4,0];[-8,-4,2]] U=[[1,-3,-6];[0,8,-7];[0,0,3]] fprintf('%s\n','Next set A=P*L*U'); A=P*L*U b=[10;2;4] fprintf('\n\n%s\n','Now to solve Ax=b'); fprintf('%s\n','we whould observe that A factors'); fprintf('%s\n','as P *L *U'); fprintf('%s\n', 'so solve Ly =P^(-1)b)') y=L^(-1)*P*b x=U^(-1)*y fprintf('%s\n','Check:'); b A*x