Matlab #6 answers ------------- Problem 1 ----- --- part a) >> A=[1 0 4 2 6; 2 0 7 1 14; 2 0 6 -2 16; 1 0 3 -1 8]'; >> B = [1 0 4 2 6; 1 1 1 1 1]'; >> C = [1 0 4 2 6; 0 0 1 3 -2]; % Note that S is the columns space of A, T is the column space of B, % and W is the null space of C. % So we can find the dimensions of S, T, and W from the ranks of A, B, and C >> rank(A), rank(B), rank(C) ans = 2 ans = 2 ans = 2 % All have rank 2, so S and T both have dimension 2. % But W is the null space of C, so its dimension is the number of % columns of C minus the rank of C, 5-2 = 3, % So W has dimension 3. % Note that by page 381, Sperp and Tperp are the null spaces of A' and B', % so as above they have dimension 5 - rank, or 3 in both cases. % Again by page 381, Wperp is the column space of C' so its dimension % is the rank of C' which equals the rank of C which is 2. % To summarize, S, T, and Wperp have dimension 2 % and Sperp, Tperp, and W have dimension 3. ---- part b) % We'll need projection matrices to all six subspaces, % so let's calculate them first. >> projS = orth(A)*orth(A)' projS = 0.0176 0.0000 0.0730 0.0428 0.1008 0.0000 0.0000 0.0000 0.0000 -0.0000 0.0730 0.0000 0.3741 0.3917 0.2746 0.0428 0.0000 0.3917 0.7469 -0.1839 0.1008 -0.0000 0.2746 -0.1839 0.8615 >> projT = orth(B)*orth(B)' projT = 0.3103 0.3793 0.1034 0.2414 -0.0345 0.3793 0.4914 0.0431 0.2672 -0.1810 0.1034 0.0431 0.2845 0.1638 0.4052 0.2414 0.2672 0.1638 0.2155 0.1121 -0.0345 -0.1810 0.4052 0.1121 0.6983 % To project to W we need an orthonormal basis of W. % null(C) is a matrix whose columns are an orthonormal basis of % the null space of C which is W. >> projW = null(C)*null(C)' projW = 0.9824 -0.0000 -0.0730 -0.0428 -0.1008 -0.0000 1.0000 0 -0.0000 -0.0000 -0.0730 0 0.6259 -0.3917 -0.2746 -0.0428 -0.0000 -0.3917 0.2531 0.1839 -0.1008 -0.0000 -0.2746 0.1839 0.1385 % By page 381, null(A') and null(B') will be orthonormal bases % of Sperp and Tperp. >> projSperp = null(A')*null(A')' projSperp = 0.9824 -0.0000 -0.0730 -0.0428 -0.1008 -0.0000 1.0000 0.0000 -0.0000 -0.0000 -0.0730 0.0000 0.6259 -0.3917 -0.2746 -0.0428 -0.0000 -0.3917 0.2531 0.1839 -0.1008 -0.0000 -0.2746 0.1839 0.1385 >> projTperp = null(B')*null(B')' projTperp = 0.6897 -0.3793 -0.1034 -0.2414 0.0345 -0.3793 0.5086 -0.0431 -0.2672 0.1810 -0.1034 -0.0431 0.7155 -0.1638 -0.4052 -0.2414 -0.2672 -0.1638 0.7845 -0.1121 0.0345 0.1810 -0.4052 -0.1121 0.3017 % Again by page 381, the columns of orth(C') are a basis of Wperp. >> projWperp = orth(C')*orth(C')' projWperp = 0.0176 0 0.0730 0.0428 0.1008 0 0 0 0 0 0.0730 0 0.3741 0.3917 0.2746 0.0428 0 0.3917 0.7469 -0.1839 0.1008 0 0.2746 -0.1839 0.8615 % Now let us check containment. % If one subspace is contained in another but is not equal, % its dimension must be smaller. % So we only need check for equality of subspaces of the same dimension % and then check for containment of each 2 dimensional subspace % in each 3 dimensional subspace. % We also need not check if a subspace is contained % in its orthogonal complement, since a nonzero vector % can't be perpendicular to itself. % Checking for equality is easy, we can check for % equality of the projection matrices. % Looking at the upper left entry of the projection matrices % the only ones which are possibly equal are: % 1) projSperp and projW % 2) projWperp and projS % We can check for certain as follows: >> norm(projSperp-projW) ans = 4.4638e-16 >> norm(projWperp-projS) ans = 9.0638e-16 % So we conclude the only equal pairs of subspaces are W = Sperp and Wperp = S. % Now let's check for containment of the 2 dimensional subspaces S, T, Wperp % in the three dimensional subspaces Sperp, Tperp, and W. % I gave two methods for checking containment so I'll do this both ways. % The first way says the column space of D is contained in the null space of E % if and only if ED=0. % So to check if S is contained in W: >> norm(C*A) ans = 188.4749 % Since the norm of CA is not close to 0, we conclude S is not contained in W. % Now to see if T is contained in Sperp: >> norm(C*B) ans = 58.4831 % So T is not contained in W >> norm(A'*B) ans = 188.2921 % So T is not in Sperp >> norm(A'*C') ans = 188.4749 % So Wperp is not in Sperp >> norm(B'*A) ans = 188.2921 % So S is not in Tperp >> norm(B'*C') ans = 58.4831 % So Wperp is not in Tperp % So none of the 2 dimensional subspaces are contained in the 3 dimensional ones. % Now to do to the other way. >> norm(projW*A-A) ans = 25.8639 % So S is not in W >> norm(projW*B-B) ans = 7.7451 % so T is not in W >> norm(projSperp*B-B) ans = 7.7451 % So T is not in Sperp >> norm(projSperp*C'-C') ans = 7.5560 % So Wperp is not in Sperp >> norm(projTperp*A-A) ans = 24.7624 % So S is not in Tperp >> norm(projTperp*C'-C') ans = 7.5547 % So Wperp is not in Tperp % So to summarize, the only containments are in fact equalities: % 1) Sperp is contained in W % 1') W is contained in Sperp % 2) S is contained in Wperp % 2') Wperp is contained in S ------------------ part c) % As we saw in part b) the only equal subspaces are: % 1) W = Sperp % 2) S = Wperp ----------------- part d) >> projS+projSperp ans = 1.0000 -0.0000 0.0000 0.0000 -0.0000 -0.0000 1.0000 0.0000 -0.0000 -0.0000 0.0000 0.0000 1.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 1.0000 % This looks like the identity, so let's make sure. >> norm(ans-eye(5)) ans = 6.9698e-16 % Yes, it's the identity all right. >> projT+projTperp ans = 1.0000 0 0 0.0000 0.0000 0 1.0000 0 0 0.0000 0 0 1.0000 0.0000 -0.0000 0.0000 0 0.0000 1.0000 0.0000 0.0000 0.0000 -0.0000 0.0000 1.0000 >> norm (ans-eye(5)) ans = 1.4109e-16 >> projW+projWperp ans = 1.0000 -0.0000 0.0000 -0.0000 -0.0000 -0.0000 1.0000 0 -0.0000 -0.0000 0.0000 0 1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 1.0000 0.0000 -0.0000 -0.0000 -0.0000 0.0000 1.0000 >> norm(ans-eye(5)) ans = 4.5540e-16 % So in all three cases the sum of the projections is the identity. % So it is reasonable to conjecture that for any subspace U, % the projection to U plus the projection to Uperp is the identity. --------- part e) >> trace(projS), trace(projT), trace(projW) ans = 2.0000 ans = 2 ans = 3 % Note these results are the same as the dimension of the subspace. % So it is reasonable to conjecture that for any subspace U, % the trace of projection to U equals the dimension of U. % following is a check on the conjectures I gave in parts d and e, % for a random subspace. % The conjectures seem to be true for a random subspace of dimension 4. >> D = rand(5,4); >> norm(orth(D)*orth(D)'+null(D')*null(D')'-eye(5)) ans = 1.4257e-15 >> trace(orth(D)*orth(D)'), rank(D) ans = 4.0000 ans = 4 --------- Problem 2 % We can get a random 4x4 of rank 2 by multiplying a random 4x2 % with a random 2x4, as in matlab 4. >> A = (rand(4,2)+i*rand(4,2))*(rand(2,4)+i*rand(2,4)); >> rank(A) ans = 2 >> [Q R] = qr(A) Q = -0.1533 + 0.2718i 0.1073 + 0.1171i -0.8626 + 0.2320i -0.2530 - 0.1243i -0.1069 + 0.4918i -0.0602 + 0.5294i 0.2024 - 0.2309i -0.3371 + 0.5050i 0.2547 + 0.4829i -0.4725 + 0.2761i 0.0420 + 0.1110i 0.4580 - 0.4226i -0.2364 + 0.5434i 0.5459 - 0.3055i 0.2881 - 0.1037i -0.0639 - 0.3994i R = 2.1412 1.6415 + 0.2681i 1.0258 - 0.3072i 1.4899 - 0.0744i 0 0.4255 -0.3894 + 0.0047i -0.0344 + 0.4463i 0 0 0.0000 0.0000 - 0.0000i 0 0 0 0.0000 >> norm(A-Q*R) ans = 8.6779e-16 % So A essentially equals QR >> norm(Q*Q'-eye(4)) ans = 7.8777e-16 >> norm(Q'-inv(Q)) ans = 9.4144e-16 % Each of the above two tests shows that Q transpose % essentially equals Q inverse. % Since A = QR and only the first two rows of R are nonzero, % we know that each column of A is a linear combination of the % first two columns of Q. % For example, we see from R that the first column of A is % 2.1412 times the first column of Q. % The second column of A is 1.6415 + 0.2681i times the first column of Q % plus 0.4255 times the second column of Q. % And so forth for the other columns. % Consequently the first two columns of Q are a basis for the % columns space of A. % (To be more precise, the above argument shows that the span of the % first two columns of Q is contained in the column space of A. % But both these subspaces have dimension 2, so they are equal.) ----------------------------- For those who are curious, here is a sketch of a proof of the conjectures in part 1d and part 1e. Suppose {u_1,...,u_p} is an orthonormal basis of a subspace U, and {u_{p+1},...,u_n} is an orthonormal basis of its orthogonal complement Uperp. Then note that when combined, {u_1,...,u_n} is an orthonormal basis of R^n. By Thm 10 on page 399, projU(y) = (y . u_1)u_1 + ... + (y . u_p)u_p and projUperp(y) = (y . u_{p+1})u_{p+1} + ... + (y . u_n)u_n so projU(y) + projUperp(y) = (y . u_1)u_1 + ... + (y . u_n)u_n which equals y by Thm 5 on page 385. Thus projU(y) + projUperp(y) = Identity(y) for all y so projU + projUperp = Identity. If we let S = [u_1 u_2 ... u_n] then S^{-1}projU S = [e_1 ... e_p 0 0 ... 0] So we can then compute trace( S^{-1}projU S ) = p = dim U. But by problem 25 on page 334, we know similar matrices have the same trace, so trace( projU ) = p also. A second proof of this notes that if P = [u_1 ... u_p] then projU = P P' and so the i-th diagonal entry is the square of the length of the i-th row of P. But then the trace of P P' is the sum of the squares of the lengths of all the rows of P, which equals the sum of the squares of all the entries of P, which equals the sum of the squares of the lengths of the columns of P. But each column of P has length 1 and there are p columns. So the trace of P P' is p.