library(knitr)
What is the rank of the matrix A?
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)
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
qr_result <- qr(A)
rank_A <- sum(abs(diag(qr_result$qr)) > .Machine$double.eps)
rank_A
## [1] 4
Given an mxn matrix where m>n, what can be the maximum rank?The minimum rank,assuming that the matrix is non-zero?
Given an mxn matrix where m>n, the maximum rank is n since the number of columns in the matrix is n; the maximum number of linearly independent columns. The minimum rank is 1, since the matrix must have at least one linearly independent row or column. If a matrix has all zero entries, its rank is zero.
What is the rank of the matrix B?
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
qr_result_2 <- qr(B)
rank_B <- sum(abs(diag(qr_result_2$qr)) > .Machine$double.eps)
rank_B
## [1] 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.
A<- matrix(c(1,2,3,0,4,5,0,0,6), nrow = 3, ncol = 3, byrow = TRUE)
A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
The eigenvalue of a matrix is a scalar value that represents how the matrix transforms a vector in space. Given a square matrix A, an eigenvalue λ is a scalar that satisfies the following equation:
A * x = λ * x
where x is the eigenvector of the matrix. The eigenvector represents the direction of the transformation, and the eigenvalue represents the magnitude of the transformation. To find the eigenvalues of a matrix, you need to solve the characteristic equation det(A - λI) = 0, where I is the identity matrix and det is the determinant. Once you have the characteristic equation, you can solve for λ and find the eigenvalues of the matrix.
an image caption Source: Evaluation of Eigenvector of the Matrix
The EigenValues for λ are: λ = 1, λ = 4, λ = 6
an image caption Source: Calculation of the Eigenvectors for the 3 values of λ
M <- matrix(c(0, -2,-3, 0, -3, -5, 0, 0, -5), nrow = 3, ncol = 3, byrow = TRUE)
(M[1,] <- M[1,] / -2)
## [1] 0.0 1.0 1.5
(M[2,] <- M[1,] *3 + M[2,])
## [1] 0.0 0.0 -0.5
(M[2,] <- M[2,] / -.5)
## [1] 0 0 1
(M[1,] <- M[1,] - M[2,] * 1.5)
## [1] 0 1 0
(M[3,] <- M[3,] + M[2,] * 5)
## [1] 0 0 0
M
## [,1] [,2] [,3]
## [1,] 0 1 0
## [2,] 0 0 1
## [3,] 0 0 0
M <- matrix(c(3, -2, -3, 0, 0, -5, 0, 0, -2), nrow = 3, ncol=3 ,byrow = TRUE)
(M[1,] <- M[1,]/3)
## [1] 1.0000000 -0.6666667 -1.0000000
(M[2,] <- M[2,] / -5)
## [1] 0 0 1
(M[1,] <- M[1,] + M[2,])
## [1] 1.0000000 -0.6666667 0.0000000
(M[3,] <- M[2,] * 2 + M[3,])
## [1] 0 0 0
M
## [,1] [,2] [,3]
## [1,] 1 -0.6666667 0
## [2,] 0 0.0000000 1
## [3,] 0 0.0000000 0
M <- matrix(c(5, -2, -3, 0, 2, -5, 0, 0, 0), nrow = 3, ncol = 3, byrow = TRUE)
(M[1,] <- M[1,] / 5)
## [1] 1.0 -0.4 -0.6
(M[2,] <- M[2,] / 2)
## [1] 0.0 1.0 -2.5
(M[1,] <- M[2,] * .4 + M[1,])
## [1] 1.0 0.0 -1.6
M
## [,1] [,2] [,3]
## [1,] 1 0 -1.6
## [2,] 0 1 -2.5
## [3,] 0 0 0.0
Or! Instead of all of that…. Let’s solve using R:
A <- matrix(c(1, 2, 3, 0, 4, 5, 0, 0, 6), nrow = 3, ncol = 3, byrow = TRUE)
t <- eigen(A)
values <- t$values
vectors <- t$vectors
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