Problem set 1

(1)

A = matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3),ncol = 4)
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
rank_A <- qr(A)$rank
rank_A
## [1] 4

(2)

The rank of a matrix is defined as (a) the maximum number of linearly independent column vectors in the matrix or (b) the maximum number of linearly independent row vectors in the matrix. Both definitions are equivalent.

For an m x n matrix:

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 rank of a matrix would be zero only if the matrix had no elements. If a matrix had even one element, its minimum rank would be one.

(3)

B = matrix(c(1,3,2,2,6,4,1,3,2),ncol = 3)
B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
rank_B <- qr(B)$rank
rank_B
## [1] 1
#install.packages("pracma")
library(pracma)
rref(B) ## calculating its reduced row echelon form, results in only one row non zero
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    0    0    0

Problem set 2

A = matrix(c(1,0,0,2,4,0,3,5,6),ncol = 3)
A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0    4    5
## [3,]    0    0    6
eigen_A <- eigen(A)
eigen_A$values # Eigen values
## [1] 6 4 1

\[ \lambda = 6, \lambda = 4, \lambda = 1 \]

charpoly(A) # Characteristic polynomial
## [1]   1 -11  34 -24

\[ p(\lambda) = \lambda^3 - 11\lambda^2 + 34\lambda - 24 = 0 \] \[ Eigenvector = \lambda I - A \] \[\lambda = 6\]

l = eigen_A$values[1]
l_I = l * diag(3)

vectors = l_I - A

rref(vectors)
##      [,1] [,2] [,3]
## [1,]    1    0 -1.6
## [2,]    0    1 -2.5
## [3,]    0    0  0.0

Eigenspace

\[v_3 = t\] \[ v_2 - 2.5t = 0\] \[v_1 - 1.6t = 0\]

\[\left[\begin{array} {r} v_1 \\ v_2 \\ v_3 \\ \end{array}\right] = t \left[\begin{array} {r} 1.6 \\ 2.5 \\ 1 \\ \end{array}\right] \]

\[\lambda = 4\]

l = eigen_A$values[2]
l_I = l * diag(3)

vectors = l_I - A

rref(vectors)
##      [,1]       [,2] [,3]
## [1,]    1 -0.6666667    0
## [2,]    0  0.0000000    1
## [3,]    0  0.0000000    0

Eigenspace

\[v_3 = 0\] \[ v_2 = t\] \[v_1 - 0.66t = 0\]

\[\left[\begin{array} {r} v_1 \\ v_2 \\ v_3 \\ \end{array}\right] = t \left[\begin{array} {r} 0.66 \\ 1 \\ 0 \\ \end{array}\right] \]

\[\lambda = 1\]

l = eigen_A$values[3]
l_I = l * diag(3)

vectors = l_I - A

rref(vectors)
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2,]    0    0    1
## [3,]    0    0    0

Eigenspace

\[v_3 = 0\] \[v_2 = 0 \] \[v_1 = t\] \[\left[\begin{array} {r} v_1 \\ v_2 \\ v_3 \\ \end{array}\right] = t \left[\begin{array} {r} 1 \\ 0 \\ 0 \\ \end{array}\right] \]

eigen_A$vectors # Eigenvectors caluclated with eigen function
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0