DATA605_HW3_Eigenvalues and Eigenvectors
library(pracma)Problem set 1
- What is the rank of the matrix A?
\[ A = \begin{bmatrix} 1 & 2 & 3 & 4 \\ -2 & 0 & 1 & 3 \\ 0 & 1 & -2 & 1 \\ 5 & 4 & -2 & -3 \\ \end{bmatrix} \]
Solution 1
A <- matrix(c(1,-2,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3), ncol=4)
A## [,1] [,2] [,3] [,4]
## [1,] 1 2 3 4
## [2,] -2 0 1 3
## [3,] 0 1 -2 1
## [4,] 5 4 -2 -3
det(A)## [1] 52
Since \(Det(A)\neq 0\), we say there is no linear dependence of any role or column.
Rank of a matrix A is the number of role or column that are not a linear combination of another role of column.
qr(A)$rank## [1] 4
- Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?
Solution 2
For a Non-Zero Matrix, the Maximum rank can’t be greater than the the smaller dimension of the matrix which is n and the mininum rank can’t be less than 1.
Therefore, the rank is between 1 and n (inclusive). Maximum Rank = n Mininum Rank = 1
- What is the rank of matrix B?
\[ B = \begin{bmatrix} 1 & 2 & 1 \\ 3 & 6 & 3 \\ 2 & 4 & 2 \\ \end{bmatrix}\]
Solution 3
B <- matrix(c(1,3,2,2,6,4,1,3,2), nrow = 3)
B## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
det(B)## [1] 0
The rank of B is 1, because:
- The determinant of this square matrix is 0, which hints at linear dependence.
- Each row and column is a linear combination of other rows and column. We manipulate the matrix to get the number of NOn-zero role to be 1. Hence, the rank is 1
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 = \begin{bmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \\ \end{bmatrix}\)
Solution
\(Det (A - \lambda I)= 0\)
\(Det\left ( \begin{bmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \\ \end{bmatrix}- \lambda \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} \right ) = 0\)
\(= Det\begin{bmatrix} 1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda \\ \end{bmatrix}\)
\(= (1-\lambda )((4-\lambda)(6-\lambda)-0\times 5) - 2((6-\lambda)\times 0-0\times 5) + 3((0\times 0)-(0\times (4-\lambda)))\)
simplifying the above equation, we get the characteristic polynomial as:
\(P(\lambda )= -\lambda ^3 + 11\lambda^2 - 34\lambda + 24\)
Equating the characteristiv polynomial to zero(0) and Solving to get the Eigenvalues, we get:
\((-\lambda + 6)(\lambda - 4)(\lambda - 1) = 0\)
Eigenvalues of matrix A are: \(\lambda = 1, \lambda = 4, \lambda = 6\)
To calculate Eigenvectors, we use the formular \((AX-\lambda I) = 0\)
using R to reduce to matrix
A <- matrix(c(1,2,3,0,4,5,0,0,6), nrow=3, byrow=TRUE)If \(\lambda=1\), then \(A - 1I_3\) is row-reduced to
rref(A - 1 * diag(3))## [,1] [,2] [,3]
## [1,] 0 1 0
## [2,] 0 0 1
## [3,] 0 0 0
\[ \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} \]
Then \(v_1=v_1\) and \(v_2=0\) and \(v_3=0\). The eigenvector for \(\lambda=1\) is
\[ X_{1}= \begin{bmatrix} 1\\ 0\\ 0 \end{bmatrix} \]
If \(\lambda=4\), then \(A - 4I_3\) is row-reduced to
rref(A - 4 * diag(3))## [,1] [,2] [,3]
## [1,] 1 -0.6666667 0
## [2,] 0 0.0000000 1
## [3,] 0 0.0000000 0
\[ \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} \]
Then \(v_1 - \frac{2}{3}v_2=0\) and \(v_3=0\).
Or \(v_1=v_1\) and \(v_2=\frac{3}{2}v_1=1.5v_1\) and \(v_3=0\).
The eigenvector for \(\lambda=4\) is
\[ X_{2}= \begin{bmatrix} 1\\ 1.5\\ 0 \end{bmatrix} \]
Finally, if \(\lambda=6\), then \(A - 6I_3\) is row-reduced to
rref(A - 6 * diag(3))## [,1] [,2] [,3]
## [1,] 1 0 -1.6
## [2,] 0 1 -2.5
## [3,] 0 0 0.0
\[ \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} \]
Then \(v_1-1.6v_3=0\) and \(v_2-2.5v_3=0\).
Or \(v_1=1.6v_3\) and \(v_2=2.5v_3\) and \(v_3=v_3\).
The eigenvector for \(\lambda=6\) is:
\[ X_{3}= \begin{bmatrix} 1.6\\ 2.5\\ 1 \end{bmatrix} \]
Eigenvalues of matrix A are: \(\lambda_{1} = 1, \lambda_{2} = 4, \lambda_{3} = 6\)
Eigenvectors of matrix A are: \(X_{1}=\begin{bmatrix}1\\0\\0\end{bmatrix}\) , \(X_{2}=\begin{bmatrix}1\\1.5\\0\end{bmatrix}\) and \(X_{3}=\begin{bmatrix}1.6\\2.5\\1\end{bmatrix}\)