#import the Matrix library
library(Matrix)
## Warning: package 'Matrix' was built under R version 4.1.3
library(latex2exp)
## Warning: package 'latex2exp' was built under R version 4.1.3
The rank of Matrix A is 4 meaning we have 4 pivot columns
## build the matrix
A <- matrix(c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3),byrow=T,nrow = 4)
## calculating the rank of the matrix using rankMatrix
## We get the rank is 4
rankMatrix(A)[1]
## [1] 4
Given a m*n matrix where the row is greater than the column,the maximum rank would be n, since by definition the rank of a matrix can be no greater than the smallest of the rows or column dimension,since n is smaller than m, the maximum rank would be n. The minimum rank assuming the matrix is non-zero would be 1,since there should be atleast 1 pivot in the non zero matrix.
The rank of Matrix B is 1 since the other vectors are multiples of the first vector..
B <- matrix(c(1,2,1,3,6,3,2,4,2),byrow=T,nrow=3)
rankMatrix(B)[1]
## [1] 1
First we create our matrix A
A <-matrix(c(1,2,3,0,4,5,0,0,6),byrow=T,nrow=3)
A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
In order to get our characteristic polynomial we first have to find the \[det(A-AI) = 0\]
which is:
\[ det(A-AI)= \begin{bmatrix} 1-x & 2 & 3 & \\ 0 & 4-x & 5 & \\ 0 & 0 & 6-x & \\ \end{bmatrix} \] where x denotes lambda
Next, we solve for the determinant and get the form
\[ (1-x)\begin{bmatrix} 4-x & 5 & \\ 0 & 6-x & \\ \end{bmatrix} \]
\[ -2\begin{bmatrix} 0 & 5 & \\ 0 & 6-x & \\ \end{bmatrix} \] \[ 3\begin{bmatrix} 0 & 4-x &\\ 0 & 0 & \\ \end{bmatrix} \]
Combining all the terms together we get the equation
\[ det(A-AI) = -x^3 + 11x^2 -34x + 24\]
or more accurately
\[ -x^3 + 11x^2 -34x + 24 = 0 \]
Unfortunately for me, we have to factor a cubic polynomial which is no easy feat. Our roots of this polynomial will factor out from our constant which is 24, so a factor of 24 is plugged into the characteristic polynomial and gives us 0 is a root! The roots of 24 are: \[ 24: 1,2,3,4,6,8,12,24 \]
The only root that give us 0 when plugged into the polynomial is 4!, This means that one of the eigenvalues of this polynomial is 4!. However we can find the rest of the eigenvalues by dividing x-4 into the characteristic polynomial.(Edit!! I also found out that 1 also is a root if we plug it into the characteristic polynomial and we get 0 there as well but the below method still works the same!!)
\[ \frac{-x^3 + 11x^2 -34x + 24}{x-4} \]
Doing the long division on polynomial we get:
\[ \frac{-x^3 + 11x^2 -34x + 24}{x-4} = -x^2+7x-6 \]
We can further simply this by taking out the negative sign and easily factor it out since it is a quadratic polynomial we get:
\[ (x^2-7x+6) = 0 \]
\[ (x^2-7x+6) = (x-6)(x-1) \]
Now our eigenvalues are now: \[ x=1,x=4,x=6 \]
Now that we have our eigenvalues we can find our eigenvectors
First let us solve for x=1
\[ x=1 \] Pluggin in 1 for lambda we have the matrix:
\[ A-1I= \begin{bmatrix} 1-1 & 2 & 3 & \\ 0 & 4-1 & 5 & \\ 0 & 0 & 6-1 & \\ \end{bmatrix} = \begin{bmatrix} 0 & 2 & 3 & \\ 0 & 3 & 5 & \\ 0 & 0 & 5 & \\ \end{bmatrix} \]
Next we convert the matrix into row reduced echelon form and we get:
\[ \begin{bmatrix} 0 & 1 & 0 & \\ 0 & 0 & 1 & \\ 0 & 0 & 0 & \\ \end{bmatrix} \] Since both v2 and v3 = 0 and v1 is a free variable we can let v1 = t and we have the following eigenvector for lambda = 1: \[ t\begin{bmatrix} 1 \\ 0 \\ 0 \\ \end{bmatrix} \]
Next let us solve for x = 4
\[ x=4 \] we have the following matrix:
\[ A-4I= \begin{bmatrix} 1-4 & 2 & 3 & \\ 0 & 4-4 & 5 & \\ 0 & 0 & 6-4 & \\ \end{bmatrix} = \begin{bmatrix} -3 & 2 & 3 & \\ 0 & 0 & 5 & \\ 0 & 0 & 2 & \\ \end{bmatrix} \] Converting it to reduced row echelon form we get:
\[ \begin{bmatrix} 1 & 2/3 & 0 & \\ 0 & 0 & 1 & \\ 0 & 0 & 0 & \\ \end{bmatrix} \]
Since v2 is a free variable and v3 = 0, let v2= t and we have: the eigenvector for x = 4
\[ t\begin{bmatrix} 2/3 \\ 1 \\ 0 \\ \end{bmatrix} \]
Finally, solving for x = 6
\[ x=6 \]
we have the matrix
\[ A-6I= \begin{bmatrix} 1-6 & 2 & 3 & \\ 0 & 4-6 & 5 & \\ 0 & 0 & 6-6 & \\ \end{bmatrix} = \begin{bmatrix} -5 & 2 & 3 & \\ 0 & -2 & 5 & \\ 0 & 0 & 0 & \\ \end{bmatrix} \]
row reducing the matrix in echelon form we get the matrix:
\[ \begin{bmatrix} 1 & 0 & -8/5 & \\ 0 & 1 & -5/2 & \\ 0 & 0 & 0 & \\ \end{bmatrix} \]
We then have v1 = 8/5v3 , v2= 5/2v3 and v3 is a free variable, let v3 = t we have the eigenvector for x=6 we get:
\[ t\begin{bmatrix} 8/5 \\ 5/2 \\ 1 \\ \end{bmatrix} \]