library(Matrix)
library(pracma)A <- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3),nrow= 4)
det(A)## [1] -9
rankMatrix(A,warn.t = FALSE)[1]## [1] 4
The determinant of this matrix is not zero so the rank is 4. We can also see that the rank is 4 by using the rankMatrix function.
C <- matrix(c(1,2,3,4,3,5),ncol=2,nrow=3)
C## [,1] [,2]
## [1,] 1 4
## [2,] 2 3
## [3,] 3 5
rankMatrix(C,warn.t = FALSE)[1]## [1] 2
The maximum rank for a mxn matrix with m > n would be n since the rank cannot be greater than the smaller column and/or row. THe minimum rank rank would be 1 given the case that matrix is non-zero.
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
det(B)## [1] 0
rankMatrix(B)[1]## [1] 1
The determinant of this matrix is zero so the rank is between 1 and 2. We see that 2(row1) = row3 and 3(row1) - row3 so the matrix has row1 as the only independet row making the rank=1. We can also see that the rank is 1 by using the rankMatrix function.
Characteristic Polynomial:
\[\mathbf{det(A - xI)} =det(\left[\begin{array}
{rrr}
1 & 2 & 3\\
0 & 4 & 5\\
0 & 0 & 6\\
\end{array}\right]
-
x \left[\begin{array}
{rrr}
1 & 0 & 0\\
0 & 1 & 0\\
0 & 0 & 1\\
\end{array}\right]
)
\]
\[\mathbf{det(A - xI)} =det(\left[\begin{array}
{rrr}
1-x & 2 & 3\\
0 & 4-x & 5\\
0 & 0 & 6-x\\
\end{array}\right])
\] \[-x^3 + 11x^2 - 34x + 24\]
Eigenvalues:
polyroot(c(24,-34,11,-1))## [1] 1+0i 4-0i 6+0i
Eigenvalues are 1, 4, and 6.
Eigenvectors:
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
diag(3)## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1
Eigenvector for 1:
rref(A-1*diag(3))## [,1] [,2] [,3]
## [1,] 0 1 0
## [2,] 0 0 1
## [3,] 0 0 0
\[x_2=0\quad x_3=0\quad x_1=1\] \[\mathbf{E_1} =\left[\begin{array} {rrr} 1\\ 0\\ 0\\ \end{array}\right] \] Eigenvector for 4:
rref(A-4*diag(3))## [,1] [,2] [,3]
## [1,] 1 -0.6666667 0
## [2,] 0 0.0000000 1
## [3,] 0 0.0000000 0
\[x_1 - .67(x_2)=0\quad x_3=0\] \[1-.67(x_2) = 0\] \[x_2 = 1.5\]
\[\mathbf{E_4} =\left[\begin{array}
{rrr}
1\\
1.5\\
0\\
\end{array}\right]
\] Eigenvector for 6:
rref(A-6*diag(3))## [,1] [,2] [,3]
## [1,] 1 0 -1.6
## [2,] 0 1 -2.5
## [3,] 0 0 0.0
\[x_1 - 1.6(x_3)=0\quad x_2 - 2.5(x_3)=0\] \[\mathbf{E_6} =\left[\begin{array} {rrr} 1.6\\ 2.5\\ 1\\ \end{array}\right] \]