Using augmented matrices
An augmented matrix can be thought of as a matrix with extra things tacked on. If you have a matrix A and you add another matrix B beside it you can write it as [A|B].You can then perform a series of elementary row operations on this, operating on whole rows at a time, so A and B.These are
- swapping two rows around
- multiplying a row by a constant m
- replacing a row by itself added to a constant times another row.
If you want to solve a set of equations AX=B for an nxn matrix A and nx1 matrices X and B, then first you form the augmented matrix [A|B].
Change it with elementary row operations until the left part is the identity matrix. Then you will have transformed it into [I|A-1B].
The solution will be on the right hand side.
Similarly, if you want to get the inverse of the matrix, do these row operations on [A|I] and you will turn it into [I|A-1].
It is intuitively obvious that these row operations are the same thing that you would do to linear equations if you were solving them the old fashioned way.
More formally, it works because each of these elementary row transformations can itself be represented by an invertible matrix, and you are performing these transformations on both parts of the augmented matrix at once.
So if you apply a sequence of transforms T1, T2, T3 etc
and you end up with the left hand side being I then you have
T1T2T3A = I on the left hand side, and
T1T2T3B on the right hand side.
But right-multiply the first by A-1 shows that
T1T2T3 = A-1
and therefore the right side is
A-1B which is the solution to the equation.
You can see more details, including what these T matrices look like, on Wikipedia.
A shortcut is to stop when you have the left hand matrix in "row echelon form". This means that the first non-zero entry in each row is 1 and is strictly to the right of the first non-zero entry in the row above. In this case you can solve from the bottom, substituting values in the rows above.
