In this assignment we’ll use functions from the Matrix
package in R to verify our work.
library('Matrix')
What is the rank of the matrix A?
\[ A= \left[ {\begin{array}{cccc} 1 & 2 & 3 & 4 \\ -1 & 0 & 1 & 3 \\ 0 & 1 & -2 & 1 \\ 5 & 4 & -2 & -3 \\ \end{array} } \right] \]
Let’s Row-Reduce until it’s obvious what rank the matrix is.
\[ A= \left[ {\begin{array}{cccc} 1 & 2 & 3 & 4 \\ 0 & 2 & 4 & 7 \\ 0 & 1 & -2 & 1 \\ 0 & -6 &-17 &-23 \\ \end{array} } \right] \]
\[ A= \left[ {\begin{array}{cccc} 1 & 2 & 3 & 4 \\ 0 & 1 & -2 & 1 \\ 0 & 0 & 8 & 5 \\ 0 & 0 &-29 &-17 \\ \end{array} } \right] \]
By inspection, now, we can see that neither R3 and R4 encode the other and so are linearly independent and the rank of this matrix is 4.
Here we verify the matrix’s rank is 4 using R.
A <- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3),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
rankMatrix(A)[1]
## [1] 4
Given an \(mxn\) 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 mxn matrix, where m>n, is n. An mxn matrix, say a 4x2 matrix will have 4 rows and 2 columns. If the first two rows are linearly independent then the matrix has a rank of at least 2. Since there is no third dimension with a third variable, any possible row 3 can only be made up of a combination of the first two rows and so no subsequent row after the first two can be linearly independent or contribute to the rank of the matrix. So the maximum rank of an mxn matrix, where m>n, is n.
The minimum rank is 1. If the matrix is non-zero, the first row will be linearly independent and contribution at least a rank of 1 to the mxn matrix. If the subsequent m-1 rows are linearly dependent on the first row then they do not contribute to the rank of the matrix and we have a rank 1 matrix. If the first row were not linearly independent (even horizontal or vertical with a zero in one of the elements for an mx2 matrix) and none of the subseqent m-1 rows were linearly independent, then it would be the excluded possibility of a zero-matrix.
What is the rank of matrix B?
\[ B= \left[ {\begin{array}{ccc} 1 & 2 & 1 \\ 3 & 6 & 3 \\ 2 & 4 & 2 \\ \end{array} } \right] \]
By inspection the rank of this matrix is 1 because all of the rows are encoded by a single row.
I can multiply R1 by 3 to get R2, and I can multiply R1 by 2 to get R3
Here we confirm Matrix B has a rank of 1 using R.
B <- matrix(c(1,3,2,2,6,4,1,3,2),ncol=3)
B
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
rankMatrix(B)[1]
## [1] 1
Compute the eigenvalues and eigenvectors of the matrix C. You’ll need to show your work. You’ll need to write out the characteristic polynomial and show your solution.
\[ C= \left[ {\begin{array}{ccc} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \\ \end{array} } \right] \]
In order to get the eigenvalues we need to solve the characteristic equation: \(det(A-\lambda I)=0\)
Here we subtract lambda times the Identity matrix from matrix C.
\[ C= \left[ {\begin{array}{ccc} 1-\lambda & 2 & 3 \\ 0 & 4-\lambda & 5 \\ 0 & 0 & 6-\lambda \\ \end{array} } \right] \]
The determinant of a 3x3 matrix is the determinant of three 2x2 submatrices constructed in a special way. I’ve put them on separate lines for readability. Notice how the terms on the left are the elements of the top row, they alternate being positive and negative, and the terms in square brackets are the determinants of the 2x2 submatrices created when you remove the column below the first row element used on the left.
\(+(1-\lambda)[(4-\lambda)(6-\lambda)-(5)(0)]\)
\(-(2)[(0)(6-\lambda)-(5)(0)]\)
\(+(3)[(0)(0)-(4-\lambda)(0)]\)
\(=0\)
Because it’s an Upper Triangle Matrix, the eigenvalues turn out to be the elements of the diagonal. We’ll see that here as the terms with zero all drop off.
\((1-\lambda)(4-\lambda)(6-\lambda)-0+0=0\)
So the eigenvalues are the solutions to the characteristic equation: 1, 4, and 6.
To find the eigenvector corresponding to each eigenvalue we need to solve for the highest dimension vectors such that \((C-lambda I)*eigenvector = 0\). It ends up being a system of equations where you solve the elements of the eigenvector one at a time and whenever the value of one of the eigenvector’s elements could be zero or any number, you go with the higher dimension by selecting any real number, though for simplicity we’d pick 1.
By subtracting 1 from the diagonals, and imagining we are solving for the eigenvector such that \([C-1I]*eigenvector=0\) we get the following system of equations:
\((1-1)x+(2)y+(3)z=0\)
\((0)x+(4-1)y+(5)z=0\)
\((0)x+(0)y+(6-1)z=0\)
which simplifies to:
\((0)x+(2)y+(3)z=0\)
\((0)x+(3)y+(5)z=0\)
\((0)x+(0)y+(5)z=0\)
Since \((5)z=0\), \(z\) must be zero and the system simplifies to:
\((0)x+(2)y=0\)
\((0)x+(3)y=0\)
Since \((3)y=0\), \(y\) must be zero and the system simplifies to:
\((0)x=0\)
Since the coefficient is zero, \(x\) could be any number, not just zero, so we have to choose any number other than zero to capture the higher dimension here. Let’s choose 1 for simplicity.
And the eigenvector corresponding to \(\lambda=1\) is:
\[ \left[ {\begin{array}{ccc} 1 \\ 0 \\ 0 \\ \end{array} } \right] \]
By subtracting 4 from the diagonals, and imagining we are solving for the eigenvector such that \([C-4I]*eigenvector=0\) we get the following system of equations:
\((1-4)x+(2)y+(3)z=0\)
\((0)x+(4-4)y+(5)z=0\)
\((0)x+(0)y+(6-4)z=0\)
which simplifies to:
\((-3)x+(2)y+(3)z=0\)
\((0)x+(0)y+(5)z=0\)
\((0)x+(0)y+(2)z=0\)
Since \((5)z=0\) and \((2)z=0\), \(z\) must be zero and the system simplifies to:
\((-3)x+(2)y=0\)
To build out our vector we can pick \(x=1\) or \(y=1\) and the [x,y,z] vector that satisfies the equation will be scalars of each other either way. Let’s pick \(y=1\). Then \(x=2/3\).
And the eigenvector corresponding to \(\lambda=4\) is:
\[ \left[ {\begin{array}{ccc} 2/3 \\ 1 \\ 0 \\ \end{array} } \right] \]
By subtracting 6 from the diagonals, and imagining we are solving for the eigenvector such that \([C-6I]*eigenvector=0\) we get the following system of equations:
\((1-6)x+(2)y+(3)z=0\)
\((0)x+(4-6)y+(5)z=0\)
\((0)x+(0)y+(6-6)z=0\)
which simplifies to:
\((-5)x+(2)y+(3)z=0\)
\((0)x+(-2)y+(5)z=0\)
\((0)x+(0)y+(0)z=0\)
In Row 3, since \((0)z=0\), \(z\) can be any number, not just zero, so we have to choose any number other than zero to capture the higher dimension here. Let’s choose 1 for simplicity, and then the system simplifies to:
\((-5)x+(2)y+3=0\)
\((0)x+(-2)y+5=0\)
Then \(y=5/2\) and we are left with:
\((-5)x+8=0\)
Thus \(x=8/5\)
And the eigenvector corresponding to \(\lambda=6\) is:
\[ \left[ {\begin{array}{ccc} 8/5 \\ 5/2 \\ 1 \\ \end{array} } \right] \]
Note that the eigenvectors below are all unit length 1, but they scale to the ones we calculated by hand.
C <- matrix(c(1,0,0,2,4,0,3,5,6),ncol=3)
C
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
eigen(C)$values
## [1] 6 4 1
eigen(C)$vectors
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0
For column 2, we can verify it’s a scalar of \([2/3, 1, 0]\) by dividing every element by
0.8320503
.
0.5547002/0.8320503
## [1] 0.6666667
For column 1, we can verify it’s a scalar of \([8/5, 5/2, 1]\) by dividing every element
by 0.3192754
.
0.5108407/0.3192754
## [1] 1.6
0.7981886/0.3192754
## [1] 2.5