Matrix Inverse

Step through Gauss-Jordan elimination on [A | I] and watch the identity matrix turn into the inverse. Try a singular matrix to see where it breaks.

Intermediate
SizeLoad

Matrix A (integers)

Determinant

det(A) = 10

det(A) ≠ 0, so A is invertible. Gauss-Jordan elimination will turn [A | I] into [I | A⁻¹].

Step 1 of 6

Start with [A | I]

Write A next to the identity matrix. Every row operation is applied to the whole row, both halves.

4
7
1
0
2
6
0
1
changed row row used pivotright half: becomes A⁻¹

Row operations

2×2 shortcut: the adjugate formula

Swap the diagonal entries, negate the off-diagonal entries, then divide by the determinant.

A⁻¹ = 1/(ad − bc) ×
d−b−ca
= 1/10 ×
6−7−24
=
3/5−7/10−1/52/5

What is an inverse matrix?

The inverse of a square matrix A is the matrix A⁻¹ that undoes it: multiplying them in either order gives the identity, AA⁻¹ = A⁻¹A = I. If A rotates, stretches or shears the plane, A⁻¹ puts every point back where it started.

Not every matrix has an inverse. If A flattens space onto a line or a point, different inputs land on the same output and there is no way to tell them apart afterwards. That happens exactly when det(A) = 0. Such a matrix is called singular.

Gauss-Jordan elimination finds the inverse with row operations. Each row operation is the same as multiplying on the left by an elementary matrix E. If a sequence of them turns A into I, then Ek…E1A = I, so Ek…E1 = A⁻¹. Applying the same operations to I (the right half of [A | I]) builds exactly that product.

The three row operations

Swap two rows

Ri ↔ Rj. Used when the pivot position holds a 0 and a lower row has a non-zero entry in that column.

Scale a row

Ri ← k·Ri with k ≠ 0. Used to turn the pivot into a 1.

Add a multiple of another row

Ri ← Ri − k·Rj. Used to make every other entry in the pivot column 0.

Key formulas

Definition

A·A⁻¹ = A⁻¹·A = I

Gauss-Jordan

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

2×2 inverse (adjugate formula)

A⁻¹ = 1/(ad − bc) × [[d, −b], [−c, a]]

A
[[a, b], [c, d]]
ad − bc
the determinant; must be non-zero

General adjugate formula and useful rules

A⁻¹ = adj(A) / det(A)

(AB)⁻¹ = B⁻¹A⁻¹

det(A⁻¹) = 1 / det(A)

Watch the order

The inverse of a product reverses the order: (AB)⁻¹ = B⁻¹A⁻¹, just as you take off your shoes before your socks.

How to use this visualizer

  1. 1
    Choose a 2×2 or 3×3 matrix and type integer entries, or load one of the presets.
  2. 2
    Check the determinant. If it is 0 the matrix is singular and has no inverse.
  3. 3
    Press Next step to apply one row operation at a time. The changed row is highlighted in amber, the row used to change it in blue, and the current pivot is outlined.
  4. 4
    Click any operation in the list to jump straight to it.
  5. 5
    At the last step the left half is I and the right half is A⁻¹. For a 2×2 matrix, compare it with the adjugate formula below the steps.
  6. 6
    Load the Singular preset to see elimination stop when a column has no pivot.

Where inverses are used

Solving linear systems

If Ax = b and A is invertible, then x = A⁻¹b. One inverse solves the system for every right-hand side b.

Computer graphics

Undoing a camera or model transformation means applying its inverse matrix, for example to map a mouse click back into world space.

Cryptography

The Hill cipher encrypts blocks of letters with a matrix; decrypting uses its inverse (modulo 26).

Statistics

Least-squares regression uses (XᵀX)⁻¹Xᵀy to find the best-fit coefficients.

Practice problems

Problem 1: Invert a 2×2 matrix

Find the inverse of A = [[3, 5], [1, 2]] and check your answer.
Show solution

det(A) = 3×2 − 5×1 = 1

A⁻¹ = 1/1 × [[2, −5], [−1, 3]]

A⁻¹ = [[2, −5], [−1, 3]]

Check: row 1 of A times A⁻¹ = [3×2 + 5×(−1), 3×(−5) + 5×3] = [1, 0]

Row 2 of A times A⁻¹ = [1×2 + 2×(−1), 1×(−5) + 2×3] = [0, 1]. So AA⁻¹ = I.

Problem 2: Solve a system with the inverse

Solve 4x + 7y = 15 and 2x + 6y = 10 by writing it as Ax = b with A = [[4, 7], [2, 6]].
Show solution

det(A) = 4×6 − 7×2 = 10

A⁻¹ = 1/10 × [[6, −7], [−2, 4]]

x = A⁻¹b = 1/10 × [6×15 − 7×10, −2×15 + 4×10]

= 1/10 × [20, 10]

x = 2, y = 1

Check: 4(2) + 7(1) = 15 and 2(2) + 6(1) = 10.

Discussion

Questions, ideas or a different approach? Join the conversation.