library(Matrix)
library(matrixcalc)
library(matlib)
## 
## Attaching package: 'matlib'
## The following object is masked from 'package:matrixcalc':
## 
##     vec

Problem Set 1

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

A <- matrix(c(1, 2, 3, 4, -1, 0, 1, 3, 0, 1, -2, 1, 5, 4, -2, -3), 4, 4, byrow = T)

Using Row Echelon form

#echelon
echelon(A, reduced = F)
##      [,1] [,2]      [,3]       [,4]
## [1,]    1  0.8 -0.400000 -0.6000000
## [2,]    0  1.0  2.833333  3.8333333
## [3,]    0  0.0  1.000000  0.5862069
## [4,]    0  0.0  0.000000  1.0000000

Counting all non-zero rows tells the rank of the matrix. In this case it is 4.

To confirm this using R’s built in function:

rankMatrix(A)
## [1] 4
## attr(,"method")
## [1] "tolNorm2"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 8.881784e-16

The rank is 4.

  1. Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?

    • If m is less than n, then the maximum rank of the matrix is m.
    • If m is greater than n, then the maximum rank of the matrix is n.
    • The minimum rank would be one.
  2. 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), 3, 3, byrow = T)
echelon(B, reduced = F)
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    0    0    0

The rank is 1.

Problem Set 2

  1. 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), 3, 3, byrow = T)
I <- diag(3)

To obtain the eigenvalues of A, we find the determinant >> \(det(A - \lambda I) = 0\) to satisfy the characteristic equation of the matrix A.

[ \[\begin{aligned} \mathbf{A - \lambda I} &=\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] =\left[\begin{array} {rrr} 1 - \lambda & 2 & 3\\ 0 & 4 - \lambda & 5\\ 0 & 0 & 6 - \lambda\\ \end{array}\right]\\ \\ \\ \mathbf{det(A - \lambda I)} &= (1- \lambda) \begin{vmatrix} 4 - \lambda & 5\\ 0 & 6 - \lambda \end{vmatrix} - (2)\begin{vmatrix} 0 & 5\\ 0 & 6 - \lambda \end{vmatrix} +(3)\begin{vmatrix} 0 & 4 - \lambda\\ 0 & 0 \end{vmatrix}\\ \\ &= (1 - \lambda)\begin{vmatrix}(4 - \lambda)(6-\lambda) - (0)(5)\end{vmatrix} - (2) \begin{vmatrix}(0)(6- \lambda) - (0)(5)\end{vmatrix} + (3) \begin{vmatrix}(0)(0)- (0)(4- \lambda)\end{vmatrix}\\ \\ &= (1 - \lambda)(4 - \lambda)(6-\lambda) - 0 + 0\\ \\ &= (1 - \lambda)(4 - \lambda)(6-\lambda)\end{aligned}\]

]

The characteristic polynomial is \(-\lambda^3 + 11 \lambda^2 - 34\lambda + 24\)

Therefore the eigenvalues of \(A\) are \(\lambda\) = 1, 4 and 6

Eigenvectors:

\(\lambda = 1\)

\(-A + I_3\)

-A + I
##      [,1] [,2] [,3]
## [1,]    0   -2   -3
## [2,]    0   -3   -5
## [3,]    0    0   -5
echelon((-A + I))
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2,]    0    0    1
## [3,]    0    0    0

\[\left[\begin{array} {rrr} 1\\0\\0\\ \end{array}\right]\]

\(\lambda = 4\)

\(-A + 4I_3\)

-A + (4*I)
##      [,1] [,2] [,3]
## [1,]    3   -2   -3
## [2,]    0    0   -5
## [3,]    0    0   -2
echelon((-A + (4*I)))
##      [,1]       [,2] [,3]
## [1,]    1 -0.6666667    0
## [2,]    0  0.0000000    1
## [3,]    0  0.0000000    0

\[\left[\begin{array} {rrr} \frac{2}3\\1\\0\\ \end{array}\right] = \left[\begin{array} {rrr} 2\\3\\0\\ \end{array}\right]\]

\(\lambda = 1\)

\(-A + 6I_3\)

-A + (6*I)
##      [,1] [,2] [,3]
## [1,]    5   -2   -3
## [2,]    0    2   -5
## [3,]    0    0    0
echelon((-A + (6*I)))
##      [,1] [,2] [,3]
## [1,]    1    0 -1.6
## [2,]    0    1 -2.5
## [3,]    0    0  0.0

\[\left[\begin{array} {rrr} \frac{8}5\\\frac{5}2\\1\\ \end{array}\right] = \left[\begin{array} {rrr} 16\\25\\10\\ \end{array}\right]\]