(1) What is the rank of the matrix A?

A <- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3),4,4)
rankA <- rankMatrix(A)

(2) Given an mxn matrix where m > n, what can be the maximum rank? If m > n, then maximum rank = n, otherwise max rank = m The minimum rank, assuming that the matrix is non-zero? The minimum rank of any non-zero matrix is 1

(3) What is the rank of matrix B?

B <- matrix(c(1,3,2,2,6,4,1,3,2),3,3)
rankB <- rankMatrix(B)
rankB
## [1] 1
## attr(,"method")
## [1] "tolNorm2"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 6.661338e-16

(P.S.2) Compute the eigenvalues and eigenvectors of the matrix A.

l <- NA
iM <- matrix(c("l-1",0,0,-2,"l-4",0,-3,-5,"l-6"),3,3) #lM - A
Sar <- cbind(iM,iM[,1],iM[,2])
x <- ((l-1)*(l-4)*(l-6)) + (-2*-5*0) + (3*0*0) - (-2*0*(l-6)) - ((l-1)*-5*0) - (-3*(l-4)*0)#det(iM)
x <- (l^2 - 5*l + 4)*(l-6)
x <- l^3 - 5*l^2 + 4*l -6*l^2 + 30*l - 24
x <- l^3 - 11*l^2 + 34*l - 24 #characteristic polynomial
cpRoots <- polyroot(c(-24,34,-11,1))

check

A <- matrix(c(1,0,0,2,4,0,3,5,6),3,3)
checkEigen <- function(A,l){
  lM <- matrix(c(l,0,0,0,l,0,0,0,l),3,3)
  iMA <- lM - A
  det(iMA)
}

for(i in 1:length(cpRoots)){
  l <- Re(cpRoots[i])
  print(checkEigen(A,l))
}
## [1] -1.099121e-13
## [1] -1.119105e-13
## [1] -1.154632e-13