Computing an inverse and using it
The Gauss-Jordan method
The 2 × 2 formula does not generalise simply. Beyond that, the inverse is computed by Gaussian elimination carried all the way: the Gauss-Jordan method.
The principle
Write A and the identity matrix side by side, then apply elementary row operations to both halves at once, until the left part becomes the identity:
[ A | I ] -----------------> [ I | A⁻¹ ]
row operations
Why it works: each elementary operation amounts to multiplying on the left by an invertible matrix. If the sequence of operations turns A into I, then that same sequence is A⁻¹ — and applying it to I makes it appear.
A worked example
Let us invert A = [[1, 0, 2], [2, -1, 3], [4, 1, 8]].
[ 1 0 2 | 1 0 0 ]
[ 2 -1 3 | 0 1 0 ] R2 <- R2 - 2 R1
[ 4 1 8 | 0 0 1 ] R3 <- R3 - 4 R1
[ 1 0 2 | 1 0 0 ]
[ 0 -1 -1 | -2 1 0 ] R2 <- -R2
[ 0 1 0 | -4 0 1 ]
[ 1 0 2 | 1 0 0 ]
[ 0 1 1 | 2 -1 0 ] R3 <- R3 - R2
[ 0 1 0 | -4 0 1 ]
[ 1 0 2 | 1 0 0 ]
[ 0 1 1 | 2 -1 0 ] R3 <- -R3
[ 0 0 -1 | -6 1 1 ]
The left part is triangular; it remains to go back up to clear what sits above the pivots:
[ 1 0 2 | 1 0 0 ] R1 <- R1 - 2 R3
[ 0 1 1 | 2 -1 0 ] R2 <- R2 - R3
[ 0 0 1 | 6 -1 -1 ]
[ 1 0 0 | -11 2 2 ]
[ 0 1 0 | -4 0 1 ] <- A⁻¹ has appeared on the right
[ 0 0 1 | 6 -1 -1 ]
The check, which is essential: multiply A by the result and you must land on the identity.
[ 1 0 2 ] [ -11 2 2 ] [ 1 0 0 ]
[ 2 -1 3 ] × [ -4 0 1 ] = [ 0 1 0 ] ✔
[ 4 1 8 ] [ 6 -1 -1 ] [ 0 0 1 ]
When the method fails
If, during elimination, a row of the left part becomes entirely zero, it is over: A is not invertible.
[ 1 2 | 1 0 ] R2 <- R2 - 2 R1 [ 1 2 | 1 0 ]
[ 2 4 | 0 1 ] [ 0 0 | -2 1 ]
^^^^^
no pivot can be obtained here
So the algorithm does not merely compute the inverse: it also decides whether it exists. That is an advantage over the 2 × 2 formula, which presupposes the determinant is known.
The cost
Gauss-Jordan on an n × n matrix -> about n³ operations
That is acceptable, but it is roughly three times the cost of simply solving a system. Hence the practical rule of the next lesson: invert a matrix only when you genuinely need the inverse itself.
Summary
- Gauss-Jordan: start from
[ A | I ]and end at[ I | A⁻¹ ]. - Elementary operations apply to both halves simultaneously.
- Go down to reach echelon form, then back up to clear above the pivots.
- An entirely zero row on the left signals a non-invertible matrix.
- Always check by computing
A × A⁻¹ = I. - Cost: about
n³, roughly three system solves.

