\(\mathbf{A}\) = \(\left[ \begin{array}{ccc} 1 & 2 & 3 & 4\\ -1 & 0 & 1 & 3\\ 0 & 1 & -2 & 1\\ 5 & 4 & -2 & -3 \end{array} \right]\)
Rank of matrix A by Row Echelon Form and by Determinant Method
REDF <- function (M)
{
r = dim(M)[1]
for (p in 1:(r-1))
{
for (i in p:(r-1)) #row
{
mult = ((M[i+1,p])/(M[p,p]))
print (mult)
for (j in p:r) #column
{
M[i+1,j] = M[i+1,j] - M[p,j]*mult
}
}
}
return(M)
}
A = matrix(c(1, -1, 0, 5, 2, 0, 1, 4, 3, 1, -2, -2, 4, 3, 1, -3), 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
det(A)
## [1] -9
Since determinant is non-zero, rank of Matrix A is 4.
Also by Reduced Row Echelon Form Method to find rank of matrix
s <- REDF(A)
## [1] -1
## [1] 0
## [1] 5
## [1] 0.5
## [1] -3
## [1] 1.25
print(s)
## [,1] [,2] [,3] [,4]
## [1,] 1 2 3 4.000
## [2,] 0 2 4 7.000
## [3,] 0 0 -4 -2.500
## [4,] 0 0 0 1.125
REDF2 <- function (M)
{
r = nrow(M)
c = ncol(M)
for (p in 1:(c-1))
{
for (i in p:(r-1)) #row
{
mult = ((M[i+1,p])/(M[p,p]))
print (mult)
for (j in p:c) #column
{
M[i+1,j] = M[i+1,j] - M[p,j]*mult
}
}
}
return(M)
}
Q = matrix(c(s[,2],s[,3],s[,4]), ncol=3)
Q
## [,1] [,2] [,3]
## [1,] 2 3 4.000
## [2,] 2 4 7.000
## [3,] 0 -4 -2.500
## [4,] 0 0 1.125
s <- REDF2(Q)
## [1] 1
## [1] 0
## [1] 0
## [1] -4
## [1] 0
print(s)
## [,1] [,2] [,3]
## [1,] 2 3 4.000
## [2,] 0 1 3.000
## [3,] 0 0 9.500
## [4,] 0 0 1.125
Q = matrix(c(s[,2],s[,3]), ncol=2)
Q
## [,1] [,2]
## [1,] 3 4.000
## [2,] 1 3.000
## [3,] 0 9.500
## [4,] 0 1.125
s <- REDF2(Q)
## [1] 0.3333333
## [1] 0
## [1] 0
print(s)
## [,1] [,2]
## [1,] 3 4.000000
## [2,] 0 1.666667
## [3,] 0 9.500000
## [4,] 0 1.125000
Since all rows/columns are non-zero in reduced echelon form, rank of square matrix A is same as its dimensions which is 4.
Since m(rows) > n(columns), maximum rank of the matrix is n (number of columns)
Minimum rank of a non-zero matrisx is 1.
\(\mathbf{B}\) = \(\left[ \begin{array}{ccc} 1 & 2 & 1\\ 3 & 6 & 3\\ 2 & 4 & 2 \end{array} \right]\)
__Rank of matrix B by Row Echelon Form and by Determinant Method_
B = matrix(c(1,2,1,3,6,3,2,4,2),nrow=3,byrow=TRUE)
det(B)
## [1] 0
Since determinant is 0, rank of matrix B is less than rows/columns of 3.
Using the Row Echelon Form method
s <- REDF2(B)
## [1] 3
## [1] 2
## [1] NaN
print(s)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] 0 NaN NaN
C = matrix(c(B[1,],B[3,]),nrow=2,byrow=TRUE)
C
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 2 4 2
Since there is only 1 independent row, rank of the matris is 1.
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.
\(\mathbf{A}\) = \(\left[ \begin{array}{ccc} 1 & 2 & 3\\ 0 & 4 & 5\\ 0 & 0 & 6 \end{array} \right]\)
Let \(\lambda\) be an eigenvalue of \(\mathbf{A}\) where \(\mathbf{A}\vec{v}\) = \(\lambda\vec{v}\) for non-zero \(\vec{v}\),
(\(\lambda\)\(I_n\)-\(\mathbf{A}\))\(\vec{v}\)=\(\vec{0}\)
\(\left[ \begin{array}{ccc} \lambda & 0 & 0\\ 0 & \lambda & 0\\ 0 & 0 & \lambda \end{array} \right]\) - \(\left[ \begin{array}{ccc} 1 & 2 & 3\\ 0 & 4 & 5\\ 0 & 0 & 6 \end{array} \right]\) = \(\left[ \begin{array}{ccc} \lambda - 1 & -2 & -3\\ 0 & \lambda - 4 & -5\\ 0 & 0 & \lambda - 6 \end{array} \right]\)
det \(\left| \begin{array}{ccc} \lambda - 1 & -2 & -3\\ 0 & \lambda - 4 & -5\\ 0 & 0 & \lambda - 6 \end{array} \right|\) = (\(\lambda\)-1) (\(\lambda\)-4) (\(\lambda\)-6)
(\(\lambda\)-1) = 1, 4 and 6 (eigenvalues)
Eigenvectors -
For \(\lambda_1\) -
= \(\left[ \begin{array}{ccc} 0 & -2 & -3\\ 0 & -3 & -5\\ 0 & 0 & -5 \end{array} \right]\) \(\vec{v}\)
Reduced Row Echelon Form to find the vector for eigenvalue \(\lambda_1\)
C = matrix(c(0, -2, -3, 0, -3, -5, 0, 0, -5),nrow=3,byrow=TRUE)
C
## [,1] [,2] [,3]
## [1,] 0 -2 -3
## [2,] 0 -3 -5
## [3,] 0 0 -5
s <- REDF2(C)
## [1] NaN
## [1] NaN
## [1] NaN
print(s)
## [,1] [,2] [,3]
## [1,] 0 -2 -3
## [2,] NaN NaN NaN
## [3,] NaN NaN NaN
0\(V_1\) -2\(V_2\) - 3\(V_3\) = 0
-2$V_2$ = 3$V_3$
$V_2$ = -1.5$V_3$