library(pracma)
A = matrix(c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3), nrow=4, ncol=4, byrow=T)
print(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
print(det(A))
## [1] -9
Since determinent of A is non zero, rank of A is 4.
Verify using R
print(Rank(A))
## [1] 4
Maxm rank of the nXm matrix can be minimum value of either n or m. For example for 4X6 matrix maxm rank can be 4. Minimum rank of the non zero matrix will be 1. Matrix rank can be zero if the given matrix is zero matrix that means all the elements of the matrix are 0
B = matrix(c(1, 2, 1,3, 6, 3,2, 4, 2), nrow=3,ncol=3, byrow=T)
print(B)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
Row 2 and Row 3 of the above matrix is multiplier of Row 1 and can be converted to 0. This geves us only one non zero row for this matrix. Therefore rank of the matirx B is 1
Verify using R
print(Rank(B))
## [1] 1
A <- matrix(c(1,2,3,0,4,5,0,0,6), ncol=3, nrow=3, byrow=TRUE)
print(A)
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
knitr::include_graphics("https://github.com/mlforsachid/MSDSQ2Data605/blob/master/Week3/HW-3/HW-3.jpg?raw=true")
Verify using R
stat = eigen(A)
print(stat$values)
## [1] 6 4 1
print(stat$vectors)
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0