ToolSphere
Back to all articles
student

Matrix Inverse by Gauss-Jordan Elimination

2026-11-129 min read

Try it: free Matrix Calculator

Exact inverse, determinant and RREF with steps

Open →

In introductory linear algebra courses—such as UC Berkeley's Math 54 or MIT's 18.06—finding the inverse of a square matrix is one of the foundational procedures students must master. While two-by-two matrices can be inverted using a short four-term shortcut, three-by-three and larger matrices require a systematic, algorithmic approach.

The standard textbook method taught across university mathematics, physics, and engineering curricula is Gauss-Jordan elimination on an augmented matrix. By placing the original matrix side by side with an identity matrix and applying elementary row operations until the left half becomes the identity matrix, the right half transforms directly into the exact inverse matrix.

This comprehensive guide details the mechanics of Gauss-Jordan elimination for 3×3 matrices. We walk through a complete, step-by-step worked example with exact fractions, show how to find the matrix determinant simultaneously through row reduction, explain how row swaps change signs, and illustrate exactly what happens when a matrix is singular and has no inverse.


What Is a Matrix Inverse?

For any non-zero real scalar k, its reciprocal k⁻¹ = 1/k satisfies k × (1/k) = 1. In linear algebra, square matrices represent linear transformations, but standard matrix division does not exist. Instead, we use the multiplicative inverse.

For an n × n square matrix A, its inverse A⁻¹ is the unique n × n matrix satisfying:

A × A⁻¹ = A⁻¹ × A = I

where I is the n × n identity matrix with ones along the main diagonal and zeros everywhere else:

    [ 1  0  0 ]
I = [ 0  1  0 ]
    [ 0  0  1 ]

If an inverse exists, the matrix A is called invertible or non-singular. If no inverse exists, A is called singular or degenerate.


The Three Elementary Row Operations

Gauss-Jordan elimination relies exclusively on three elementary row operations. These operations modify the rows of a matrix without altering the linear dependency relationships between its columns:

  1. Row Replacement (Addition): Add a scalar multiple of one row to another row:
    R_i → R_i + c × R_j (where i ≠ j).
  2. Row Scaling (Multiplication): Multiply all entries in a row by a non-zero scalar:
    R_i → c × R_i (where c ≠ 0).
  3. Row Swapping (Interchange): Swap the positions of two rows:
    R_i ↔ R_j.

When these operations are applied to an augmented matrix [ A | I ], each elementary row operation corresponds to multiplying both A and I on the left by an elementary matrix E. If a sequence of operations reduces A to I:

(E_k × ... × E₂ × E₁) × A = I

then multiplying that same sequence by I yields:

(E_k × ... × E₂ × E₁) × I = A⁻¹

This identity is the theoretical foundation of Gauss-Jordan elimination.


Step-by-Step 3×3 Worked Example with Exact Fractions

Let us invert the following real 3×3 matrix A:

    [ 2  1  1 ]
A = [ 1  2  1 ]
    [ 1  1  2 ]

We set up the augmented matrix [ A | I ] of size 3×6, placing A on the left and the 3×3 identity matrix I on the right:

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

Phase 1: Clear Column 1 Below the First Pivot

Our first pivot is the top-left entry in Row 1, Column 1, which currently equals 2.

Step 1.1: Normalize Row 1. Divide Row 1 by 2 (or multiply by 1/2) to create a leading 1:
R₁ → (1/2) × R₁

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

Step 1.2: Eliminate Row 2, Column 1. Subtract Row 1 from Row 2:
R₂ → R₂ − (1) × R₁

  • Col 1: 1 − 1 = 0
  • Col 2: 2 − 1/2 = 3/2
  • Col 3: 1 − 1/2 = 1/2
  • Col 4: 0 − 1/2 = -1/2
  • Col 5: 1 − 0 = 1
  • Col 6: 0 − 0 = 0

Step 1.3: Eliminate Row 3, Column 1. Subtract Row 1 from Row 3:
R₃ → R₃ − (1) × R₁

  • Col 1: 1 − 1 = 0
  • Col 2: 1 − 1/2 = 1/2
  • Col 3: 2 − 1/2 = 3/2
  • Col 4: 0 − 1/2 = -1/2
  • Col 5: 0 − 0 = 0
  • Col 6: 1 − 0 = 1

The augmented matrix after completing Column 1 is:

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

Phase 2: Clear Column 2 Above and Below the Second Pivot

Our second pivot is at Row 2, Column 2, which equals 3/2.

Step 2.1: Normalize Row 2. Multiply Row 2 by 2/3 so the pivot becomes 1:
R₂ → (2/3) × R₂

  • Col 2: (3/2) × (2/3) = 1
  • Col 3: (1/2) × (2/3) = 1/3
  • Col 4: (-1/2) × (2/3) = -1/3
  • Col 5: (1) × (2/3) = 2/3
  • Col 6: 0 × (2/3) = 0

Row 2 is now [ 0, 1, 1/3 | -1/3, 2/3, 0 ].

Step 2.2: Eliminate Row 1, Column 2. Subtract (1/2) × R₂ from Row 1:
R₁ → R₁ − (1/2) × R₂

  • Col 2: 1/2 − (1/2)(1) = 0
  • Col 3: 1/2 − (1/2)(1/3) = 3/6 − 1/6 = 2/6 = 1/3
  • Col 4: 1/2 − (1/2)(-1/3) = 3/6 + 1/6 = 4/6 = 2/3
  • Col 5: 0 − (1/2)(2/3) = -1/3
  • Col 6: 0 − 0 = 0

Step 2.3: Eliminate Row 3, Column 2. Subtract (1/2) × R₂ from Row 3:
R₃ → R₃ − (1/2) × R₂

  • Col 2: 1/2 − (1/2)(1) = 0
  • Col 3: 3/2 − (1/2)(1/3) = 9/6 − 1/6 = 8/6 = 4/3
  • Col 4: -1/2 − (1/2)(-1/3) = -3/6 + 1/6 = -2/6 = -1/3
  • Col 5: 0 − (1/2)(2/3) = -1/3
  • Col 6: 1 − 0 = 1

The augmented matrix after completing Column 2 is:

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

Phase 3: Clear Column 3 Above the Third Pivot

Our third pivot is at Row 3, Column 3, which equals 4/3.

Step 3.1: Normalize Row 3. Multiply Row 3 by 3/4 to make the pivot 1:
R₃ → (3/4) × R₃

  • Col 3: (4/3) × (3/4) = 1
  • Col 4: (-1/3) × (3/4) = -1/4
  • Col 5: (-1/3) × (3/4) = -1/4
  • Col 6: (1) × (3/4) = 3/4

Row 3 is now [ 0, 0, 1 | -1/4, -1/4, 3/4 ].

Step 3.2: Eliminate Row 1, Column 3. Subtract (1/3) × R₃ from Row 1:
R₁ → R₁ − (1/3) × R₃

  • Col 3: 1/3 − (1/3)(1) = 0
  • Col 4: 2/3 − (1/3)(-1/4) = 8/12 + 1/12 = 9/12 = 3/4
  • Col 5: -1/3 − (1/3)(-1/4) = -4/12 + 1/12 = -3/12 = -1/4
  • Col 6: 0 − (1/3)(3/4) = -1/4

Step 3.3: Eliminate Row 2, Column 3. Subtract (1/3) × R₃ from Row 2:
R₂ → R₂ − (1/3) × R₃

  • Col 3: 1/3 − (1/3)(1) = 0
  • Col 4: -1/3 − (1/3)(-1/4) = -4/12 + 1/12 = -3/12 = -1/4
  • Col 5: 2/3 − (1/3)(-1/4) = 8/12 + 1/12 = 9/12 = 3/4
  • Col 6: 0 − (1/3)(3/4) = -1/4

The final augmented matrix is:

[  1   0   0  |   3/4  -1/4  -1/4 ]
[  0   1   0  |  -1/4   3/4  -1/4 ]
[  0   0   1  |  -1/4  -1/4   3/4 ]

The left half is now the 3×3 identity matrix I. The right half is our exact inverse A⁻¹:

       [  3/4  -1/4  -1/4 ]
A⁻¹  = [ -1/4   3/4  -1/4 ]
       [ -1/4  -1/4   3/4 ]

Verification by Matrix Multiplication

To verify the result, compute the matrix product A × A⁻¹:

  • Row 1 × Column 1: 2(3/4) + 1(-1/4) + 1(-1/4) = 6/4 - 1/4 - 1/4 = 4/4 = 1
  • Row 1 × Column 2: 2(-1/4) + 1(3/4) + 1(-1/4) = -2/4 + 3/4 - 1/4 = 0
  • Row 1 × Column 3: 2(-1/4) + 1(-1/4) + 1(3/4) = -2/4 - 1/4 + 3/4 = 0
  • Row 2 × Column 2: 1(-1/4) + 2(3/4) + 1(-1/4) = -1/4 + 6/4 - 1/4 = 4/4 = 1
  • Row 3 × Column 3: 1(-1/4) + 1(-1/4) + 2(3/4) = -1/4 - 1/4 + 6/4 = 4/4 = 1

All off-diagonal entries sum to 0 and diagonal entries equal 1, confirming A × A⁻¹ = I.


Finding the Determinant by Row Reduction

Computing determinants using cofactor expansion on a 3×3 matrix requires evaluating three separate 2×2 sub-determinants. For larger matrices, cofactor expansion scales factorially (O(n!)). In contrast, row reduction computes the determinant in O(n³) operations.

How Row Operations Affect the Determinant

  1. Row Replacement (R_i → R_i + c × R_j): Does not change the determinant at all. det(A_new) = det(A).
  2. Row Swap (R_i ↔ R_j): Flips the sign of the determinant. det(A_new) = -det(A).
  3. Row Scaling (R_i → c × R_i): Multiplies the determinant by c. det(A_new) = c × det(A).

Once a matrix is transformed into upper-triangular form U (where all entries below the main diagonal are zero), its determinant is simply the product of the entries on its main diagonal:

det(U) = u₁₁ × u₂₂ × u₃₃

Computing det(A) for Example 1

To find det(A) without tracking scaling factors, reduce A to upper-triangular echelon form using only row replacement operations:

Starting matrix A:

[ 2  1  1 ]
[ 1  2  1 ]
[ 1  1  2 ]
  1. Eliminate Column 1 below the pivot:
    • R₂ → R₂ − (1/2) × R₁ gives Row 2 = [ 0, 3/2, 1/2 ]
    • R₃ → R₃ − (1/2) × R₁ gives Row 3 = [ 0, 1/2, 3/2 ]
  2. Eliminate Column 2 below the second pivot:
    • Subtract (1/3) × R₂ from Row 3:
      R₃ → R₃ − (1/3) × R₂
      Col 3 entry: 3/2 − (1/3)(1/2) = 3/2 − 1/6 = 9/6 − 1/6 = 8/6 = 4/3.

The resulting upper-triangular matrix U is:

    [ 2    1    1 ]
U = [ 0  3/2  1/2 ]
    [ 0    0  4/3 ]

Because only row replacement operations were performed, the determinant of A equals the determinant of U:

det(A) = 2 × (3/2) × (4/3) = (2 × 3 × 4) / (2 × 3) = 24 / 6 = 4

Row Swapping and Sign Tracking

What happens when a pivot entry is zero? Consider the matrix M:

    [ 0   2   1 ]
M = [ 1  -1   2 ]
    [ 3   1   4 ]

Because M[0][0] = 0, we cannot divide by zero to normalize the first row. We must perform a row swap.

Step 1: Swap Row 1 and Row 2.
R₁ ↔ R₂ (This swap flips the determinant sign: factor = -1).

[ 1  -1   2 ]
[ 0   2   1 ]
[ 3   1   4 ]

Step 2: Eliminate Row 3, Column 1.
R₃ → R₃ − 3 × R₁

  • Col 1: 3 − 3(1) = 0
  • Col 2: 1 − 3(-1) = 4
  • Col 3: 4 − 3(2) = -2

The matrix is now:

[ 1  -1   2 ]
[ 0   2   1 ]
[ 0   4  -2 ]

Step 3: Eliminate Row 3, Column 2.
R₃ → R₃ − 2 × R₂

  • Col 2: 4 − 2(2) = 0
  • Col 3: -2 − 2(1) = -4

The upper-triangular matrix U_M is:

[ 1  -1   2 ]
[ 0   2   1 ]
[ 0   0  -4 ]

The diagonal product is 1 × 2 × (-4) = -8. Because we performed one row swap, we multiply by -1:

det(M) = (-1)¹ × [ 1 × 2 × (-4) ] = (-1) × (-8) = 8

Since det(M) = 8 ≠ 0, matrix M is invertible. Running full Gauss-Jordan elimination on [ M | I ] produces its exact inverse:

       [ -3/4  -7/8   5/8 ]
M⁻¹  = [  1/4  -3/8   1/8 ]
       [  1/2   3/4  -1/4 ]

When No Inverse Exists: Singular Matrices

A matrix does not always have an inverse. If a matrix compresses space into a lower dimension (for example, flattening a 3D volume into a 2D plane or a 1D line), information is permanently lost and the transformation cannot be reversed.

Consider the matrix S:

    [ 1  2 -1 ]
S = [ 2  5  1 ]
    [ 3  7  0 ]

Notice that Row 3 is the exact sum of Row 1 and Row 2 (Row 3 = Row 1 + Row 2). The rows are linearly dependent. Let us observe what happens during Gauss-Jordan elimination on [ S | I ]:

[ 1  2 -1  |  1  0  0 ]
[ 2  5  1  |  0  1  0 ]
[ 3  7  0  |  0  0  1 ]
  1. Eliminate Column 1 below pivot:
    • R₂ → R₂ − 2 × R₁ gives Row 2 = [ 0, 1, 3 | -2, 1, 0 ]
    • R₃ → R₃ − 3 × R₁ gives Row 3 = [ 0, 1, 3 | -3, 0, 1 ]

The matrix becomes:

[ 1  2 -1  |  1  0  0 ]
[ 0  1  3  | -2  1  0 ]
[ 0  1  3  | -3  0  1 ]
  1. Eliminate Column 2:
    • R₁ → R₁ − 2 × R₂ gives Row 1 = [ 1, 0, -7 | 5, -2, 0 ]
    • R₃ → R₃ − 1 × R₂ gives Row 3:
      [ 0, 1, 3 | -3, 0, 1 ] − [ 0, 1, 3 | -2, 1, 0 ] = [ 0, 0, 0 | -1, -1, 1 ]

Look closely at the third row:

[ 0  0  0  |  -1  -1  1 ]

The entire left-hand side of Row 3 has become zeros:

0 × x₁ + 0 × x₂ + 0 × x₃ = -1

It is impossible to find a non-zero pivot in Column 3 or anywhere in Row 3. You cannot multiply or divide zero to produce a leading 1. Consequently, the left half can never be transformed into the identity matrix I.

The Invertible Matrix Theorem Checklist

When solving college midterm or homework problems, you can confirm whether a 3×3 matrix has an inverse using any of these mathematically equivalent statements:

Condition Invertible Matrix Singular Matrix
Determinant det(A) ≠ 0 det(A) = 0
Row Echelon Form 3 non-zero pivots (full rank = 3) At least one row of zeros (rank < 3)
Reduced Row Echelon Form (RREF) Reduces to identity matrix I Cannot reach I
Linear Independence Columns are linearly independent Columns are linearly dependent
Homogeneous System Ax = 0 Only trivial solution x = 0 Non-trivial solutions exist (null space > 0)
Matrix Transformation One-to-one and onto (bijective) Compresses dimension (kernel dimension ≥ 1)

Frequently Asked Questions

What is the difference between Gaussian elimination and Gauss-Jordan elimination?

Gaussian elimination applies row operations only to clear entries below each pivot, transforming the matrix into upper-triangular echelon form. It is typically paired with back-substitution to solve linear systems. Gauss-Jordan elimination continues further, eliminating entries both above and below every pivot to produce Reduced Row Echelon Form (RREF). For matrix inversion, Gauss-Jordan is necessary because the left side must reach the complete identity matrix I.

Why does Gauss-Jordan elimination place the identity matrix on the right?

Elementary row operations represent multiplication on the left by elementary matrices E_k ... E₁. If a series of operations reduces A to I, then (E_k ... E₁) × A = I, which means (E_k ... E₁) = A⁻¹. Because (E_k ... E₁) × I = A⁻¹, applying the exact same operations to I simultaneously builds A⁻¹ on the right-hand side.

Can I swap columns during Gauss-Jordan elimination?

No. Elementary row operations act on rows only. Swapping columns changes the identity of the underlying variables and does not correspond to left-multiplication by elementary matrices. If a pivot position is zero, you must swap rows (R_i ↔ R_j) with a lower row that has a non-zero entry in that column.

How do row operations change the determinant?

Row replacement (R_i → R_i + c × R_j) leaves the determinant unchanged. Row swapping (R_i ↔ R_j) flips the sign of the determinant (multiplies by -1). Row scaling (R_i → c × R_i) multiplies the determinant by c.

Why should I use exact fractions instead of decimals?

Floating-point decimals introduce rounding errors that compound across multiple row operations. A small rounding difference can prevent off-diagonal entries from canceling cleanly to zero, or incorrectly suggest that a singular matrix has a tiny non-zero determinant like 1e-16. Exact rational fractions maintain mathematical precision.

How can I check if my calculated inverse matrix is correct?

Multiply your calculated inverse by the original matrix: A × A⁻¹. If every diagonal entry equals 1 and every off-diagonal entry equals 0, your inverse is verified. You can also verify small arithmetic steps using our Matrix Calculator.

What happens if an entire row of zeros appears in the left matrix?

If any row on the left side becomes all zeros during elimination, the matrix is singular and has no inverse. Its determinant is 0, its rank is strictly less than 3, and its column vectors are linearly dependent.

Can a rectangular matrix have an inverse?

No. A two-sided inverse A⁻¹ that satisfies A × A⁻¹ = A⁻¹ × A = I exists only for square matrices (n × n). Rectangular matrices (m × n where m ≠ n) may have one-sided left or right pseudo-inverses under specific rank conditions, but they do not possess a standard two-sided inverse.

Is Gauss-Jordan elimination faster than Cramer's rule for 3×3 matrices?

Yes. Cramer's rule requires calculating four separate 3×3 determinants (one for the coefficient matrix and three for the variable replacements). Gauss-Jordan elimination solves the system or finds the entire inverse matrix in a single unified sequence of row operations.

Use the Linear System Solver to work through a related system of linear equations. For a related walkthrough, read Gaussian Elimination: Solving Ax = b.

Looking for other tools?

Explore ToolSphere Homepage →