The rank of a matrix is defined as (a) the maximum number of linearly independent column vectors in the matrix or (b) the maximum number of linearly independent row vectors in the matrix. Both definitions are equivalent.
A = matrix(c(1, -1, 0, 5, 2, 0, 1, 4, 3, 1, -2, -2, 4, 3, 1, -3), nrow = 4, ncol = 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
factorize <- function(A){
if (nrow(A) == 2){
value <- -A[2,1] / A[1,1]
multiply <- matrix(c(1, value, 0, 1), nrow=2, ncol=2)
lower_triangular_matrix <- multiply %*% A
} else if (nrow(A) == 3){
value <- (A[,1]/(-1*A[1,1]))
multiply <- matrix(c(1, value[2], value[3], 0, 1, 0, 0, 0, 1), nrow=3, ncol=3)
transformation_1 <- multiply %*% A
value_2 <- -1*(transformation_1[3,2]/transformation_1[2,2])
multiply_2 <- matrix(c(1, 0, 0, 0, 1, value_2, 0, 0, 1), nrow=3, ncol=3)
lower_triangular_matrix <- multiply_2 %*% transformation_1
} else if (nrow(A) == 4){
value <- (A[,1]/(-1*A[1,1]))
multiply <- matrix(c(1, value[2], value[3], value[4], 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), nrow=4, ncol=4)
transformation_1 <- multiply %*% A
value_1 <- (transformation_1[,2]/(-1*transformation_1[2,2]))
multiply_1 <- matrix(c(1, 0, 0, 0, 0, 1, value_1[3], value_1[4], 0, 0, 1, 0, 0, 0, 0, 1), nrow=4, ncol=4)
transformation_2 <- round(multiply_1 %*% transformation_1, 1)
value_2 <- round((-1*(transformation_2[4,3])/(transformation_2[3,3])), 1)
multiply_2 <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, value_2, 0, 0, 0, 1), nrow=4, ncol=4)
lower_triangular_matrix <- round(multiply_2 %*% transformation_2, 0) #account for rounding errors
}
return (list(lower_triangular_matrix = lower_triangular_matrix))
}
factorize(A)
## $lower_triangular_matrix
## [,1] [,2] [,3] [,4]
## [1,] 1 2 3 4
## [2,] 0 2 4 7
## [3,] 0 0 -4 -2
## [4,] 0 0 0 1
Using the function from the previous homework, we can see that each row is linearly idependent, therefore the rank of matrix A is 4.
y <- qr(A)
y$rank
## [1] 4
For an m x n matrix,
If m < n, then the maximum rank of the matrix is m. If m > n, then the maximum rank of the matrix is n.
Maximum rank where m > n is n.
B = matrix(c(1, 3, 2, 2, 6, 4, 1, 3, 2), nrow = 3, ncol = 3)
B
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
factorize(B)
## $lower_triangular_matrix
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] NaN NaN NaN
There is only one linearaly independent row in matrix B, therefore it has a rank of 1.
y <- qr(B)
y$rank
## [1] 1
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 = matrix(c(1, 0, 0, 2, 4, 0, 3, 5, 6), nrow = 3, ncol = 3)
A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
λ is an eigenvalue of A if Av = λx for some non zero v
det(λIn - A) = 0 where
\[ λI~n~ = λ \left(\begin{array}{cc} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \end{array}\right) = \left(\begin{array}{cc} λ & 0 & 0\\ 0 & λ & 0\\ 0 & 0 & λ\\ \end{array}\right) \]
\[ \left(\begin{array}{cc} λ & 0 & 0\\ 0 & λ & 0\\ 0 & 0 & λ\\ \end{array}\right) - \left(\begin{array}{cc} 1 & 2 & 3\\ 0 & 4 & 5\\ 0 & 0 & 6\\ \end{array}\right) = \left(\begin{array}{cc} λ - 1 & -2 & -3\\ 0 & λ-4 & -5\\ 0 & 0 & λ-6\\ \end{array}\right) \]
\[ (λI~n~ - A) = \left(\begin{array}{cc} λ - 1 & -2 & -3\\ 0 & λ-4 & -5\\ 0 & 0 & λ-6\\ \end{array}\right) \left(\begin{array}{cc} λ - 1 & -2\\ 0 & λ-4\\ 0 & 0 \end{array}\right) \]
\[ (((λ-1)(λ-4)(λ-6))+0+0) - 0(λ-6) - 0(λ-1) - 0(λ-4) = λ^3 - 5λ^2 + 4λ - 24 \] The characteristic polynomial is:
\[ λ^3 - 5λ^2 + 4λ - 24 = (λ-1) * (λ-4)* (λ-6) \]
Therefore the Eigenvalues of A are,
λ1 = 1 λ2 = 4 λ3 = 6
When λ = 1
\[ \left(\begin{array}{cc} 1 - 1 & -2 & -3\\ 0 & 1-4 & -5\\ 0 & 0 & 1-6\\ \end{array}\right) = \left(\begin{array}{cc} 0 & -2 & -3\\ 0 & -3 & -5\\ 0 & 0 & -5\\ \end{array}\right)= RREF-> \left(\begin{array}{cc} 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ \end{array}\right) \] When we solve the system,
\[ \left(\begin{array}{cc} 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ \end{array}\right) \left(\begin{array}{cc} v1 \\ v2 \\ v3 \\ \end{array}\right)= \left(\begin{array}{cc} 0 \\ 0 \\ 0 \\ \end{array}\right) \] v1 is a free variable, v2 = 0 and v3 = 0. Therefore, the eigenspace when λ = 1 is
\[ span \left(\begin{array}{cc} v1 \\ 0 \\ 0 \\ \end{array}\right) \]
When λ = 4
\[ \left(\begin{array}{cc} 4 - 1 & -2 & -3\\ 0 & 4-4 & -5\\ 0 & 0 & 4-6\\ \end{array}\right) = \left(\begin{array}{cc} 2 & -2 & -3\\ 0 & 0 & -5\\ 0 & 0 & -2\\ \end{array}\right) = RREF-> \left(\begin{array}{cc} 1 & -1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ \end{array}\right) \] When we solve the system,
\[ \left(\begin{array}{cc} 1 & -1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0\\ \end{array}\right) \left(\begin{array}{cc} v1 \\ v2 \\ v3 \\ \end{array}\right)= \left(\begin{array}{cc} 0 \\ 0 \\ 0 \\ \end{array}\right) \]
v1 is a free variable, v2 = 0 and v3 = 0. Therefore, the eigenspace when λ = 1 is
\[ span \left(\begin{array}{cc} 0 \\ 0 \\ 0 \\ \end{array}\right) \]
When λ = 6
\[ \left(\begin{array}{cc} 6 - 1 & -2 & -3\\ 0 & 6-4 & -5\\ 0 & 0 & 6-6\\ \end{array}\right) = \left(\begin{array}{cc} 5 & -2 & -3\\ 0 & 2 & -5\\ 0 & 0 & 0\\ \end{array}\right) = RREF-> \left(\begin{array}{cc} 1 & 0 & -1.6\\ 0 & 1 & -2.5\\ 0 & 0 & 0\\ \end{array}\right) \]
When we solve the system,
\[ \left(\begin{array}{cc} 1 & 0 & -1.6\\ 0 & 1 & -2.5\\ 0 & 0 & 0\\ \end{array}\right) \left(\begin{array}{cc} v1 \\ v2 \\ v3 \\ \end{array}\right)= \left(\begin{array}{cc} 0 \\ 0 \\ 0 \\ \end{array}\right) \]
v1 is a free variable, v2 = 0 and v3 = 0. Therefore, the eigenspace when λ = 1 is
\[ span \left(\begin{array}{cc} 1.6 \\ 2.5 \\ 0 \\ \end{array}\right) \]