knitr::opts_chunk$set(echo = TRUE)
The rank of the matrix A is 4. It is a linearly independent matrix.
library(Matrix)
A <- matrix(c(1, -1, 0, 5, 2, 0, 1, 4, 3, 1, -2, -1, 4, 3, 1, -3), nrow = 4)
A
## [,1] [,2] [,3] [,4]
## [1,] 1 2 3 4
## [2,] -1 0 1 3
## [3,] 0 1 -2 1
## [4,] 5 4 -1 -3
rankMatrix(A)
## [1] 4
## attr(,"method")
## [1] "tolNorm2"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 8.881784e-16
The maximum rank is the minimum of m and n, since m > n, the maximum rank is n. The minimum rank for a non-zero matrix is 1.
The rank of matrix B is 1, as matrix B is not a linearly independent matrix.
B <- matrix(c(1, 3, 2, 2, 6, 4, 1, 3, 2), nrow = 3)
B
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
rankMatrix(B)
## [1] 1
## attr(,"method")
## [1] "tolNorm2"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 6.661338e-16
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 <- matrix(c(1, 0, 0, 2, 4, 0, 3, 5, 6), nrow = 3)
A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
\({det}\left(A-\lambda \,I\right)\,=\,0?\)
The characteristic equation of the matrix
\(\left(\begin{array}{ccc}1&2&3\\0&4&5\\0&0&6\end{array}\right)\)
is
\(\text{det}\left(\begin{array}{ccc}1-\lambda &2&3\\0&4-\lambda &5\\0&0&6-\lambda \end{array}\right)=0\)
Expanding the determinant,
\(\left(1-\lambda\right) [\left(4-\lambda \right)\left(6-\lambda \right)-5\times 0] + 2[0 \times \left(6-\lambda \right)-5\times 0] + 3[0\times0 - 0\left(4-\lambda \right)]=0\)
\(\lambda_1=6,\lambda_2=4,\lambda_3=1\)
Compute the eigenvectors:
If \(\lambda_1=6\) and set X = 1, then solve the equation:
\(\left(\begin{array}{ccc}-5&2&3\\0&-2&5\\0&0&0\end{array}\right)\left(\begin{array}{c}X\\Y\\Z\end{array}\right)=\left(\begin{array}{c}0\\0\\0\end{array}\right).\)
-5 + 2Y + 3Z = 0
-2Y + 5Z = 0
X = 1, Y = \(\frac{25}{16}\), Z = \(\frac{5}{8}\)
Scale up, the eigenvector is (16, 25, 10)
Same calculations for \(\lambda_2=4\) and \(\lambda_3=1\), the eigenvectors are (2, 3, 0) and (1, 0, 0).
ev <- eigen(A)
# extract components
(values <- ev$values)
## [1] 6 4 1
(vectors <- ev$vectors)
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0
Reference:
https://cran.r-project.org/web/packages/matlib/vignettes/eigen-ex1.html