How to find the inverse of a matrix using elementary row operations?
Answers
The following examples illustrate the steps in finding the inverse of a matrix using elementary row operations (EROs):
Add a multiple of one row to another (rowadd())
Multiply one row by a constant (rowmult())
Interchange two rows (rowswap())
These have the properties that they do not change the inverse. The method used here is sometimes called the Gauss-Jordan method, a form of Gaussian elimination. Another term is (row-reduced) echelon form.
Steps:
Adjoin the identity matrix to the right side of A, to give the matrix [A|I]
Apply row operations to this matrix until the left (A) side is reduced to I
The inverse matrix appears in the right (I) side
Why this works: The series of row operations transforms
[A|I]⇒[A−1A|A−1I]=[I|A−1]
If the matrix is does not have an inverse (is singular) a row of all zeros will appear in the left (A) side.Create a 3 x 3 matrix
A <- matrix( c(1, 2, 3,
2, 3, 0,
0, 1,-2), nrow=3, byrow=TRUE)
Join an identity matrix to A
(AI <- cbind(A, diag(3)))
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 2 3 1 0 0
## [2,] 2 3 0 0 1 0
## [3,] 0 1 -2 0 0 1