library("pracma")
library("Matrix")
a <- c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3)
A <- matrix(a, nrow=4); 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
rref(A)
## [,1] [,2] [,3] [,4]
## [1,] 1 0 0 0
## [2,] 0 1 0 0
## [3,] 0 0 1 0
## [4,] 0 0 0 1
rankMatrix(A)[1]
## [1] 4
The rank of a matrix is the dimension of the matrix corresponding to the number of linearly independent rows or columns of the matrix.i The maximum rank of a matrix is the lesser of \(m, n\) such that \(\max(rank) = min(m, n)\).ii Therefore if \(m > n\), the maximum rank is \(n\). The rank of a zero matrix is \(0\) therefore the minimum rank for a non-zero matrix would be the natural number successor of zero \(S(n)=n+1\) such that \(S(0)=0+1=1\).
b <- c(1,3,2,2,6,4,1,3,2)
B <- matrix(b, nrow=3); B
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
rref(B)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] 0 0 0
rankMatrix(B)[1]
## [1] 1
Compute the eigenvalues and eigenvectors of the matrix \(\mathbf{A}\). You’ll need to show your work. You’ll need to write out the characteristic polynomial and show your solution. \[\mathbf{A} = \begin{bmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{bmatrix}\]
a <- c(1,0,0,2,4,0,3,5,6)
A <- matrix(a, nrow=3); A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
\[det\left( \mathbf{A} \right) =\begin{vmatrix} 1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda \end{vmatrix}=0\Rightarrow \tag{1}\]
\[\left( 1-\lambda \right) \begin{vmatrix} 4-\lambda & 5 \\ 0 & 6-\lambda \end{vmatrix}-\left( 2 \right) \begin{vmatrix} 0 & 5 \\ 0 & 6-\lambda \end{vmatrix}+\left( 3 \right) \begin{vmatrix} 0 & 4-\lambda \\ 0 & 0 \end{vmatrix}=0 \tag{2}\]
\[\left( 1-\lambda \right) \left[ \left( 4-\lambda \right) \left( 6-\lambda \right) -\left( 5 \right) \left( 0 \right) \right] -\left( 2 \right) \left[ \left( 0 \right) \left( 6-\lambda \right) -\left( 5 \right) \left( 0 \right) \right] +\left( 3 \right) \left[ \left( 0 \right) \left( 0 \right) -\left( 4-\lambda \right) \left( 0 \right) \right] =0 \tag{3}\]
\[\left( 1-\lambda \right) \left[ \left( 4-\lambda \right) \left( 6-\lambda \right) -0 \right] -\left( 2 \right) \left( 0 \right) +\left( 3 \right) \left( 0 \right) = 0 \tag{4}\]
\[\left( 1-\lambda \right) \left( 4-\lambda \right) \left( 6-\lambda \right) = 0 \tag{5}\]
\[\left( 1-\lambda \right) \left( \lambda ^{ 2 }-10\lambda +24 \right) = 0 \tag{6}\]
\[-\lambda ^{ 3 }+11\lambda ^{ 2 }-34\lambda +24 = 0 \tag{7}\]
To calculate the eigenvalues, we subtract \(\lambda\) from the diagonal of \(\mathbf{A}\) and solve for \(\lambda\) in the equation (characteristic polynomial) that results from setting \(det\left(\mathbf{A}\right) = 0\). The characteristic polynomial for this example can be seen in \((7)\) above. In this example we can also see which values of \(\lambda\) solve the characteristic polynomial in equation \((5)\) above; and they are the eignvalues of \(\lambda = 6,4,1\) ordered by dominance (size).
eigen(A)$values
## [1] 6 4 1
\[\lambda =6\Rightarrow \begin{bmatrix} 1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda \end{bmatrix}=\begin{bmatrix} -5 & 2 & 3 \\ 0 & -2 & 5 \\ 0 & 0 & 0 \end{bmatrix}\models \tag{8.1}\]
\[rref\left( \begin{bmatrix} -5 & 2 & 3 \\ 0 & -2 & 5 \\ 0 & 0 & 0 \end{bmatrix} \right) =\begin{bmatrix} 1 & 0 & -\frac { 8 }{ 5 } \\ 0 & 1 & -\frac { 5 }{ 2 } \\ 0 & 0 & 0 \end{bmatrix}=\begin{bmatrix} 1 & 0 & -\frac { 8 }{ 5 } \\ 0 & 1 & -\frac { 5 }{ 2 } \\ 0 & 0 & 0 \end{bmatrix}\Rightarrow \tag{8.2}\]
\[\mathbf{x}=\begin{bmatrix} \frac { 8 }{ 5 } \\ \frac { 5 }{ 2 } \\ 1 \end{bmatrix}\Rightarrow \left\| \mathbf{x} \right\| =\begin{bmatrix} { \frac { 8 }{ 5 } }/\sqrt { \frac { 8 }{ 5 } ^{ 2 }+\frac { 5 }{ 2 } ^{ 2 }+1^{ 2 } } \\ \frac { 5 }{ 2 } /\sqrt { \frac { 8 }{ 5 } ^{ 2 }+\frac { 5 }{ 2 } ^{ 2 }+1^{ 2 } } \\ 1/\sqrt { \frac { 8 }{ 5 } ^{ 2 }+\frac { 5 }{ 2 } ^{ 2 }+1^{ 2 } } \end{bmatrix}=\begin{bmatrix} { \frac { 16\sqrt { 109 } }{ 327 } } \\ \frac { 25\sqrt { 109 } }{ 327 } \\ \frac { 10\sqrt { 109 } }{ 327 } \end{bmatrix}\approx \begin{bmatrix} 0{ .5108407 } \\ 0.7981886 \\ 0.3192754 \end{bmatrix} \tag{8.3}\]
\[\lambda =4\Rightarrow \begin{bmatrix} 1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda \end{bmatrix}=\begin{bmatrix} -3 & 2 & 3 \\ 0 & 0 & 5 \\ 0 & 0 & 2 \end{bmatrix}\models \tag{9.1}\]
\[rref\left( \begin{bmatrix} -3 & 2 & 3 \\ 0 & 0 & 5 \\ 0 & 0 & 2 \end{bmatrix} \right) =\begin{bmatrix} 1 & -\frac { 2 }{ 3 } & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{bmatrix}=\begin{bmatrix} 1 & -\frac { 2 }{ 3 } & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}\Rightarrow \tag{9.2}\]
\[\mathbf{x}=\begin{bmatrix} \frac { 2 }{ 3 } \\ 1 \\ 0 \end{bmatrix}\Rightarrow \left\| \mathbf{x} \right\| =\begin{bmatrix} { \frac { 2 }{ 3 } }/\sqrt { \frac { 2 }{ 3 } ^{ 2 }+1^{ 2 }+0^{ 2 } } \\ 1/\sqrt { \frac { 2 }{ 3 } ^{ 2 }+1^{ 2 }+0^{ 2 } } \\ 0/\sqrt { \frac { 2 }{ 3 } ^{ 2 }+1^{ 2 }+0^{ 2 } } \end{bmatrix}=\begin{bmatrix} { \frac { 2\sqrt { 13 } }{ 13 } } \\ \frac { 3\sqrt { 13 } }{ 13 } \\ 0 \end{bmatrix}\approx \begin{bmatrix} { 0.5547002 } \\ 0.8320503 \\ 0.0000000 \end{bmatrix}\tag{9.3}\]
\[\lambda =1\Rightarrow \begin{bmatrix} 1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda \end{bmatrix}=\begin{bmatrix} 0 & 2 & 3 \\ 0 & 3 & 5 \\ 0 & 0 & 5 \end{bmatrix}\models \tag{10.1} \]
\[rref\left( \begin{bmatrix} 0 & 2 & 3 \\ 0 & 3 & 5 \\ 0 & 0 & 5 \end{bmatrix} \right) =\begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{bmatrix}=\begin{bmatrix} 0 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}\Rightarrow \tag{10.2}\]
\[\mathbf{x}=\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}\Rightarrow \left\| \mathbf{x} \right\| =\begin{bmatrix} { 1 }/\sqrt { 1^{ 2 }+0^{ 2 }+0^{ 2 } } \\ 0/\sqrt { 1^{ 2 }+0^{ 2 }+0^{ 2 } } \\ 0/\sqrt { 1^{ 2 }+0^{ 2 }+0^{ 2 } } \end{bmatrix}=\begin{bmatrix} { 1 } \\ 0 \\ 0 \end{bmatrix}\tag{10.3}\]
To calculate the eignenvectors, the eignevalues are subtracted from the diagonal in equationss \((n.1)\) above and then the matrices are reduced to row echelon form in equations \((n.2)\) above. The eignenvectors are the resulting solutions to the system which have been normalized to unit length in equations \((n.3)\) above in order to allow for comparison with the values calculated by R.iii,iv
eigen(A)$vectors
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0