data_605_hw3

HW3

(1) What is the rank of the matrix A?

\[ A = \begin{bmatrix} 1 & 2 & 3 & 4 \\ -1 & 0 & 1 & 3 \\ 0 & 1 & -2 & 1 \\ 5 & 4 & -2 & -3 \end{bmatrix} \] The number of linearly independent rows or linearly independent columns in a matrix define the rank of a matrix. See this excellent tutorial from 3Blue1Brown, https://www.youtube.com/watch?v=uQhTuRlWMxw

A <- matrix(c(1, 2, 3, 4,
              -1, 0, 1, 3,
              0, 1, -2, 1, 
              5, 4, -2, -3), 
            nrow = 4,
            byrow = TRUE)

A
##      [,1] [,2] [,3] [,4]
## [1,]    1    2    3    4
## [2,]   -1    0    1    3
## [3,]    0    1   -2    1
## [4,]    5    4   -2   -3
pracma::rref(A)
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    0    0
## [2,]    0    1    0    0
## [3,]    0    0    1    0
## [4,]    0    0    0    1
print(paste0("Matrix A has a rank of ", base::qr(A)$rank))
## [1] "Matrix A has a rank of 4"

We see that there are 4 pivot columns in the reduced row echelon form of the matrix. In addition, we can directly apply the QR decomposition to find the rank of a matrix. In this case, matrix A has a rank of 4.

(2) Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?

Since the rank is the number of linearly independent rows or linearly independent columns, the maximum rank cannot be larger than the number of columns, thus the maximum would be n. If this is a non-zero matrix, the minimum rank would be 1.

(3) What is the rank of the matrix B?

\[ B = \begin{bmatrix} 1 & 2 & 1 \\ 3 & 6 & 3 \\ 2 & 4 & 2 \end{bmatrix} \]

B <- matrix(c(1, 2, 1,
              3, 6, 3,
              2, 4, 2), 
            nrow = 3,
            byrow = TRUE)

B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
pracma::rref(B)
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    0    0    0
print(paste0("Matrix B has a rank of ", base::qr(B)$rank))
## [1] "Matrix B has a rank of 1"

Matrix B has a rank of 1 since the reduced row echelon form has only one pivot column.

(4) Compute the eigenvalues and eigenvectors of the matrix A.

\[ A = \begin{bmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{bmatrix} \] We need to simplify the determinant and solve for lambda to find the characteristic polynomial.

\[ det(A-\lambda I)=0 \]

\[ |A - \lambda I | = \left | \begin{bmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\0 & 0 & 6\end{bmatrix} - \lambda \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \right | \]

\[ |A - \lambda I| = \left | \begin{bmatrix} 1-\lambda & 2 & 3 \\ 0 & 4 -\lambda & 5 \\ 0 & 0 & 6 -\lambda \end{bmatrix} \right| \]

\[ det( \begin{bmatrix} 1-\lambda & 2 & 3 \\ 0 & 4 -\lambda & 5 \\ 0 & 0 & 6 -\lambda \end{bmatrix} ) = 0 \] Compute a determinant for a 3x3 matrix:

\[ (1- \lambda)((4- \lambda)(6-\lambda))+2(0-0)+3(0-0)=0\\ \] \[ (1-\lambda)(4-\lambda)(6-\lambda) = 0 \] The eigenvalues are therefore 1, 4, 6. Let’s continue to find the characteristic polynomial.

\[ (1 - \lambda)\Big[24-10\lambda+\lambda^2\Big] = 0 \] \[ 24 -10\lambda + \lambda^2 -24\lambda +10\lambda^2 - \lambda^3 = 0 \]

\[ \lambda^3 - 11\lambda^2 +34\lambda - 24 = 0 \] We can verify above result by using pracma::charpoly()

A <- matrix(c(1, 2, 3,
              0, 4, 5,
              0, 0, 6), 
            ncol = 3, 
            byrow = TRUE)

pracma::charpoly(A)
## [1]   1 -11  34 -24

We can also verify the eigenvalues by using base::eigen()

base::eigen(A, symmetric = FALSE)$values     
## [1] 6 4 1

We can compute the eigenvectors of matrix A by plugging each eigenvalue back into the equation.

\[ A-\lambda I = 0 \] \[ A-1I\\ \begin{bmatrix} 1-1 & 2 & 3 \\ 0 & 4-1 & 5 \\ 0 & 0 & 6-1 \end{bmatrix}\\ \]

After the row reduction process, we end up getting the eigenvector of [1, 0, 0] for lambda equal to 1

\[ v_1 = \begin{bmatrix}1\\0\\0\\\end{bmatrix} \] Similarly for lambda equal to 4 and 6,

\[ A-4I\\ \begin{bmatrix} 1-4 & 2 & 3 \\ 0 & 4-4 & 5 \\ 0 & 0 & 6-4 \end{bmatrix}\\ \]

\[ A-6I\\ \begin{bmatrix} 1-6 & 2 & 3 \\ 0 & 4-6 & 5 \\ 0 & 0 & 6-6 \end{bmatrix}\\ \] We get

\[ v_4 = \begin{bmatrix}\frac{2}{3}\\1\\0\end{bmatrix} \]

\[ v_6 = \begin{bmatrix}1.6 \\ 2.5 \\ 1 \end{bmatrix} \]

Above results can be easily obtained by using base::eigen()

base::eigen(A, symmetric = FALSE)$vector
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0

Note that the eigenvalues are always returned in decreasing order, and each column of vectors corresponds to the elements in values. In this case, it would be 6, 4, 1.