Finding the Inverse of a Matrix with Gauss-Jordan Elimination

Gauss-Jordan elimination gives you a systematic way to compute the inverse of any square matrix, and it extends naturally from the same row-reduction skills used in solving linear systems. The core idea is to transform a matrix into the identity matrix while tracking every operation on a second matrix alongside it. What comes out on the right side, when the left side becomes the identity, is the inverse.

Setting Up the Augmented Matrix

To begin, take your square matrix A and write it side-by-side with an identity matrix of the same size. This forms an augmented matrix written as [A | I].

For a 3x3 matrix, the setup looks like this:

[ a11  a12  a13 | 1  0  0 ]
[ a21  a22  a23 | 0  1  0 ]
[ a31  a32  a33 | 0  0  1 ]

Every row operation you apply to A gets applied to the identity side simultaneously. This is not just bookkeeping: the identity matrix on the right records the cumulative transformation, so when A becomes I, the right side holds exactly A^-1.

If you want a refresher on the mechanics of row reduction itself before continuing, see how to find RREF by hand and the three elementary row operations.

The Three Types of Row Operations

You have three tools available, all reversible:

The goal is to reduce the left half to the identity matrix using these operations. At that point, stop. The right half is the inverse.

A Fully Worked 3x3 Example

Take the matrix:

A = [ 2   1   0 ]
    [ 1   3   1 ]
    [ 0   1   2 ]

Set up the augmented matrix:

[ 2   1   0 | 1  0  0 ]
[ 1   3   1 | 0  1  0 ]
[ 0   1   2 | 0  0  1 ]

Step 1: Get a 1 in position (1,1).

Multiply row 1 by 1/2:

[ 1   1/2   0 | 1/2  0  0 ]
[ 1     3   1 |   0  1  0 ]
[ 0     1   2 |   0  0  1 ]

Step 2: Eliminate the 1 below the pivot.

Subtract row 1 from row 2 (R2 = R2 - R1):

[ 1   1/2    0 | 1/2   0  0 ]
[ 0   5/2    1 | -1/2  1  0 ]
[ 0     1    2 |   0   0  1 ]

Step 3: Get a 1 in position (2,2).

Multiply row 2 by 2/5:

[ 1   1/2    0 |  1/2   0    0 ]
[ 0     1   2/5 | -1/5  2/5  0 ]
[ 0     1    2 |   0    0    1 ]

Step 4: Eliminate above and below the second pivot.

R1 = R1 - (1/2)R2:

[ 1   0  -1/5 |  3/5  -1/5   0 ]
[ 0   1   2/5 | -1/5   2/5   0 ]
[ 0   1    2  |   0     0    1 ]

R3 = R3 - R2:

[ 1   0  -1/5 |  3/5  -1/5   0 ]
[ 0   1   2/5 | -1/5   2/5   0 ]
[ 0   0   8/5 |  1/5  -2/5   1 ]

Step 5: Get a 1 in position (3,3).

Multiply row 3 by 5/8:

[ 1   0  -1/5 |  3/5  -1/5   0   ]
[ 0   1   2/5 | -1/5   2/5   0   ]
[ 0   0     1 |  1/8  -1/4  5/8  ]

Step 6: Eliminate above the third pivot.

R1 = R1 + (1/5)R3:

[ 1   0   0 |  5/8  -1/4  1/8 ]
[ 0   1   2/5 | -1/5   2/5   0 ]
[ 0   0   1 |  1/8  -1/4  5/8 ]

R2 = R2 - (2/5)R3:

[ 1   0   0 |  5/8  -1/4   1/8  ]
[ 0   1   0 | -1/4   1/2  -1/4  ]
[ 0   0   1 |  1/8  -1/4   5/8  ]

The left half is now the identity. The inverse is:

A^-1 = [  5/8  -1/4   1/8 ]
        [ -1/4   1/2  -1/4 ]
        [  1/8  -1/4   5/8 ]

You can verify this by computing A * A^-1 and confirming you get the identity matrix.

When No Inverse Exists

Not every square matrix has an inverse. A matrix is called singular when the Gauss-Jordan process breaks down, specifically when you encounter a zero column with no nonzero entry below it to swap in as a pivot.

If at any point during reduction the current pivot column is all zeros from the pivot row downward, the matrix has no inverse. This happens precisely when the matrix has fewer than n pivots for an n x n matrix, meaning its rank is less than n.

For example:

[ 1   2 ]
[ 2   4 ]

Row reducing this gives a zero row on the left, which means you can never produce the identity. This matrix is singular. Its determinant is (1)(4) - (2)(2) = 0, which is another way to detect the same problem. See determinant via row reduction for how row operations affect the determinant.

The rank condition ties directly into this: for an inverse to exist, a matrix must have full rank. You can check rank as a preliminary test by reading how to find the rank of a matrix.

Connections to RREF

The Gauss-Jordan method for matrix inversion is really just RREF applied to an augmented system. When you reduce [A | I] all the way to [I | B], B is A^-1. This is more thorough than Gaussian elimination (which stops at row echelon form) because you must eliminate upward as well as downward to reach the fully reduced form.

Every step you take must be reversible. That requirement is automatically satisfied by the three elementary row operations, which are all invertible transformations. The identity matrix on the right accumulates the product of all those inverse operations, which is why it ends up as A^-1.

Frequently Asked Questions

Does this method work for 2x2 matrices too?

Yes, though for 2x2 matrices there is also a direct formula: if A = [[a, b], [c, d]], then A^-1 = (1 / det(A)) * [[d, -b], [-c, a]], where det(A) = ad - bc. Gauss-Jordan still works fine for 2x2 and becomes more practical as the matrix size grows.

What if I get fractions partway through?

Fractions are common and expected. The arithmetic is the same whether you use decimals or exact fractions. Working with fractions keeps the result exact, which matters if you need A^-1 for further calculations. Multiplying through to clear denominators at intermediate steps can reduce arithmetic errors.

How do I know if I've made an error?

Multiply A by your computed inverse and check whether the result is the identity matrix. If any off-diagonal entry is nonzero, or any diagonal entry is not 1, there is an error somewhere in the row reduction. It helps to keep a log of each operation applied to both sides of the augmented matrix so you can retrace steps.

Is the inverse unique?

Yes. If a matrix A has an inverse, that inverse is unique. There is only one matrix B such that AB = BA = I. This means the Gauss-Jordan method, regardless of the order you choose to apply row operations, will always produce the same final answer.