< M A T L A B > Copyright 1984-2003 The MathWorks, Inc. Version 6.5.1.200223 Release 13 (Service Pack 1) Aug 22 2003 To get started, select "MATLAB Help" from the Help menu. >> rand('state',sum(100*clock)); ---- problem 1 >> rank(rand(6,8)) ans = 6 >> rank(rand(7,5)) ans = 5 >> rank(rand(9,9)) ans = 9 % All the ranks are as expected, the minimum of the number of rows and columns. --- Problem 2 >> A=rand(6,3)*rand(3,8); >> rank(A) ans = 3 % So the rank of A is 3 >> B=null(A) B = 0.6845 0.1032 -0.1111 -0.0148 0.2647 0.2940 0.0603 0.0653 -0.2275 -0.3411 -0.2829 -0.1102 0.5852 -0.3906 -0.0029 -0.2879 0.7081 0.1231 0.3004 -0.3658 -0.0988 -0.4776 -0.4303 0.0374 -0.6546 -0.1477 -0.4882 0.3672 0.4600 0.1955 0.0188 0.0269 -0.1049 0.6647 0.1060 -0.5002 0.0710 -0.5429 -0.2243 0.4494 % The columns of B are supposed to be basis of the Null space of A. % Let's check to see if they are. >> norm(A*B) ans = 9.3065e-16 % So we see that AB is essentially 0. % Let b1,...,b5 denote the columns of B. % Then AB = A[b1 b2 b3 b4 b5] = [Ab1 Ab2 Ab3 Ab4 Ab5]. % So each Abi is essentially zero, so each bi is in the Null space of A. >> rref(B) ans = 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 % Since there is a pivot in each column, we know {b1,b2,b3,b4,b5} % is a linearly independent set. % By Theorem 14, page 265 we know dim Nul(A) = 8 - rank(A) = 5. % So by Theorem 12, page 259 we know {b1,b2,b3,b4,b5} is a basis of the null space of A. ---- Problem 3 -- part a) % Just for the heck of it, I generate a matrix with integer entries. >> A=randint(6,4)*randint(4,7); >> B=rref(A) B = 0 1 0 0 1 0 1 0 0 1 0 -1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 % So we see the pivot columns are 2, 3, 4, and 6. % Thus C is formed from the second, third, fourth and sixth columns of A, % and the columns of C give a basis for the column space of A. >> C=A(:,[2 3 4 6]) C = 2 1 0 2 1 0 0 1 2 1 0 2 1 0 0 0 3 1 1 2 0 0 0 0 % Have matlab find a basis for the null space of A. >> N=null(A); % We get a basis for Row(A) by taking the pivot rows in rref(A) % (but not the pivot rows of A, a common mistake). >> R=B(1:4,:); ---- part b) >> M=null(A'); >> S=[R' N]; >> T=[C M]; % So let us see why we should always expect S and T to be square matrices. % If A is any m x n matrix with rank r, then the column space and row space of A % are both r dimensional. Thus C is m x r and R is r x n. % We also know the null space of A is n-r dimensional so N is n x (n-r). % So S has n rows and r + (n-r) = n columns, so S is square. % Now rank(A')=rank(A)=r so M has m-r columns. % So T has m rows and r + (m-r) = m columns, so T is square. % We use two different methods to check that S and T are invertible. % One way is to check that rank(S) = number of rows of S = number of columns of S. % The second way is to again note that S is square, find the inverse matrix inv(S), % and to make double sure, check that S*inv(S) is essentially the identity. >> size(S), rank(S), norm(S*inv(S)-eye(7)) ans = 7 7 ans = 7 % S is a 7x7 matrix with rank 7 so it is invertible. ans = 2.6273e-16 % Matlab calculates inv(S) and checks that S*inv(S) essentially equals the identity. >> size(T), rank(T), norm(T*inv(T)-eye(6)) ans = 6 6 ans = 6 % T is a 6x6 matrix of rank 6 so it is invertible. ans = 2.8735e-16 % Matlab calculates inv(T) and checks that T*inv(T) essentially equals the identity.