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

Solution:

The rank of a matrix is defined as the maximum number of linearly independent vectors in rows or columns. If we have a matrix with dimensions R x C, having R number of rows and C number of columns, and if R is less than C then the rank of the matrix would be R. To find the rank of a matrix in R, we can use rankMatrix function in Matrix package.

library(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 )

print('Rank of the given matrix is:')
## [1] "Rank of the given matrix is:"
  rankMatrix(A, method = "qr")
## [1] 4
## attr(,"method")
## [1] "qrLINPACK"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 8.881784e-16

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

Solution:

Since the rank is the number of linearly independent columns, the maximum rank can’t be larger than the number of columns, i.e. \(n\).

If the matrix is non-zero, the minimum rank would be 1.

(3) What is the rank of matrix B?

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

library(Matrix)

B = matrix(c(1, 2, 1,
             3, 6, 3,
             2, 4, 2),
           nrow = 3, ncol=3, byrow = TRUE )

print('Rank of the given matrix is:')
## [1] "Rank of the given matrix is:"
  rankMatrix(B, method = "qr")
## [1] 1
## attr(,"method")
## [1] "qrLINPACK"
## attr(,"useGrad")
## [1] FALSE
## attr(,"tol")
## [1] 6.661338e-16

Problme set 2

Compute the eigenvalues and eigenvectors of the matrix A

\[A = \begin{bmatrix} 1 & 2 & 3\\ 0 & 4 & 5\\ 0 & 0 & 6 \end{bmatrix}\]

Let’s find eigenvalues of A first by finding the values of λ which satisfy the characteristic equation of the matrix A of which is

  det(A- λI) = 0

where I is the 3 x 3 identity matrix

From the matrix A - λI: \[|A - \lambda I | = \left | \begin{bmatrix} 1 & 2 & 3\\ 0 & 4 & 5\\0 & 0 & 6\end{bmatrix} - \lambda \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix} \right |\] \(= \left|\begin{bmatrix}1-\lambda & 2 & 3\\ 0 & 4-\lambda & 5\\ 0 & 0 & 6-\lambda\end{bmatrix}\right|\)

\(= (1-\lambda)(4-\lambda)(6-\lambda)\)

\((1 - \lambda)\Big[24-10\lambda+\lambda^2\Big] = 24 -10\lambda + \lambda^2 -24\lambda +10\lambda^2 - \lambda^3 = -\lambda^3 + 11\lambda^2 -34\lambda + 24\)

After factoring, we get \((\lambda - 1)(\lambda - 4)(\lambda - 6)\)

So the eigenvalues are 1, 4, 6.

For \(\lambda = 1\):

library(pracma)
## 
## Attaching package: 'pracma'
## The following objects are masked from 'package:Matrix':
## 
##     expm, lu, tril, triu
A <- matrix(c(1, 2, 3,
              0, 4, 5,
              0, 0, 6),
            nrow = 3, ncol = 3, byrow = T)
I <- diag(3)
rref(A-I)
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2,]    0    0    1
## [3,]    0    0    0

\(v_1 = \begin{bmatrix}1\\0\\0\\\end{bmatrix}\)

For \(\lambda = 4\):

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

\(x_1 - \frac{2}{3}x_2 = 0\)

\(v_4 = \begin{bmatrix}\frac{2}{3}\\1\\0\end{bmatrix}\)

For \(\lambda = 6\):

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

\(x_1 - 1.6x_3 = 0 \hspace{20mm} x_2 - 2.5x_3 = 0 \hspace{5mm} x_3\neq 0\).

\(v_6 = \begin{bmatrix}1.6 \\ 2.5 \\ 1 \end{bmatrix}\)