library(pracma)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
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
Rank(A)
## [1] 4
Matrix A has a rank of 4, meaning each vector comprising its columns is linearly independent. We can confirm this by reducing the matrix to its reduced row echelon form:
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
Because there are no 0 rows, we know the rank of matrix A is the same as its number of columns, or 4.
For an m x n matrix where m > n, the maximum rank would be n, the number of columns, as the smaller value. The minimum rank would be 1, because as long as it is not a zero matrix, there must be at least one linearly independent vector.
B = matrix(c(1,2,1,
3,6,3,
2,4,2))
Rank(B)
## [1] 1
The rank of matrix B is 1, which makes intuitive sense. Column 3 is identical to column 1, and column 2 is precisely 2 times column 1 (and, by definition, 3). That means there is only one linearly independent column in the matrix, hence a rank of 1.
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
In order to find the eigenvalues and eigenvectors for this matrix, I must first uncover its characteristic polynomial. This is done by substracting the identity matrix, scaled by my yet-unknown eigenvalue (which I’ll denote as λ), and taking the determinant of the resulting matrix. I’ll switch to latex here in order to incorporate my unknown variable.
\[ A = \begin{pmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{pmatrix} \]
\[ A - λI = \begin{pmatrix} 1-λ & 2 & 3 \\ 0 & 4-λ & 5 \\ 0 & 0 & 6-λ \end{pmatrix} \]
Next, we must take the determinant of this matrix, keeping the unknown λ intact. In the general matrix: \[ \begin{pmatrix} a & b & c \\ d & e & f \\ g & h & i \end{pmatrix} \]
The determinant is given by the formula:
\[ \det(M) = a(ei - fh) - b(di - fg) + c(dh - eg) \] In our case, that makes:
\[ \det(A - \lambda I) = (1 - \lambda)((4 - \lambda)(6 - \lambda) - 0) - 2(0 - 0) + 3(0 - 0) \]
Given all the zeroes from our original matrix, this simplifies our polynomial down considerably. Given all distributions and eliminations, we are left with:
\[ (1 - \lambda)(4 - \lambda)(6 - \lambda) \]
In order to solve for our eigenvalues, we set that polynomial equal to 0. The lambda values that would make the resulting equation equal zero are 1, 4, and 6, which we can understand as our eigenvalues.
Next, we must consider our eigenvectors. Those are the vectors that hold true for the following equation, for each eigenvalue λ:
\[ (A-\lambda I)v \]
That means we must find the value of \((A-\lambda I)\) for each λ, then find its nullspace (ie. the vector that, when multiplied by \((A-\lambda I)\) results in 0).
For \((\lambda = 1)\):
\[ (A-1*I) = \begin{pmatrix} 1-1 & 2 & 3 \\ 0 & 4-1 & 5 \\ 0 & 0 & 6-1 \end{pmatrix} = \begin{pmatrix} 0 & 2 & 3 \\ 0 & 3 & 5 \\ 0 & 0 & 5 \end{pmatrix} \] We can then find the nullspace of this matrix by treating it as a set of linear equations (set equal to zero) and solving for the unknowns. Treating those unknowns respectively as \(x, y\) and \(z\), we know that \(z\) must be equal to 0. Plugging 0 in for \(z\) in the second equation, we know \(y\) must also be zero. Lastly, this leaves \(x\) as a free variable, which we can set as 1 for simplicity. That leaves an eigenvector of \(v = \begin{pmatrix}1 \\ 0 \\ 0\end{pmatrix}\).
For \((\lambda = 4)\):
\[ (A-4*I) = \begin{pmatrix} 1-4 & 2 & 3 \\ 0 & 4-4 & 5 \\ 0 & 0 & 6-4 \end{pmatrix} = \begin{pmatrix} -3 & 2 & 3 \\ 0 & 0 & 5 \\ 0 & 0 & 2 \end{pmatrix} \] In this case (using the same system of equations methodology as above), we can see from the second two equations that \(z\) again must be 0. Plugging 0 in for \(z\) in the first equation leaves us with \(-3x + 2y = 0\). Solving for \(y\), we see get \(y = (3/2) x\), or 1.5 times whatever \(x\) is. Thus, if we let \(x=2\), \(y=3\). Our next eigenvector is then \(v = \begin{pmatrix}2 \\ 3 \\ 0\end{pmatrix}\)
Lastly, for \((\lambda = 6)\):
\[ (A-6*I) = \begin{pmatrix} 1-6 & 2 & 3 \\ 0 & 4-6 & 5 \\ 0 & 0 & 6-6 \end{pmatrix} = \begin{pmatrix} -5 & 2 & 3 \\ 0 & -2 & 5 \\ 0 & 0 & 0 \end{pmatrix} \] In the above system, we can only really work with the first to equations. Solving for \(z\) in the second equation, we move from \(-2y + 5z = 0\) to \(z = (2/5)y\). If we allow for \(y=10\), \(z\) would be equal to \(4\). Plugging those values into the first equation (set equal to 0), we have \(-5x + 2(10) + 3(4) = 0\), which simplifies to \(-5x = -32\), and finally \(x = 32/5\). We are left with the vector \(v = \begin{pmatrix}32/5 \\ 10 \\ 4\end{pmatrix}\). I will scale that a factor of \(5/2\) just to get all integers, resulting in \(v = \begin{pmatrix}16 \\ 25 \\ 10\end{pmatrix}\).
Therefore, my full vector space in the set of the following vectors: \[ \begin{pmatrix}1 \\ 0 \\ 0\end{pmatrix}, \begin{pmatrix}2 \\ 3 \\ 0\end{pmatrix}, and \begin{pmatrix}16 \\ 25 \\ 10\end{pmatrix} \]