#install.packages("MASS")
library(MASS)
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}\)
To solve we need row echelon form:
Row operations Column 1: [2,1] must equal 0:
Calculation: Row1+Row2
\(\begin{bmatrix} 1 & 2 & 3 &
4 \\ 0 & 2 & 4 & 7 \\ 0 & 1 &-2 & 1 \\ 5
& 4 &-2 &-3 \end{bmatrix}\)
Row operations Column 1: [4,1] must equal 0:
Calculation:-5*Row1 +Row4
\(\begin{bmatrix} 1 & 2 & 3 &
4 \\ 0 & 2 & 4 & 7 \\ 0 & 1 &- 2 & 1 \\ 0
&-6 &-17 &-23 \end{bmatrix}\)
Row operations Column 2: [3,2] must equal 0:
Calculation:-1/2*Row1 +Row3
\(\begin{bmatrix} 1 & 2 & 3 &
4 \\ 0 & 2 & 4 & 7 \\ 0 & 0 & -4 & -2.5 \\ 0
&-6 &-17 &-23 \end{bmatrix}\)
Row operations Column 2: [4,2] must equal 0:
Calculation:3*Row2 +Row4
\(\begin{bmatrix} 1 & 2 & 3 &
4 \\ 0 & 2 & 4 & 7 \\ 0 & 0 & -4 & -2.5 \\ 0
& 0 & -5 & -2 \end{bmatrix}\)
Row operations Column 3: [4,3] must equal 0:
Calculation:5/4*Row3 +Row4
\(\begin{bmatrix} 1 & 2 & 3 &
4 \\ 0 & 2 & 4 & 7 \\ 0 & 0 & -4 & -2.5 \\ 0
& 0 & 0 & 1.125 \end{bmatrix}\)
This is echelon form and since no rows are all zero the rank of the matrix is 4.
Below the rankMatrix function validates that the rank is 4.
library(Matrix)
A <- matrix(data = c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3), nrow = 4, ncol = 4, byrow = TRUE)
rank_A <- rankMatrix(A)
rank_A
## [1] 4
## attr(,"method")
## [1] "tolNorm2"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 8.881784e-16
2. Given an mxn matrix where m > n, what can be the
maximum rank? The minimum rank, assuming that the matrix is
non-zero?
Given an m x n matrix where m > n, the maximum rank would be n. This
is because the rank is limited by the smallest number/value, which in
this case is n. The minimum rank of this matrix, assuming that the
matrix is non-zero, is one because one row or column would necessarily
be linearly independent.
3. What is the rank of matrix B?
B =\(\begin{bmatrix}1 & 2 & 1 \\ 3 & 6 & 3 \\ 2 & 4 & 2\end{bmatrix}\)
To solve we need row echelon form:
Row operations Column 1: [2,1] must equal 0:
-1/3*Row1+Row2
\(\begin{bmatrix} 1 & 2 & 1 \\ 0 & 0 & 0 \\ 2 & 4 & 2 \end{bmatrix}\)
Row operations Column 1: [3,1] must equal 0:
-2*Row1+Row2
\(\begin{bmatrix} 1 & 2 & 1 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}\)
The rank is 1 since row 2 and row 3 are all zero.
Below the rank() function validates that the rank is 1.
B <- matrix(data = c(1,2,1,3,6,3,2,4,2), nrow = 3, ncol = 3, byrow = TRUE)
rank_B <- rankMatrix(B)
rank_B
## [1] 1
## attr(,"method")
## [1] "tolNorm2"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 6.661338e-16
4. 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}\)
A. Finding the Characteristic Polynomial \(\begin{bmatrix}1-λ & 2 & 3 \\0 & 4-λ & 5\\ 0 & 0 & 6-λ\end{bmatrix}\) \[{((1-λ)(4-λ)(6-λ)-0)}\] \[{4-1λ-4λ+x^2}\] \[{(4-5λ+x^2)(6-λ)}\] This is the characteristic polynominal \[{24-34λ+11λ^2-λ^3}\]
B. Finding eigenvalues
Next we plug the numbers 1, 4 and 6 into characteristic polynomial to determine if those make the equation equal zero and are thus eigenvalues:
Solving for λ using the number 1: \[{24-34(1)+11(1)^2-1(1)^3= 24-34+11-1 = 0}\]
Solving for λ using the number 4: \[{24-34(4)+11(4)^2-(4)^3) = 24-136+176-64 = 200-200 = 0}\] Solving for λ using the number 6: \[{24-34(6)+11(6)^2-(6)^3) = 24-204+396-216 = 420-420 = 0}\] 1, 4 and 6 are indeed the eigenvalues.
C. Finding the Eigenvectors
Below the eigen values are validated to be 1,4 and 6. Eigan vectors are calculated using the eigan function.
a = matrix(c(1,0,0,2,4,0,3,5,6), ncol = 3, nrow = 3)
# find eigenvalues and eigenvectors
eigen(a)
## 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