(1) What is the rank of the matrix A? \[\mathbf{A} = \left[\begin{array} {rrr} 1 & 2 & 3 & 4 \\ -1 & 0 & 1 & 3 \\ 0 & 1 & -2 & 1 \\ 5 & 4 & -2 & -3 \end{array}\right] \]
reforder = function(x) {
pivot = 1
xrows = nrow(x)
xcolumns = ncol(x)
for(rows in 1:xrows) {
if ( xcolumns <= pivot)
break;
newrow = rows
while( x[newrow, pivot] == 0 ) {
newrow = newrow + 1
if ( xrows == newrow ) {
newrow = rows
pivot = pivot + 1
if ( xcolumns == pivot ) return(x)
}
}
# swapping rows
placeholder = x[newrow, ]
x[newrow, ] = x[rows, ]
x[rows, ] = placeholder
# reducing equation
x[rows, ] = x[rows, ] / x[rows, pivot]
for(newrow in 1:xrows) {
if ( newrow != rows )
x[newrow, ] = x[newrow, ] - x[rows, ] * x[newrow, pivot]
}
pivot = pivot + 1
}
# ordering the matrix
x = x[order(x[ ,1],decreasing = T), ]
# counting the order
count = 0
for (rows in 1:xrows){
if ( sum(x[rows, 1:xcolumns] ) != 0) {
count = count + 1
}
}
printed = sprintf("The order is: %s", count)
output = list(x, printed)
return(output)
}
A = matrix(c(1, 2, 3, 4, -1, 0, 1, 3, 0, 1, -2, 1, 5, 4, -2, -3), byrow=TRUE, nrow = 4)
reforder(A)
## [[1]]
## [,1] [,2] [,3] [,4]
## [1,] 1 0 0 -2.375
## [2,] 0 1 0 2.250
## [3,] 0 0 1 0.625
## [4,] 0 0 0 1.125
##
## [[2]]
## [1] "The order is: 4"
The rank of the matrix is determined by the number of non-zero rows in a matrix. In this example, matrix A does not have any non-zero rows, therefore the rank is four.
(2) Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?
Since the rank of a matrix is dependent on the number of non-zero rows, the highest the rank can be in an mxn matrix (where m is the number of rows and n is the number of columns) is m and the lowest the rank can be (if it is a non-zero matrix) is one.
(3) What is the rank of matrix B? \[\mathbf{B} = \left[\begin{array} {rrr} 1 & 2 & 1 \\ 3 & 6 & 3 \\ 2 & 4 & 2 \end{array}\right] \]
B = matrix(c(1, 2, 1, 3, 6, 3, 2, 4, 2), byrow=TRUE, nrow = 3)
reforder(B)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] 0 0 0
Matrix B’s rank is one because out of the three rows reduced to row echelon form, only one is non-zero.
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. \[\mathbf{A} = \left[\begin{array} {rrr} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{array}\right] \]
A = matrix(c(1,2,3,0,4,5,0,0,6), byrow=TRUE, nrow = 3)
\[det(A-\lambda I) = det(\left[\begin{array} {rrr} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{array}\right]- \left[\begin{array} {rrr} \lambda & 0 & 0 \\ 0 & \lambda & 0 \\ 0 & 0 & \lambda \end{array}\right])= det(\left[\begin{array} {rrr} (1-\lambda) & -2 & -3 \\ 0 & (4-\lambda) & -5 \\ 0 & 0 & (6-\lambda) \end{array}\right]) \] To solve, we keep in mind that \(det(A-\lambda) = 0\) so that
\[det(\left[\begin{array} {rrr} (1-\lambda) & -2 & -3 \\ 0 & (4-\lambda) & -5 \\ 0 & 0 & (6-\lambda) \end{array}\right])= ((1-\lambda))[(4-\lambda)(6-\lambda)-(-5)(0)]-(-2)[(0)(6-\lambda)-(-5)(0)]+(-3)[0(0)-(4-lambda)(0)]=(1-\lambda)(4-\lambda)(6-\lambda) \] so
\(p(\lambda)= -\lambda^3+11\lambda^2-34\lambda+24=0\) or \((1-\lambda)(4-\lambda)(6-\lambda)=0\), which makes the eigenvalues \(\lambda= 1, 4, 6\).
A = matrix(c(1,2,3,0,4,5,0,0,6), byrow=TRUE, nrow = 3)
l1 = diag(1, dim(A), dim(A))
l4 = diag(4, dim(A), dim(A))
l6 = diag(6, dim(A), dim(A))
lambda1 = A-l1
lambda4 = A-l4
lambda6 = A-l6
lambda1
## [,1] [,2] [,3]
## [1,] 0 2 3
## [2,] 0 3 5
## [3,] 0 0 5
lambda4
## [,1] [,2] [,3]
## [1,] -3 2 3
## [2,] 0 0 5
## [3,] 0 0 2
lambda6
## [,1] [,2] [,3]
## [1,] -5 2 3
## [2,] 0 -2 5
## [3,] 0 0 0
library("pracma")
## Warning: package 'pracma' was built under R version 3.3.3
rref(lambda1)
## [,1] [,2] [,3]
## [1,] 0 1 0
## [2,] 0 0 1
## [3,] 0 0 0
rref(lambda4)
## [,1] [,2] [,3]
## [1,] 1 -0.6666667 0
## [2,] 0 0.0000000 1
## [3,] 0 0.0000000 0
rref(lambda6)
## [,1] [,2] [,3]
## [1,] 1 0 -1.6
## [2,] 0 1 -2.5
## [3,] 0 0 0.0
For \(\lambda=1\):
\[ E(\lambda=1)=\left[\begin{array} {rrr} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{array}\right] \left[\begin{array} {rrr} v1 \\ v2 \\ v3 \end{array}\right]= \left[\begin{array} {rrr} 0 \\ 0 \\ 0 \end{array}\right] \] \(v3=0\), \(v2=0\), \(v1=t\) \[ v=\left[\begin{array} {rrr} t \\ 0 \\ 0 \end{array}\right]= \left[\begin{array} {rrr} 1 \\ 0 \\ 0 \end{array}\right]t \]
For \(\lambda=4\): \[ E(\lambda=4)=\left[\begin{array} {rrr} 0 & -0.67 & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{array}\right] \left[\begin{array} {rrr} v1 \\ v2 \\ v3 \end{array}\right]= \left[\begin{array} {rrr} 0 \\ 0 \\ 0 \end{array}\right] \] \(v3=0\), \(v2=t\), \(v1=0.67t\) \[ v=\left[\begin{array} {rrr} 0.67t \\ t \\ 0 \end{array}\right]= \left[\begin{array} {rrr} 0.67 \\ 1 \\ 0 \end{array}\right]t \]
For \(\lambda=6\):
\[ E(\lambda=6)=\left[\begin{array} {rrr} 1 & 0 & -1.6 \\ 0 & 1 & -2.5 \\ 0 & 0 & 0 \end{array}\right] \left[\begin{array} {rrr} v1 \\ v2 \\ v3 \end{array}\right]= \left[\begin{array} {rrr} 0 \\ 0 \\ 0 \end{array}\right] \] \(v3=t\), \(v2=2.5t\), \(v1=1.6t\) \[ v=\left[\begin{array} {rrr} 1.6t \\ 2.5t \\ t \end{array}\right]= \left[\begin{array} {rrr} 1.6 \\ 2.5 \\ 1 \end{array}\right]t \]