Problem set 1
1. What is the rank of the matrix A? A =
\[
\begin{bmatrix}
1 & 2 & 3 & 4\\
-1 & 0 & 1 & 3\\
0 & 1 & -2 & 1\\
5 & 4 & -2 & -3\\
\end{bmatrix}
\]
library(pracma)
A1 = matrix(c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3), nrow = 4, byrow = T)
rref(A1)
## [,1] [,2] [,3] [,4]
## [1,] 1 0 0 0
## [2,] 0 1 0 0
## [3,] 0 0 1 0
## [4,] 0 0 0 1
This is the \(I_4/\) matrix - rank is therefore 4. Each row and column are linearly independent.
??? ??? ??? ??? 2. 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 is n. If the matrix has fewer than n linear independent columns, the rank will be < n.
3. What is the rank of matrix B? B =
\[
\begin{bmatrix}
1 & 2 & 1\\
3 & 6 & 3\\
2 & 4 & 2\\
\end{bmatrix}
\]
library(Matrix)
##
## Attaching package: 'Matrix'
## The following objects are masked from 'package:pracma':
##
## expm, lu, tril, triu
A3 = matrix(c(1,2,1,3,6,3,2,4,2), nrow = 3, byrow = T)
#reduced row echelon form
rref(A3)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] 0 0 0
#using rankMatrix function from Matrix package
rankMatrix(A3)[1]
## [1] 1
Matrix has one (non-zero) linearly independent row, so it’s rank is 1. Verified by rankMatrix function.
???
Problem set 2
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}
\]
Step 1. Get determinant.
A2 = matrix(c(1,2,3,0,4,5,0,0,6), nrow = 3, byrow = T)
A2
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
From this week’s lecture:
To find eigenvalues and eigenvectors, we take the determinant of a special matrix and set it to zero:
det(A - \(\lambda\)I) = 0
This gives rise to a polynomial equation in terms of ?? called the characteristic polynomial.
To solve, using x in place of lamda:
\[
det(
\begin{bmatrix}
1 & 2 & 3\\
0 & 4 & 5\\
0 & 0 & 6\\
\end{bmatrix} -
\begin{bmatrix}
x & 0 & 0\\
0 & x & 0\\
0 & 0 & x\\
\end{bmatrix}
) = 0
\]
\[
det(
\begin{bmatrix}
1 - x & 2 & 3\\
0 & 4 - x & 5\\
0 & 0 & 6 - x\\
\end{bmatrix}
) = 0
\]
\[
(1 - x) * det(
\begin{bmatrix}
4 - x & 5\\
0 & 6 - x\\
\end{bmatrix}
) - 2 * det(
\begin{bmatrix}
0 & 5\\
0 & 6 - x\\
\end{bmatrix}
) + 3 * det(
\begin{bmatrix}
0 & 1 - x\\
0 & 2\\
\end{bmatrix}
)
\]
(1 - x)(x^2 - 10x + 24) - 2(0) + 3(0) x^2 - 10x + 24 - x^3 + 10x^2 - 24x Characteristic polynomial: -x^3 + 11x^2 - 34x + 24
Factored: (-x+1)(x-6)(x-4)
So our eigenvalues are 1, 6, and 4.
To get eigenvectors, we plug these values into the lambda/x equations above.
\[ (
\begin{bmatrix}
1 & 2 & 3\\
0 & 4 & 5\\
0 & 0 & 6\\
\end{bmatrix} -
\begin{bmatrix}
1 & 0 & 0\\
0 & 1 & 0\\
0 & 0 & 1\\
\end{bmatrix}) *
\begin{bmatrix}
v_1\\
v_2\\
v_3\\
\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}
= 0
\]
Let’s use r to get the rref:
B1 = matrix(c(0,2,3,0,3,5,0,0,5), nrow = 3, byrow = T)
rref(B1)
## [,1] [,2] [,3]
## [1,] 0 1 0
## [2,] 0 0 1
## [3,] 0 0 0
$x_2 = 0 $/ $x_3 = 0 $/ So \(x_2 = x_3 = 0\)/ and \(x_1\)/ is a free variable, which we’ll make 1.
\[ e_1 =
\begin{bmatrix}
1\\
0\\
0\\
\end{bmatrix}
\]
Repeat for eigenvalue 4. \[ (
\begin{bmatrix}
1 & 2 & 3\\
0 & 4 & 5\\
0 & 0 & 6\\
\end{bmatrix} -
\begin{bmatrix}
4 & 0 & 0\\
0 & 4 & 0\\
0 & 0 & 4\\
\end{bmatrix}) *
\begin{bmatrix}
v_1\\
v_2\\
v_3\\
\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}
= 0
\]
Let’s use r to get the rref:
B2 = matrix(c(-3,2,3,0,0,5,0,0,2), nrow = 3, byrow = T)
rref(B2)
## [,1] [,2] [,3]
## [1,] 1 -0.6666667 0
## [2,] 0 0.0000000 1
## [3,] 0 0.0000000 0
$x_1 - (2/3)*x_2 = 0 $/ $x_3 = 0 $/ So \(x_3 = 0\)/ and \(x_1 = 2/3\)/ and \(x_2 = 1\)/.
\[ e_4 =
\begin{bmatrix}
2/3\\
1\\
0\\
\end{bmatrix}
\]
Repeat for eigenvalue 6. \[ (
\begin{bmatrix}
1 & 2 & 3\\
0 & 4 & 5\\
0 & 0 & 6\\
\end{bmatrix} -
\begin{bmatrix}
6 & 0 & 0\\
0 & 6 & 0\\
0 & 0 & 6\\
\end{bmatrix}) *
\begin{bmatrix}
v_1\\
v_2\\
v_3\\
\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}
= 0
\]
Let’s use r to get the rref:
B3 = matrix(c(-5,2,3,0,-2,5,0,0,0), nrow = 3, byrow = T)
rref(B3)
## [,1] [,2] [,3]
## [1,] 1 0 -1.6
## [2,] 0 1 -2.5
## [3,] 0 0 0.0
$x_1 - 1.6x_3 = 0 $/ $x_2 - 2.5x_3 = 0 $/ So \(x_1 = 1.6\)/ and \(x_2 = 2.5\)/ and \(x_3 = 1\)/.
\[ e_6 =
\begin{bmatrix}
1.6\\
2.5\\
1\\
\end{bmatrix}
\]
Our eigenvectors are: \[
\begin{bmatrix}
1.6\\
2.5\\
1\\
\end{bmatrix}
,
\begin{bmatrix}
2/3\\
1\\
0\\
\end{bmatrix}
,
\begin{bmatrix}
1\\
0\\
0\\
\end{bmatrix}
\]
Checking work in R.
#characteristic polynomial
charpoly(A2)
## [1] 1 -11 34 -24
eA2 = eigen(A2)
#eigenvalues
eA2$values
## [1] 6 4 1
#eigenvector
eA2$vectors
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0
Please show your work using an R-markdown document. Please name your assignment submission with your ???rst initial and last name.