library(pracma)

Problem set 1

A <- matrix(c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3), nrow=4, byrow=TRUE)
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

1) What is the rank of the matrix A?

x <- qr(A)
Rank_A <- x$rank
Rank_A
## [1] 4

2)Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?

3)What is the rank of matrix B?

B <- matrix(c(1, 2, 1, 3, 6, 3, 2, 4, 2), nrow = 3, ncol = 3, byrow = TRUE)
B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
y <- qr(B)
Rank_B <- y$rank
Rank_B
## [1] 1

Problem set 2

A <- matrix(c( 1, 2, 3, 0, 4, 5, 0, 0, 6), nrow = 3, ncol = 3, byrow = TRUE)
A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0    4    5
## [3,]    0    0    6

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.

eigen(A)$values
## [1] 6 4 1
vec<-eigen(A)$vectors
vec
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0