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}\]

In order to find the rank of the matrix A we have to transform the matrix A to its row echelon form and count the number of non-zero rows.

#build the inial matrix
A = matrix(c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3),nrow=4,  ncol=4, byrow = TRUE)
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
#row2<-row1+row2  
A[2,] = A[1,] + A[2,]
A
##      [,1] [,2] [,3] [,4]
## [1,]    1    2    3    4
## [2,]    0    2    4    7
## [3,]    0    1   -2    1
## [4,]    5    4   -2   -3
#row2<-row2/row1 
A[2,] = A[2,]/A[1,]
A
##      [,1] [,2]      [,3]  [,4]
## [1,]    1    2  3.000000  4.00
## [2,]    0    1  1.333333  1.75
## [3,]    0    1 -2.000000  1.00
## [4,]    5    4 -2.000000 -3.00
#row4<-row4-5row1 
A[4,] = A[4,] - 5*A[1,]
A
##      [,1] [,2]       [,3]   [,4]
## [1,]    1    2   3.000000   4.00
## [2,]    0    1   1.333333   1.75
## [3,]    0    1  -2.000000   1.00
## [4,]    0   -6 -17.000000 -23.00
#row3<-row3-row2
A[3,] = A[3,] - A[2,]
A
##      [,1] [,2]       [,3]   [,4]
## [1,]    1    2   3.000000   4.00
## [2,]    0    1   1.333333   1.75
## [3,]    0    0  -3.333333  -0.75
## [4,]    0   -6 -17.000000 -23.00
#row4<-6row2+row4
A[4,] = 6*A[2,] + A[4,]
A
##      [,1] [,2]      [,3]   [,4]
## [1,]    1    2  3.000000   4.00
## [2,]    0    1  1.333333   1.75
## [3,]    0    0 -3.333333  -0.75
## [4,]    0    0 -9.000000 -12.50
#row3<-row3/element[3,3]
A[3,] = A[3,]/A[3,3]
A
##      [,1] [,2]      [,3]    [,4]
## [1,]    1    2  3.000000   4.000
## [2,]    0    1  1.333333   1.750
## [3,]    0    0  1.000000   0.225
## [4,]    0    0 -9.000000 -12.500
#row4<-9row3+row4
A[4,] = 9*A[3,] + A[4,]
A
##      [,1] [,2]     [,3]    [,4]
## [1,]    1    2 3.000000   4.000
## [2,]    0    1 1.333333   1.750
## [3,]    0    0 1.000000   0.225
## [4,]    0    0 0.000000 -10.475
  1. Given an m x n matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?

The rank of a matrix equals to the number of non-zero rows of row echelon matrix. If matrix has m rows then there are a possibility that all rows of row echelon matrix are non-zero. So that, the maximum rank of a matrix is m.

  1. What is the rank of matrix B?

\[B = \begin{bmatrix} 1 & 2 & 1 \\ 3 & 6 & 3 \\ 2 & 4 & 2 \\ \end{bmatrix}\]

In order to find the rank of the matrix B we have to transform the matrix A to its row echelon form and count the number of non-zero rows.

#build the inial matrix
B = matrix(c(1,2,1,3,6,3,2,4,2),nrow=3,  ncol=3, byrow = TRUE)
B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
#row2<-row2-3row1
B[2,] = B[2,] -  3*B[1,]
B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    2    4    2
#swap row2 and row3
x = B[2,]
B[2,] = B[3,]
B[3,] = x
B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    2    4    2
## [3,]    0    0    0
#row2<-row2-2row1
B[2,] = B[2,] -  2*B[1,]
B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    0    0    0

The number of non-zero rows in row echelon matrix is 1. So that, the rank of matrix B is 1.

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}\]

Let’s calculate eigenvalues

\[det( \begin{bmatrix} 1 - {\lambda} & 2 & 3 \\ 0 & 4 - {\lambda} & 5 \\ 0 & 0 & 6 - {\lambda} \\ \end{bmatrix})=0\]

(1 - \({\lambda}\))(4 - \({\lambda}\))(6 - \({\lambda}\)) = 0

The eigenvalues are

\({\lambda}_1\)=1, \({\lambda}_2\)=4, \({\lambda}_3\)=6

Let’s check eigenvalues using the built-in function ‘eigen’

#build the inial matrix
A = matrix(c(1,2,3,0,4,5,0,0,6),nrow=3,  ncol=3, byrow = TRUE)
A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0    4    5
## [3,]    0    0    6
print(eigen(A)$values)
## [1] 6 4 1

Now, let’s calculate eigenvectors

  1. \({\lambda}_1\)=1

\[\left[ \begin{array}{cc} 1-1 & 2 & 3 \\ 0 & 4-1 & 5 \\ 0 & 0 & 6-1 \end{array} \right] % \left[ \begin{array}{cc} x_1 \\ x_2 \\ x_3 \end{array} \right] = \left[ \begin{array}{cc} 0 \\ 0 \\ 0 \end{array} \right]\]

\[\left[ \begin{array}{cc} 0 & 2 & 3 \\ 0 & 3 & 5 \\ 0 & 0 & 5 \end{array} \right] % \left[ \begin{array}{cc} x_1 \\ x_2 \\ x_3 \end{array} \right] = \left[ \begin{array}{cc} 0 \\ 0 \\ 0 \end{array} \right]\]

\(2*x_2+3*x_3=0\)

\(3*x_2+5*x_3=0\)

\(5*x_3=0\)

\(x_1\) is a free variable \(x_1=1\)

\(x_3=0\) \(=>\) \(2*x_2+3*0=0\) \(=>\) \(x_2=0\)

\[x_{\lambda=1}=\begin{bmatrix} 1 \\0 \\0\end{bmatrix}\]

  1. \({\lambda}_2\)=4

\[\left[ \begin{array}{cc} 1-4 & 2 & 3 \\ 0 & 4-4 & 5 \\ 0 & 0 & 6-4 \end{array} \right] % \left[ \begin{array}{cc} x_1 \\ x_2 \\ x_3 \end{array} \right] = \left[ \begin{array}{cc} 0 \\ 0 \\ 0 \end{array} \right]\]

\[\left[ \begin{array}{cc} -3 & 2 & 3 \\ 0 & 0 & 5 \\ 0 & 0 & 2 \end{array} \right] % \left[ \begin{array}{cc} x_1 \\ x_2 \\ x_3 \end{array} \right] = \left[ \begin{array}{cc} 0 \\ 0 \\ 0 \end{array} \right]\]

\(-3*x_1+2*x_2+3*x_3=0\)

\(0*x_1+0*x_2+5*x_3=0\)

\(0*x_1+0*x_2+2*x_3=0\)

\(x_2=1\)

\(0*x_1+0*x_2+2*x_3=0\) \(=>\) \(x_3=0\)

\(-3*x_1+2*x_2+3*0=0\) \(=>\) \(3*x_1=2*x_2\) , \(x_1=2*1/3=2/3\)

\[x_{\lambda=1}=\begin{bmatrix} 2/3 \\1 \\0\end{bmatrix}\]

  1. \({\lambda}_3\)=6

\[\left[ \begin{array}{cc} 1-6 & 2 & 3 \\ 0 & 4-6 & 5 \\ 0 & 0 & 6-6 \end{array} \right] % \left[ \begin{array}{cc} x_1 \\ x_2 \\ x_3 \end{array} \right] = \left[ \begin{array}{cc} 0 \\ 0 \\ 0 \end{array} \right]\]

\[\left[ \begin{array}{cc} -5 & 2 & 3 \\ 0 & -2 & 5 \\ 0 & 0 & 0 \end{array} \right] % \left[ \begin{array}{cc} x_1 \\ x_2 \\ x_3 \end{array} \right] = \left[ \begin{array}{cc} 0 \\ 0 \\ 0 \end{array} \right]\]

\(-5*x1+2*x2+3*x3=0\)

\(0*x1-2*x2+5*x3=0\)

\(0*x1+0*x2+0*x3=0\)

\(x_3\) is free variable, \(x_3=1\)

\(0*x_1-2*x_2+5*1=0\) \(=>\) \(-2*x_2+5*1=0\), \(-2*x_2=-5*1\), \(x_2=5/2\)

\(-5*x1+2*5/2+3*1=0\) \(=>\) \(-5*x1+5+3*1=0\) \(=>\) \(x_1=8/5\)

\[x_{\lambda=1}=\begin{bmatrix} 8/5 \\5/2 \\1\end{bmatrix}\]

Now, let’s check eigenvectors using built-in ‘eigen’ function

print(eigen(A)$vectors)
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0