we have a matric A \(A = \begin{bmatrix}1 & 2 & 3 & 4\\ -1 &0 & 1 & 3 \\ 0 & 1 & -2 & 1 \\ 5 & 4 & -2 & -3\end{bmatrix}\). We are goijng to reduce the matrix to echelon form R2 <- R2 + R1 R4 <- R4 - 5R1
that will give us this matrix \(A = \begin{bmatrix}1 & 2 & 3 & 4\\ 0 &2 & 4 & 7 \\ 0 & 1 & -2 & 1 \\ 0 & -6 & -17 & -23\end{bmatrix}\)
we continue to break down the matrix so we can get the non zero rows
R2 <- 1/2R2
R4 <- R4 - 6R3
That will give us \(A = \begin{bmatrix}1 & 2 & 3 & 4\\ 0 &1 & 2 & 7/2 \\ 0 & 0 & -4 & 5/2 \\ 0 & 0 & -5 & -17\end{bmatrix}\)
R3 <- R3 + R4
R4 <- R4 + R4
Final matrix is \(A = \begin{bmatrix}1 & 2 & 3 & 4\\ 0 &1 & 2 & 7/2 \\ 0 & 0 & 1 & 24/2 \\ 0 & 0 & 1 & -39/2\end{bmatrix}\)
Therefore, n,r(A) = n . we imply that rank is 4
# initialize matrix
A <- matrix(c(1,2,3,4,-1,0,1,3,0,1,-2,1,5,4,-2,-3),nrow=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
# use matrix library
library(Matrix)
rankMatrix(A)[1][1]
## [1] 4
##2 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?
Thee maximum rank a matrix m x n can have the maximum rank of n because it is not possible to have more than n linearly independent columns. The minimum rank assuming the matrix is non-zero would be 1
#3 the rank for matrix
\(B = \begin{bmatrix}1 & 2 & 1\\ 3 &6 & 3 \\ 2 & 4 & 2 \end{bmatrix}\)
We are going to reduce the matrix to echelon form
R2 <- R2 -3R1
R3 <- R3 - 2R1
We will have this matrix:
\(B = \begin{bmatrix}1 & 2 & 1\\ 0 &0 & 0 \\ 0 & 0 & 0 \end{bmatrix}\)
Therefore, n,r(A) = n . we imply that rank is 1
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
rankMatrix(B)[1][1]
## [1] 1
Lets a matrix \(B = \begin{bmatrix}1 & 2 & 3\\ 0 &4 & 5 \\ 0 & 0 & 6 \end{bmatrix}\)
find the eigenvalues and eigenvectors:
\(|A - \lambda I | = 0\)
so we have : $B = \[\begin{bmatrix}1 & 2 & 3\\ 0 &4 & 5 \\ 0 & 0 & 6 \end{bmatrix}\]\(B = \begin{bmatrix}1-\lambda & 2 & 3\\ 0 &4-\lambda & 5 \\ 0 & 0 & 6-\lambda \end{bmatrix}\)
\(1 - \lambda \begin{bmatrix}1-\lambda & 5 \\ 0 &6-\lambda \end{bmatrix} - 2\begin{bmatrix}0 & 5 \\ 0 &6-\lambda \end{bmatrix} +3\begin{bmatrix}0 & 4-\lambda \\ 0 &0 \end{bmatrix}\)
\((1 - \lambda) (4-\lambda) (6-\lambda)\)
Eigenvalue will be 6 4 1
\((1 - \lambda) (4-\lambda) (6-\lambda)\) \((\lambda^3 - 5\lambda^2 +4\lambda)-(6\lambda^2 -30\lambda + 24)\) \(\lambda^3 - 11\lambda^2 - 34\lambda - 24\)
A <- matrix(c(1,2,3,0,4,5,0,0,6), nrow = 3, ncol = 3, byrow = TRUE)
eigen(A)
## eigen() decomposition
## $values
## [1] 6 4 1
##
## $vectors
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0
Calculate the eigenvector. we find the eigenvectors corresponding to each eigenvalue by solving the equation $(A-)v =0 $
for \((\lambda - 6)\) :
\(B = \begin{bmatrix}1-6 & 2 & 3\\ 0 &4-6 & 5 \\ 0 & 0 & 6-6 \end{bmatrix}\)
\(R1 <- -1/5R1\) \(R2 <- -1/5R2\)
\(B = \begin{bmatrix}1 & -2/5 & -3/5\\ 0 &1 & 5/2 \\ 0 & 0 & 0 \end{bmatrix}\)
\(v2 - 5/2v3 = 0\) \(v1 - 2/5v2-3/5v3 = 0\) \(v1 = t\)
for \((\lambda - 6) = \begin{bmatrix}t & 5/2 & t \end{bmatrix}\)
for \((\lambda - 4)\) :
\(A = \begin{bmatrix}1-4 & 2 & 3\\ 0 &4-4 & 5 \\ 0 & 0 & 6-4 \end{bmatrix}\)
\(R1 <- -1/3R1\)
\(B = \begin{bmatrix}1 & -2/53 & -1\\ 0 &0 & 5 \\ 0 & 0 & 2 \end{bmatrix}\)
\(5v3 = 0\) \(v1 - 2/3v2-v3 = 0\) \(v1 = -2/3t\)
for \((\lambda - 4) = \begin{bmatrix}-2/3 & 1 & 0 \end{bmatrix}\)
# calculate the eigenvector
A <- matrix(c(1,2,3,0,4,5,0,0,6), nrow = 3, ncol = 3, byrow = TRUE)
eigen(A)[2]
## $vectors
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0