4
## declare 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)
qr(A)$rank
## [1] 4
In an m x n matrix with m > n, the maximum rank is n,this is because the matrix is bounded by the smallest dimension. The minimum rank, assuming non-zero values, is 1, this is because at least one row or column must be linearly independent, making the matrix non-singular.
The rank of B is 1
B = matrix( c(1,2,1,3,6,3,2,4,2), nrow = 3, ncol=3, byrow = TRUE)
qr(B)$rank
## [1] 1
using the determinant formula
det(A - λI) = 0
substituting A - λI into the determinant, we get:
det( (1-λ 2 3 0 4-λ 5 0 0 6-λ) ) = 0
Expanding the determinant, we get
(1-λ)((4-λ)(6-λ)-0×5) - 2((6-λ)×0-0×5) + 3(0×0-0×(4-λ))
which simplifies to:
(1-λ)((24-10λ+λ^2)-0) - 0 + 0
(24-10λ+λ2-24λ+10λ2-λ^3) + 0 + 0
-λ^3 + 11λ^2 - 34λ + 24 = 0
This equation represents the characteristic polynomial of matrix A. now we solve this polynomial equation to find the eigenvalues.
To find the eigenvalues, we need to solve the characteristic polynomial:
-λ^3 + 11λ^2 - 34λ + 24 = 0
we have to solve this cubic equation for λ we see that λ = 6 is a root because (6-6) = 0. We can then use division factorize the polynomial.
Given the characteristic polynomial:
-λ^3 + 11λ^2 - 34λ + 24 = 0
We have already found one root, λ = 6. let’s factorize the polynomial using this root:
-(λ - 6)((λ^2 - 5λ + 4)) = 0
Now, we have a quadratic equation:
λ^2 - 5λ + 4 = 0
This quadratic equation can be factored into:
(λ - 4)(λ - 1) = 0
So, the remaining roots are λ = 4 and λ = 1.
# To find the corresponding eigenvectors, we need to substitute each eigenvalue back into the equation (A - λI)x = 0 and solve for the vector x.
A <- matrix(c(1, 2, 3, 0, 4, 5, 0, 0, 6), nrow = 3, byrow = TRUE)
# Define the eigenvalues
eigenvalues <- c(6, 4, 1)
# Calculate eigenvectors corresponding to eigenvalues
eigenvectors <- sapply(eigenvalues, function(lambda) {
eigen_result <- eigen(A - lambda * diag(3))
eigen_result$vectors[, which(eigen_result$values == 0)]
})
# Display eigenvectors
print("Eigenvectors:")
## [1] "Eigenvectors:"
print(eigenvectors)
## [,1] [,2] [,3]
## [1,] 0.5108407 0.5547002 1
## [2,] 0.7981886 0.8320503 0
## [3,] 0.3192754 0.0000000 0