1) What is the rank of the matrix A?
library("matlib")
# Defining matrix
(A<- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3), 4,4, byrow = F))
## [,1] [,2] [,3] [,4]
## [1,] 1 2 3 4
## [2,] -1 0 1 3
## [3,] 0 1 -2 1
## [4,] 5 4 -2 -3
# Check for determinent
(det(A)) != 0
## [1] TRUE
# Finding rank
(rank_A<- R(A))
## [1] 4
3)What is the rank of matrix B?
library(pracma)
##
## Attaching package: 'pracma'
## The following objects are masked from 'package:matlib':
##
## angle, inv
# Defining matrix
(B <- matrix(c(1,2,1,3,6,3,2,4,2), 3,3, byrow = T))
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
# Check for determinent
(det(B)== 0)
## [1] TRUE
#Finding rank of sub matrix
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"
Since det of matrix B is ZERO,the det of sub matrix is also ZERO. hence rank is 1.