library(Matrix)
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
paste("Rank of matrix A is ",rankMatrix(A))
## [1] "Rank of matrix A is 4"
Maximum rank = n (Maximum rank is the minimum of m and n) Minimum rank of a non-zero matrix = 1
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
paste("Rank of matrix B is ",rankMatrix(B))
## [1] "Rank of matrix B is 1"
\(A = \left[\begin{array}{ccc} 1 & 2 & 3\\ 0 & 4 & 5\\ 0 & 0 & 6 \end{array}\right]\)
\(|A - λI| = 0 = det\left[\begin{array}{ccc} 1-λ & 2 & 3\\ 0 & 4-λ & 5\\ 0 & 0 & 6-λ \end{array}\right]\)
Thereby our expected eigenvalues are 1,4,6. We can verify the same and also compute the eigenvectors as below
A<-matrix(c(1,0,0,2,4,0,3,5,6), nrow =3)
eigen(A)
## eigen() decomposition
## $values
## [1] 6 4 1
##
## $vectors
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0