Problem Set 1
(1): What is the rank of matrix \(A\)?
\[ A = \begin{bmatrix} 1 & 2 & 3 & 4\\ -1 & 0 & 1 & 3\\ 0 & 1 & -2 & 1\\ 5 & 4 & -2 & -3 \end{bmatrix} \]
The rank of a matrix is the maximum number of linearly independent column or row vectors in a matrix. Matrix \(A\) has 4 non-zero pivots when you reduce it to row-echelon form, so the rank of the matrix is 4.
A <- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,3), nrow=4, ncol=4)
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
(2) Given an \(m \times n\) matrix where \(m>n\), what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?
The maximum rank of an \(m \times n\) matrix is the rank of the smaller dimension, so \(n\). If the matrix is non-zero, and has at least 1 element, then the minimum rank is 1.
(3) What is the rank of matrix \(B\)?
\[ B = \begin{bmatrix} 1 & 2 & 1\\ 3 & 6 & 3\\ 2 & 4 & 2\\ \end{bmatrix} \]
The rank of matrix \(B\) is 1. When we reduce the matrix to row echelon form (below), we only get 1 pivot. This is because the rows are linearly dependent — two of the rows are actually multiples of row 1.
- \(R_2 = R_1 \times 3\)
- \(R_3 = R_1 \times 2\)
B <- matrix(c(1,3,2,2,6,4,1,3,2), nrow=3)
rref(B)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] 0 0 0
Problem Set 2
Compute the eigenvalues and eigenvectors of the matrix \(A\).
\[ A = \begin{bmatrix} 1 & 2 & 3\\ 0 & 4 & 5\\ 0 & 0 & 6\\ \end{bmatrix} \]
EIGENVALUES
To find the eigenvalues of \(A\), we need to construct the characteristic polynomial of \(A\) using the equation below and solve for the roots.
\[ \text{det}(A - \lambda I)=0, \\ \]
\(\lambda\) is some scalar and \(I\) is the identity matrix.
\[ \begin{align} A-\lambda I &= \begin{bmatrix} 1 & 2 & 3\\ 0 & 4 & 5\\ 0 & 0 & 6\\ \end{bmatrix} - \begin{bmatrix} \lambda & 0 & 0\\ 0 & \lambda & 0\\ 0 & 0 & \lambda \end{bmatrix} \\ \\&= \begin{bmatrix} 1-\lambda & 2-0 & 3-0\\ 0-0 & 4-\lambda & 5-0\\ 0-0 & 0-0 & 6-\lambda\\ \end{bmatrix} \\ \\&= \begin{bmatrix} 1-\lambda & 2 & 3\\ 0 & 4-\lambda & 5\\ 0 & 0 & 6-\lambda\\ \end{bmatrix} \end{align} \]
The result is an upper triangular matrix. The determinant of an upper triangular matrix is the product of the elements along the diagonal.
\[ \begin{align} |A-\lambda I| &= (1-\lambda)(4-\lambda)(6-\lambda)\\ \\ &= (\lambda^2 - 5\lambda +4)(6-\lambda)\\ \\ &= -\lambda^3 + 6\lambda^2 + 29\lambda + 24 && \text{the characteristic polynomial}\\ \end{align} \]
The roots of the characteristic polynomial give us three eigenvalues:
\(\qquad \lambda_1 = 1\) \(\qquad \lambda_2 = 4\) \(\qquad \lambda_3 = 6\)
EIGENVECTOR FOR \(\lambda_1 = 1\)
To find the eigenvector for \(\lambda_1\), we need to solve this equation for \(\mathbf{v}\):
\[ (A - \lambda I)\ \mathbf{v} = \mathbf{0} \]
Let’s plug in the first eigenvalue, \(\lambda_1\):
\[ \begin{align} \begin{bmatrix} 1-1 & 2 & 3\\ 0 & 4-1 & 5\\ 0 & 0 & 6-1\\ \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3\\ \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 0\\ \end{bmatrix} &= \begin{bmatrix} 0 & 2 & 3\\ 0 & 3 & 5\\ 0 & 0 & 5\\ \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3\\ \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 0\\ \end{bmatrix} && \text{plug in } 1 \text{ for } \lambda\\ \\ \\&= \begin{cases} 2v_2 \quad + &3v_3 &= 0 \\ 3v_2 \quad + &5v_3 &= 0 \\ &5v_3 &= 0 \end{cases} && \text{to get this system of equations}\\ \end{align} \]
When we solve for this system, \(v_1\) does not appear, and \(v_2\) and \(v_3\) both result in \(0\).
Therefore, the only non-zero solution is the first eigenvector \(\mathbf{v} = (1, 0, 0)\).
EIGENVECTOR FOR \(\lambda_2 = 4\)
Let’s plug in the second eigenvalue, \(\lambda_2\):
\[ \begin{align} \begin{bmatrix} 1-4 & 2 & 3\\ 0 & 4-4 & 5\\ 0 & 0 & 6-4\\ \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3\\ \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 0\\ \end{bmatrix} &= \begin{bmatrix} -3 & 2 & 3\\ 0 & 0 & 5\\ 0 & 0 & 2\\ \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3\\ \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 0\\ \end{bmatrix} && \text{plug in } 4 \text{ for } \lambda\\ \\ \\&= \begin{cases} -3v_1 &+ &2v_2 &+ &3v_3 &= 0 \\ &&&&5v_3 &= 0 \\ &&&&2v_3 &= 0 \end{cases} && \text{to get this system of equations}\\ \end{align} \]
From this system, we see that \(v_3=0\). If we set \(v_2=1\), then we can solve for \(v_1\):
\[ \begin{align} -3v_1 + 2(1) + 3(0) &= 0 \\ -3v_1 &= -2 \\ v_1 &= \frac{2}{3} \end{align} \]
Therefore, the second eigenvector is \(\mathbf{v} = (\frac{2}{3}, 1, 0)\).
EIGENVECTOR FOR \(\lambda_3 = 6\)
Let’s plug in the third eigenvalue, \(\lambda_3\):
\[ \begin{align} \begin{bmatrix} 1-6 & 2 & 3\\ 0 & 4-6 & 5\\ 0 & 0 & 6-6\\ \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3\\ \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 0\\ \end{bmatrix} &= \begin{bmatrix} -5 & 2 & 3\\ 0 & -2 & 5\\ 0 & 0 & 0\\ \end{bmatrix} \begin{bmatrix} v_1\\ v_2\\ v_3\\ \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 0\\ \end{bmatrix} && \text{plug in } 6 \text{ for } \lambda\\ \\ \\&= \begin{cases} -5v_1 &+ &2v_2 &+ &3v_3 &= 0 \\ &&-2v_2 &+ &5v_3 &= 0 \end{cases} && \text{to get this system of equations}\\ \end{align} \]
If we set \(v_2 = 1\), then:
\[ \begin{align} -2(1) + 5v_3 &= 0\\ 5v_3 &= 2\\ v_3 &= \frac{2}{5} \end{align} \]
We can then plug in \(v_2\) and \(v_3\) into the first equation to find \(v_1\):
\[ \begin{align} -5v_1 + 2(1) + 3(\frac{2}{5}) &= 0 \\ \\ -5v_1 + \frac{16}{5} &= 0 \\ -5v_1 &= \frac{-16}{5} \\ v_1 &= \frac{16}{25} \end{align} \]
Therefore, the third eigenvector is \(\mathbf{v} = (\frac{16}{25}, 1, \frac{2}{5})\).
TEST
To test the accuracy of my calculations, we can use the
eigen
function in base R. The function returns eigenvalues and eigenvectors in unit vector form.
A <- matrix(c(1,0,0,2,4,0,3,5,6), nrow=3)
e <- eigen(A)
e
## eigen() decomposition
## $values
## [1] 6 4 1
##
## $vectors
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0
Convert each eigenvector into unit vector form using a function:
# Assign the eigenvectors I found to variables
e1 <- c(1, 0, 0)
e2 <- c(2/3, 1, 0)
e3 <- c(16/25, 1, 2/5)
# Create the unit vector function and apply to each eigenvector
unit_vector <- function(x) {
x / sqrt(sum(x^2))
}
u1 <- unit_vector(e1)
u2 <- unit_vector(e2)
u3 <- unit_vector(e3)
# Create a matrix with all unit vectors
uv <- matrix(c(u3, u2, u1), nrow=3)
uv
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0
The output of my function matches the output of the
eigen
function, so my calculations were accurate.
round(uv,7) == round(e$vectors, 7)
## [,1] [,2] [,3]
## [1,] TRUE TRUE TRUE
## [2,] TRUE TRUE TRUE
## [3,] TRUE TRUE TRUE
Sources
Stat Trek: Matrix Rank
StackOverflow: In R, what’s the simplest way to scale a vector to a unit vector?