A <- matrix(c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3), byrow=T, nrow=4, ncol=4)
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
library(Matrix)
## Warning: package 'Matrix' was built under R version 3.3.3
rankMatrix(A)
## [1] 4
## attr(,"method")
## [1] "tolNorm2"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 8.881784e-16
#another way to compute rank
qr(A)
## $qr
## [,1] [,2] [,3] [,4]
## [1,] -5.1961524 -4.2339020 1.539601 2.694301
## [2,] -0.1924501 -1.7533038 -1.436442 -4.795180
## [3,] 0.0000000 0.5703518 3.683241 2.162187
## [4,] 0.9622504 -0.5877259 0.592032 0.268209
##
## $rank
## [1] 4
##
## $qraux
## [1] 1.192450 1.573827 1.805914 0.268209
##
## $pivot
## [1] 1 2 3 4
##
## attr(,"class")
## [1] "qr"
The rank of matrix A is 3.
\[rank(A_{mxn}) <= min(m,n)\] (m,n) denotes the smaller of the two numbers m and n, or either m or n if m=n. The rank of the matrix can be no larger than this smaller value. For example, for a 3 by 5 matrix, the rank can be no larger than 3.
Therefore, given an mxn matrix where m > n, the maximum rank is n. Assuming the matrix is non-zero, the minimum rank is 1.
B <- matrix(c(1,2,1,3,6,3,2,4,2), byrow=T, nrow=3, ncol=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
#another way to compute rank
qr(B)
## $qr
## [,1] [,2] [,3]
## [1,] -3.7416574 -7.483315 -3.741657
## [2,] 0.8017837 0.000000 0.000000
## [3,] 0.5345225 0.000000 0.000000
##
## $rank
## [1] 1
##
## $qraux
## [1] 1.267261 0.000000 0.000000
##
## $pivot
## [1] 1 2 3
##
## attr(,"class")
## [1] "qr"
The rank of matrix B is 1.
A <- matrix(c(1,2,3,0,4,5,0,0,6), byrow=T, nrow=3, ncol=3)
A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
A_eigen <- eigen(A)
A_eigen
## $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
\[A=\begin{vmatrix}1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6\end{vmatrix}\] We need to find eigenvalues from the characteristic polynomial. First, we’ll subtract \[\lambda\] from the diagonal entries in the matrix.
\[\begin{vmatrix}1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda\end{vmatrix}\] \[-\lambda+11\lambda^2-34 \lambda+24=0\] \[(-1)(\lambda-1)(\lambda-4)(\lambda-6)=0\] The eigenvalues and the associated eigenvectors for matrix A are:
\[\lambda_1 = 1\] \[\begin{vmatrix}1\\0\\0\end{vmatrix}\] \[\lambda_2 = 4\] \[\begin{vmatrix}1\\ \frac{3}{2} \\0\end{vmatrix}\]
\[\lambda_3 = 6\] \[\begin{vmatrix}1\\ \frac{25}{16} \\\frac{5}{8}\end{vmatrix}\]