A <-matrix(c(1, 2, 3, 4, -1, 0, 1, 3, 0, 1, -2, 1, 5, 4, -2, -3), nrow=4, byrow = TRUE)
rreform4 <- function(A) {
A[2,] <- (((A[2,1])/A[1,1])*A[1,]-A[2,])
A[3,] <- (((A[3,1])/A[1,1])*A[1,]-A[3,])
A[4,] <- (((A[4,1])/A[1,1])*A[1,]-A[4,])
A[3,] <- (((A[3,2])/A[2,2])*A[2,]-A[3,])
A[4,] <- (((A[4,2])/A[2,2])*A[2,]-A[4,])
A[4,] <- (((A[4,3])/A[3,3])*A[3,]-A[4,])
return(A)
}
rreform4(A)
## [,1] [,2] [,3] [,4]
## [1,] 1 2 3 4.000
## [2,] 0 -2 -4 -7.000
## [3,] 0 0 -4 -2.500
## [4,] 0 0 0 -1.125
Then, we see there are no 0 rows, so we conclude that rank(A)=4.
The maximum rank of a matrix, where m > n, is n. The minimum rank of a non-zero matrix is 1.
We can see right away that row 2 and row 3 are multiples of row 1, so we know rank(B)=1.
We can check this using the reduced-row-echelon form of B.
B <- matrix(c(1, 2, 1, 3, 6, 3, 2, 4, 2), nrow=3, byrow = TRUE)
rreform3 <- function(B) {
B[2,] <- (((B[2,1])/B[1,1])*B[1,]-B[2,])
B[3,] <- (((B[3,1])/B[1,1])*B[1,]-B[3,])
B[3,] <- (((B[3,2])/B[2,2])*B[2,]-B[3,])
return(B)
}
rreform3(B)
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 0 0 0
## [3,] NaN NaN NaN
So we see that rank(B)=1.
First we need to find the eigen values. We will start by finding the solutions to the det(A-λI). I will store (A-λI) in matrix B.
A <- matrix(c(1, 2, 3, 0, 4, 5, 0, 0, 6), nrow=3, byrow = TRUE)
B <- matrix(c(("1-λ"), 2, 2, 0, ("4-λ"), 5, 0, 0, ("6-λ")), 3, 3, byrow = TRUE)
Then, det(A-λI)=(1-λ)((4-λ)(6-λ)-(5*0)). When we solve for λ, we find our eigen values to be λ=1, 4, 6. To find our eigen vectors, we solve (A-λI)[x]=[0] for each eigenvalue we found, where [x]=c(x, y, z).
First, λ=1.
#Store A-λI in matrix B, sub in λ=1
B <- matrix(c(0, 2, 3, 0, 3, 5, 0, 0, 5), nrow=3, byrow = TRUE)
#So, (B)[x]=[0] gives us the system of equations:
# 0*x + 2y + 3z = 0
# 0*x + 3y + 5z = 0
# 0*x + 0y + 5z = 0
#So we know z=0, y=0, x=x. let x=1. Therefore, our eigenvector for λ=1 is c(1, 0, 0).
Then, λ=4.
#Store A-λI in matrix B, sub in λ=4
B <- matrix(c(-3, 2, 3, 0, 0, 5, 0, 0, 2), nrow=3, byrow = TRUE)
#So, (B)[x]=[0] gives us the system of equations:
# -3x + 2y + 3z = 0
# 0*x + 0*y + 5z = 0
# 0*x + 0*y + 2z = 0
#So we know z=0, y=y, And we solve for x.
# -3x + 2y + 3*0 = 0
# 2y = 3x
# x = (2/3)y
#So, x = (2/3)y. Now let y=1. Therefore, our eigenvector for λ=4 is c((2/3), 1, 0).
Then, λ=6.
#Store A-λI in matrix B, sub in λ=6
B <- matrix(c(-5, 2, 3, 0, -2, 5, 0, 0, 0), nrow=3, byrow = TRUE)
#So, (B)[x]=[0] gives us the system of equations:
# -5x + 2y + 3z = 0
# 0*x + -2*y + 5z = 0
# 0*x + 0*y + 0z = 0
#So we know z=z, And we solve for x and y. Let's start with y.
# 0*x + -2*y + 5z = 0
# 2y = 5z
# y = (5/2)z
#So, y = (5/2)z. Now we solve for x.
# -5x + 2y + 3z = 0
# 2y + 3z = 5x
# 2(5/2)z + 3z = 5x
# 8z = 5x
# x = (8/5)z
#So, x = (8/5)z. Let z=1. Therefore, our eigenvector for λ=6 is c((8/5), 5/2, 1).