A <- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3), nrow=4)
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
#inverse of A is valid, showing it to be invertible.
Ainv = solve(A)
# A multiplied by its inverse is equal to the identity matrix
round(A %*% Ainv, digits = 4)
## [,1] [,2] [,3] [,4]
## [1,] 1 0 0 0
## [2,] 0 1 0 0
## [3,] 0 0 1 0
## [4,] 0 0 0 1
# A useful function in the Matrix package provides the same result
require(Matrix)
## Loading required package: Matrix
rankMatrix(A)[1]
## [1] 4
Because the matrix is square and invertible the rank is equal to the number of dimensions.
For a rectabgular matrix, which this matrix must be, the rank is can not exceed the smaller of the row or column dimension. The maximum rank is therefore n. THere must be one independent column in the matrix, making the minimum rank 1
B <- matrix(c(1,2,1,3,6,3,2,4,2), nrow=3, byrow=T)
B
## [,1] [,2] [,3]
## [1,] 1 2 1
## [2,] 3 6 3
## [3,] 2 4 2
#B is square but not invertible
#rank function from matrix package
rankMatrix(B)[1]
## [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, byrow = T)
A
## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 4 5
## [3,] 0 0 6
Written Assignment