Ch 2-2 the rank of a matrix 在看習題解答前,建議先觀看Ch2的教學 習題目錄:


Problem 3 For the given matrix below, find (a) the rank of the matrix, (b) a basis for the row space, (c) a basis for the column space, and (d) a basis for the nullspace. $$\begin{bmatrix} 0&6&6&3\\ 1&2&1&1\\ 4&1&-3&4\\ 1&3&2&0 \end{bmatrix}$$
輸入
            
                A = [0, 6, 6, 3; 1, 2, 1, 1;4, 1, -3, 4; 1, 3, 2, 0]
                rank( A )
                rref( A )
                null( A )
            
        
輸出結果
            
                A =

                    0   6   6   3
                    1   2   1   1
                    4   1  -3   4
                    1   3   2   0

                ans = 3

                ans =

                    1   0  -1   0
                    0   1   1   0
                    0   0   0   1
                    0   0   0   0

                ans =

                    -5.7735e-01
                     5.7735e-01
                    -5.7735e-01
                    -4.9960e-16
            
        
(a) 由 rank(A) = 3 ,我們可知 the rank of the matrix 為 3 。

(b) 由 rref( A ) 的結果,a basis for the row space 就直接取rref(A)中非零向量的row vectors就好,所以有一組是 $\{[1, 0, -1, 0], [0, 1, 1, 0], [0, 0, 0, 1]\}$

(c) 由 rref( A ) 的結果,a basis for the column space 就看rref(A)中pivot在哪幾個column,然後取對應的A中的column vectors即可。

(d) 由 rref( A ) 的結果,計算出結果。 或是因為觀察到null(A)的向量有個關係,前三項的值幾乎一樣,差個正負號而已, 第四項幾乎是0,所以猜測一下,代回驗證可得 $\begin{bmatrix}1\\-1\\1\\0\end{bmatrix}$

這裡順便幫大家回憶一下,如果想要取這些向量,該如何著手。
            
                R=rref( A );
                display("basis of the row space")
                R(1,:)
                R(2,:)
                R(3,:)
                display("basis of the column space")
                A(:,1)
                A(:,2)
                A(:,4)
                a = null(A);
                display("basis of the nullspace")
                null(A) / a(1)
                display("check")
                n=[1; -1; 1; 0]
                A*n
            
        
輸出結果
            
                basis of the row space
                ans =

                    1   0  -1   0

                ans =

                    0   1   1   0

                ans =

                    0   0   0   1

                basis of the column space
                ans =

                    0
                    1
                    4
                    1

                ans =

                    6
                    2
                    1
                    3

                ans =

                    3
                    1
                    4
                    0

                basis of the nullspace
                ans =

                     1.0000e+00
                    -1.0000e+00
                     1.0000e+00
                     8.6533e-16

                check
                n =

                     1
                    -1
                     1
                     0

                ans =

                    0
                    0
                    0
                    0
            
        

Problem 7 Determine whether the given matrix is invertible, by finding its rank. $$\begin{bmatrix} 0&-9&-9& 2\\ 1& 2& 1& 1\\ 4& 1&-3& 4\\ 1& 3& 2& 0 \end{bmatrix}$$
輸入
            
                A = [0, -9, -9, 2;1, 2, 1, 1;4, 1, -3, 4;1, 3, 2, 0]
                rank( A )
                inv( A )
            
        
輸出結果
            
                A =

                    0         -9         -9          2
                    1          2          1          1
                    4          1         -3          4
                    1          3          2          0

                ans = 3

                warning: matrix singular to machine precision, rcond = 1.4803e-17
                ans =

                    *          *          *          *
                    *          *          *          *
                    *          *          *          *
                   1/14       12/7      -3/14       -6/7
            
        
因為矩陣是$4 \times 4$的,第一個ans告知我們矩陣的rank為$3 \neq 4$,所以此矩陣沒有inverse matrix。 後面第二個答案前面的warming也告知了此矩陣是 singular的。