Problem set 1

.

.

#defining the sample matrix:
A <- matrix(c(1, -1, 0, 5, 2, 0, 1, 4, 3 ,1, -2, -2, 4, 3, 1, -3), 4, 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
#run the function qr() 
qr(A)$rank
## [1] 4
#Alternative: load the Matrix package...
require(Matrix)
## Loading required package: Matrix
#and run the function rankMatrix()
rankMatrix(A)[1]
## [1] 4

.

.

==> For an mxn matrix (assuming that the matrix is non-zero) where m > n ; the maximum rank can be n.


.

.

#defining the square  matrix:
A <- matrix(c(1, 3, 2, 2, 6, 4, 1, 3, 2), 3, 3)
A
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
#run the function qr() 
qr(A)$rank
## [1] 1
#Alternative: load the Matrix package...
require(Matrix)

#and run the function rankMatrix()
rankMatrix(A)[1]
## [1] 1

Problem set 2

.

.

#defining the square  matrix:
A <- matrix(c(1, 0, 0, 2, 4, 0, 3, 5, 6), 3, 3)
A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0    4    5
## [3,]    0    0    6
#eigen fucntion:
e <- eigen(A)

#eigenvalues:
e$values
## [1] 6 4 1
.

.

#eigenvectors:
e$vectors
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0