Problem set 1
A <- matrix(c(1,2,3,4,
-1,0,1,3,
0,1,-2,1,
5,4,-2,-3), nrow = 4, ncol = 4,byrow=TRUE)
print(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
qr_decomp <- qr(A)
rankA <- qr.R(qr_decomp)
print(rankA)
## [,1] [,2] [,3] [,4]
## [1,] -5.196152 -4.233902 1.539601 2.694301
## [2,] 0.000000 -1.753304 -1.436442 -4.795180
## [3,] 0.000000 0.000000 3.683241 2.162187
## [4,] 0.000000 0.000000 0.000000 0.268209
The matrix rank is 4, as a result of matrix A having 4 non-zero rows.
Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero? The maximum rank that an mxn matrix is can have is n, since this would be the number which limits the number of rows or columns. The minimum rank that an mxn matrix can has is also n for the same reasons.
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)
print(B)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
qr_decomp <- qr(B)
rankB <- qr.R(qr_decomp)
print(rankB)
## [,1] [,2] [,3]
## [1,] -3.741657 -7.483315 -3.741657
## [2,] 0.000000 0.000000 0.000000
## [3,] 0.000000 0.000000 0.000000
The matrix rank is 1, as a result of matrix B having 1 non-zero row.
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.
A <- matrix(c(1,2,3,
0,4,5,
0,0,6), nrow = 3, ncol = 3,byrow=TRUE)
print(A)
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
I used the row with the most zeroes to find the deteminant, in this case, that was the third row. After expanding, this is what I had: det = 0(10-12) - 0(5-0) + (6-λ)((1-λ)(4-λ)0) I simplified like so: = (6-λ)((1-λ)(4-λ)) = (6-λ)(4+λ** -4λ-λ) = (6-λ)(λ** -5λ + 4) = (6-λ)(λ-1)(λ-4)
This means that we can expect our eigenvalues to be 6, 1, and 4, when we solve using R.
Here are the eigenvalues and eigenvectors using R:
eigenvalues <- eigen(A)$values
print(eigenvalues)
## [1] 6 4 1
eigenvectors <- eigen(A)$vectors
print(eigenvectors)
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0