Find the rank and nullity of the matrix \[ A = \begin{bmatrix} 1 & 2 & 1 & 1 & 1\\ 1 &3&2&0&4 \\ 1&2&1&1&1 \end{bmatrix} \]
# Load necessary library
library(pracma)
A <- matrix(c(1, 2, 1, 1, 1,
1, 3, 2, 0, 4,
1, 2, 1, 1, 1), nrow = 3, byrow = TRUE)
# Find the rank of A
rank_A <- qr(A)$rank
print(paste("Rank of A:", rank_A))
## [1] "Rank of A: 2"
# Calculate nullity of A
nullity_A <- ncol(A) - rank_A
print(paste("Nullity of A:", nullity_A))
## [1] "Nullity of A: 3"
# Below is extra, just exploration
# Find the null space of A
null_space <- nullspace(A)
print(null_space)
## [,1] [,2] [,3]
## [1,] -0.19203847 -0.79218411 0.40810718
## [2,] -0.28099894 0.07682541 -0.63882329
## [3,] 0.91801212 -0.12048890 -0.04348687
## [4,] 0.03627147 0.55835078 0.51419216
## [5,] -0.20024724 0.20067142 0.39883411