MatrixStep

Guides6 min

How to Find the Inverse of a Matrix by Gauss-Jordan Elimination

The inverse of a matrix plays the role that division plays for numbers. This guide walks through Gauss-Jordan elimination on a 2×2 and a 3×3 example, one row operation at a time, and shows what happens when no inverse exists.

What is an inverse matrix?

For a square matrix A, a matrix B with AB = BA = I is called the inverse of A and written A⁻¹. Here I is the identity matrix: ones on the diagonal, zeros everywhere else.

Not every matrix has an inverse. It exists only when A is square and its determinant is not zero. A matrix with an inverse is called invertible (or nonsingular).

Gauss-Jordan elimination at a glance

Write the identity matrix next to A to form [A | I]. Apply row operations until the left half becomes I. The right half is then A⁻¹.

[ A | I ]→row operations→[ I | A⁻¹ ]

Three row operations are allowed.

Why does this work? Each row operation is the same as multiplying on the left by an invertible matrix. The product of all the operations that turn A into I is exactly A⁻¹, and applying the same operations to I accumulates that product on the right.

Example 1: a 2×2 matrix

Let's invert the matrix below.

A =2153
  1. 01
    Append the identity matrix I to the right of A to form [A | I].
    21105301
  2. 02
    Divide row 1 by the pivot so the pivot becomes 1.
    R₁ ← (1/2)R₁
    1121205301
  3. 03
    Make every other entry of column 1 zero.
    R₂ ← R₂ − 5R₁
    112120012−521
  4. 04
    Divide row 2 by the pivot so the pivot becomes 1.
    R₂ ← 2R₂
    11212001−52
  5. 05
    Make every other entry of column 2 zero.
    R₁ ← R₁ − (1/2)R₂
    103−101−52

The left half is now the identity, so the right half is the inverse.

A⁻¹ =3−1−52

For 2×2 matrices there is also a formula. If A = [[a, b], [c, d]], then A⁻¹ = 1/(ad − bc) · [[d, −b], [−c, a]]. Here ad − bc = 2·3 − 1·5 = 1, which gives [[3, −1], [−5, 2]], the same as elimination.

Checking the answer

Multiply AA⁻¹. If you get the identity matrix, the inverse is correct.

2153×3−1−52=1001

Example 2: a 3×3 matrix

Now a 3×3 matrix. The method is identical; there is just one more pivot.

B =123014560
  1. 01
    Form [B | I].
    123100014010560001
  2. 02
    Make every other entry of column 1 zero.
    R₃ ← R₃ − 5R₁
    1231000140100−4−15−501
  3. 03
    Make every other entry of column 2 zero.
    R₁ ← R₁ − 2R₂R₃ ← R₃ + 4R₂
    10−51−20014010001−541
  4. 04
    Make every other entry of column 3 zero.
    R₁ ← R₁ + 5R₃R₂ ← R₂ − 4R₃
    100−2418501020−15−4001−541

The left half is I, so B⁻¹ is the matrix below. Because det(B) = 1, every entry of the inverse is an integer.

B⁻¹ =−2418520−15−4−541

When there is no inverse

If a row of zeros appears on the left half during elimination, the left half can never become the identity. The matrix has no inverse.

C =1224
  1. 01
    Form [C | I].
    12102401
  2. 02
    Make every other entry of column 1 zero.
    R₂ ← R₂ − 2R₁
    121000−21

Row 2 of the left half became all zeros, so C is not invertible. Indeed det(C) = 1·4 − 2·2 = 0: the second row is twice the first.

Common mistakes

FAQ

Can I tell in advance whether the inverse exists?

Yes: the inverse exists exactly when the determinant is nonzero. For 3×3 determinants see the cofactor expansion guide.

What about 4×4 and larger?

The method is the same, but the arithmetic gets long and error-prone by hand. Use the calculator to check your work.

Should I use elimination for 2×2 too?

For 2×2 the formula is faster. From 3×3 up, elimination is usually easier to organize.

Related guides