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 = T)
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
#Use qr function to get rank
#Rank is 4
qr(A)$rank
## [1] 4
#For rectangular matrices the rank has to be no greater than the smaller of the row or column dimension, therefore, given that m is greater than n, the maximum rank of the matrix is n.

#The mimimum rank would be one given that the matrix has at least one element.
B <- matrix(c(1,2,1,3,6,3,2,4,2), nrow=3, byrow = T)
B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
#Use qr function to get rank
#Rank is 1
qr(B)$rank
## [1] 1

Problem Set 2

library(pracma)
A <- matrix(c(1,2,3,0,4,5,0,0,6), nrow=3, byrow = T)
A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0    4    5
## [3,]    0    0    6
charpoly(A)
## [1]   1 -11  34 -24
#Used charpoly to make sure if we are getting the same answer below.

\[\mathbf A = \begin{bmatrix} 1 - \lambda & 2 & 3 \\ 0 & 4 - \lambda & 5 \\ 0 & 0 & 6 - \lambda \end{bmatrix}\]

We know for 3 x 3 determinant, we get \[(1- \lambda) \begin{bmatrix} 4 - \lambda & 5 \\ 0 & 6 - \lambda \end{bmatrix} - 2 \begin{bmatrix} 0 & 5 \\ 0 & 6 - \lambda \end{bmatrix} + 3 \begin{bmatrix} 0 & 4 - \lambda\\ 0 & 0 \end{bmatrix} \]

And it turns out \[(1- \lambda) (4 - \lambda) (6 - \lambda) = - \lambda^3 + 11 \lambda^2 -34 \lambda + 24 \]

For Eigenvalues, we know \[\lambda_1 = 1, \lambda_2 = 4, \lambda_3 = 6\]

With these, we can get Eigenvectors.

For \[\lambda_1 = 1 : (A-I)x = \begin{bmatrix} 0 & 2 & 3 \\ 0 & 3 & 5 \\ 0 & 0 & 5 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}\]

For \[\lambda_2 = 4 : (A-4I)x = \begin{bmatrix} -3 & 2 & 3 \\ 0 & 0 & 5 \\ 0 & 0 & 2 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}\]

For \[\lambda_3 = 6 : (A-6I)x = \begin{bmatrix} -5 & 2 & 3 \\ 0 & -2 & 5 \\ 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}\]

Thus, we know eigenvectors are:

e <- eigen(A)
e
## eigen() decomposition
## $values
## [1] 6 4 1
## 
## $vectors
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0
#first column of $vectors corresponds to eigenvalue of 6, 2nd to 4 and 3rd to 1.