library(matrixcalc)
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
matrix.rank(A)
## [1] 4
For an mxn matrix where m > n, the maximum rank is limited by the number of columns (n), while the minimum rank, provided the matrix is non-zero, stands at 1, reflecting the presence of at least one linearly independent row or column.
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
Here, We are using the qr() function to compute the rank
of matrix B, allowing us to access the rank value from the result of
qr(B)$rank.
rank_B <- qr(B)$rank
cat("Rank of matrix B:", rank_B, "\n")
## Rank of matrix B: 1
Problem Set 2 Compute the eigenvalues and eigenvectors of the matrix A. You’ll need to show your work. You’ll need to write out the characteristic polynomial and show your solution \[ A = \begin{pmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \\ \end{pmatrix} \]
To determine the eigenvalues and eigenvectors of matrix \(A\), we start by computing its characteristic polynomial.
The given matrix \(A\) is:
\[ A = \begin{pmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{pmatrix} \]
We find the characteristic polynomial by solving the equation:
\[ \text{det}(A - \lambda I) = 0 \]
where \(\lambda\) represents the eigenvalue, \(A\) is the matrix, and \(I\) is the identity matrix.
Substituting \(A\) into the characteristic polynomial equation, we obtain:
\[ \text{det}\left( \begin{pmatrix} 1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda \end{pmatrix} \right) = 0 \]
Expanding the determinant, we get:
\[ (1-\lambda)(4-\lambda)(6-\lambda) = 0 \]
Solving this equation yields the eigenvalues \(\lambda\):
\[ \lambda_1 = 1, \quad \lambda_2 = 4, \quad \lambda_3 = 6 \]
These are the eigenvalues of matrix \(A\).
Next, we find the corresponding eigenvectors by substituting each eigenvalue into the equation \((A - \lambda I) \mathbf{v} = \mathbf{0}\), where \(\mathbf{v}\) is the eigenvector.
For \(\lambda_1 = 1\), we have:
\[ (A - \lambda_1 I) \mathbf{v}_1 = \mathbf{0} \]
\[ \begin{pmatrix} 0 & 2 & 3 \\ 0 & 3 & 5 \\ 0 & 0 & 5 \end{pmatrix} \mathbf{v}_1 = \mathbf{0} \]
From this equation, the corresponding eigenvector \(\mathbf{v}_1\) for \(\lambda_1 = 1\) is \(\begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix}\).
Similarly, for \(\lambda_2 = 4\) and \(\lambda_3 = 6\), we find the respective eigenvectors.
Therefore, the eigenvalues of matrix \(A\) are \(\lambda_1 = 1\), \(\lambda_2 = 4\), \(\lambda_3 = 6\), and their corresponding eigenvectors are \(\mathbf{v}_1 = \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix}\), \(\mathbf{v}_2 = \begin{pmatrix} 0 \\ 5 \\ -5 \end{pmatrix}\), and \(\mathbf{v}_3 = \begin{pmatrix} 2 \\ -3 \\ 1 \end{pmatrix}\) respectively.