library(matrixcalc)
library(pracma)
1.Problem set 1
\[ A= \left[ \begin{array}{cccc} 1 & 2 & 3 & 4 \\ -1 & 0 & 1 & 3 \\ 0 & 1 & -2 & 1 \\ 5 & 4 & -2 & -3 \end{array} \right] \]
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
det(A)
## [1] -9
# Since the determinant is non-zero the rank is:
Rank(A)
## [1] 4
Maximum the rank would be the number of rows or number of columns (if you transpose). Rank is the total number of pivot points. The minimum is 1 since it is non-zero.
\[ B= \left[ \begin{array}{cccc} 1 & 2 & 1 \\ 3 & 6 & 3 \\ 2 & 4 & 2 \end{array} \right] \]
B <- matrix(c(1,2,1,3,6,3,2,4,2), nrow=3, byrow=TRUE)
B
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
If we reduce this to Row Echelon form, we can see the pivot of 1. So the rank is 1. Row 2 and 3 are multiples of Row 1. So it makes sense.
rref(B)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] 0 0 0
matrix.rank(B)
## [1] 1
2.Problem set 2
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= \left[ \begin{array}{cccc} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{array} \right] \]
This is a nxn (square) matrix and is also an upper triangular matrix in which all entries below the main diagonal are zero.
The eigenvalues are values on the diagonal i.e 1,4,6.
\[\lambda_1=1\] \[\lambda_2=4\] \[\lambda_3=6\]
A <- matrix(c(1,2,3,0,4,5,0,0,6), nrow=3, byrow=TRUE)
A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
eigen(A)$values
## [1] 6 4 1
Characteristic Polynomial is Det(A-λI)=0 or Det(λI-A)=0 where I is the identity matrix
# Test for Characteristic Polynomial
det(A - (rref(A) * diag(x=1, nrow=3))) == 0
## [1] TRUE
\[f_A(\lambda) = (1-\lambda)(4-\lambda)(6-\lambda) = 24-34\lambda+11\lambda^2-\lambda^3\]
If \(\lambda=1\), then \(A - 1I_3\) is row-reduced to
\[ \begin{bmatrix} 0 &1 &0\\ 0 &0 &1\\ 0&0&0 \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3 \end{bmatrix} = \begin{bmatrix} 0\\ 0\\ 0 \end{bmatrix} \]
Eigenspace would be:
\[ E_{\lambda=1}= span \Bigg( \begin{bmatrix} 1\\ 0\\ 0 \end{bmatrix} \Bigg) \]
If λ=4
\[ \begin{bmatrix} 1 &-\frac{2}{3} &0\\ 0 &0 &1\\ 0&0&0 \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3 \end{bmatrix} = \begin{bmatrix} 0\\ 0\\ 0 \end{bmatrix} \]
Eigenspace would be:
\[ E_{\lambda=4}= span \Bigg( \begin{bmatrix} 1\\ 1.5\\ 0 \end{bmatrix} \Bigg) \]
if λ=6
\[ \begin{bmatrix} 1 &0 &-1.6\\ 0 &1 &-2.5\\ 0&0&0 \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3 \end{bmatrix} = \begin{bmatrix} 0\\ 0\\ 0 \end{bmatrix} \]
Eigenspace would be:
\[ E_{\lambda=6}= span \Bigg( \begin{bmatrix} 1.6\\ 2.5\\ 1 \end{bmatrix} \Bigg) \]