Back to How to Solve

How to Solve Matrix Equations

Matrix equations look different from regular algebra, but the goal is the same: isolate the unknown. The key difference is that matrix multiplication has rules about dimensions and order. Once you respect those rules, problems like AX = B become systematic.

🧠 Linear Algebra⏱️ ~26 min read🔴 Advanced

Want to solve AX = B without getting stuck?

Try our ai math solver to compute inverses, do row reduction, and verify matrix equation solutions step by step.

Solve Now →

The Two Big Rules: Dimensions and Order

Before you solve anything, confirm the multiplication makes sense.

  • Dimension rule: If A is m×n and X is n×p, then AX is m×p.
  • Order rule: In general, AX is not the same as XA. You can’t “cancel” matrices the way you cancel numbers.

Many mistakes come from multiplying on the wrong side. If the equation is AX = B, you isolate X by multiplying on the left by A^-1. If the equation is XA = B, you multiply on the right by A^-1.

Case 1: Solve AX = B Using an Inverse (When It Exists)

If A is square (n×n) and invertible, then A^-1 exists and you can isolate X:

AX = B ⇒ A^-1(AX) = A^-1B ⇒ (A^-1A)X = A^-1B ⇒ X = A^-1B

This is the matrix version of “divide both sides by A,” but because matrices don’t commute, it matters that you multiply by A^-1 on the left.

Worked Example 1 (2×2): Solve AX = B

Problem: Solve AX = B where

A = [[2, 1], [3, 2]]
B = [[5], [12]]

Step 1: Compute A^-1. For a 2×2 matrix [[a, b], [c, d]], the inverse (if it exists) is (1/(ad−bc))·[[d, −b], [−c, a]].

det(A) = 2·2 − 1·3 = 1
A^-1 = [[2, −1], [−3, 2]]

Step 2: Multiply X = A^-1B.

X = [[2, −1], [−3, 2]] · [[5], [12]]
= [[2·5 + (−1)·12], [−3·5 + 2·12]]
= [[10 − 12], [−15 + 24]]
= [[−2], [9]]

Check: A·X = [[2, 1], [3, 2]]·[[-2], [9]] = [[5], [12]] = B.

Case 2: Solve XA = B (Inverse on the Right)

If the unknown is on the left, you multiply on the right:

XA = B ⇒ (XA)A^-1 = BA^-1 ⇒ X(AA^-1) = BA^-1 ⇒ X = BA^-1

The side you multiply on is determined by where the A is sitting. This is one of the main conceptual hurdles in matrix algebra.

Case 3: When an Inverse Is Not Available (Row Reduction)

Sometimes A is not square, or it’s square but singular (determinant 0). In those cases, you can’t use A^-1. The reliable alternative is row reduction.

If AX = B and X is a vector, you can build the augmented matrix [A | B] and row-reduce to solve the equivalent system. If you get a contradiction like 0 = 5, there is no solution. If you get a free variable, there are infinitely many solutions.

If X has multiple columns, you can treat each column as a separate right-hand side. That means you can solve AX = B by solving AX_1 = B_1, AX_2 = B_2, etc.

Which Method Should You Use?

In many classes, you learn the inverse method first because it looks like “division,” but row reduction is often the most practical method for real computations.

  • Use the inverse method when A is 2×2 (or a small 3×3), det(A) ≠ 0, and the problem explicitly asks for A^-1.
  • Use row reduction when A is bigger, when you suspect det(A)=0, or when you want a clear unique/no/infinite solution conclusion.
  • Always check by substituting: if you can multiply to confirm AX=B, do it.

Worked Example 2 (Row Reduction): Solve a Singular Case

Problem: Solve AX = B where

A = [[1, 2], [2, 4]]
B = [[3], [7]]

Here det(A) = 1·4 − 2·2 = 0, so A^-1 does not exist. Use the augmented matrix and row-reduce.

[1 2 | 3]
[2 4 | 7]
R2 → R2 − 2R1:
[1 2 | 3]
[0 0 | 1]

The last row says 0 = 1, which is impossible. So this matrix equation has no solution. This is a good reminder: some matrix equations are inconsistent.

How to Check Your Answer Fast

Matrix solutions are easy to mis-copy, so build a quick check into your workflow. You don’t need a full re-derivation—just a short consistency pass.

  • Check shapes first: verify AX and B have the same dimensions (same rows and columns).
  • Substitute: compute AX (or XA) using your candidate X and confirm it matches B exactly.
  • Reasonableness: if A is singular, expect “no solution” or “infinitely many” to be possible.
  • Column-by-column idea: if X has multiple columns, each column should satisfy its own system.

Common Mistakes

Multiplying on the wrong side

For AX = B you need A^-1 on the left. For XA = B you need A^-1 on the right.

Ignoring dimensions

If the sizes don’t match, the multiplication is undefined. Always identify the shape of X first.

Assuming every matrix is invertible

If det(A) = 0 (or A isn’t square), you must use row reduction or another method.

Not checking the answer

Substitute back: compute AX (or XA) and confirm it matches B.

If you want a strong conceptual reference on matrix equations and row reduction, the early linear algebra units in Khan Academy Linear Algebra are a dependable refresher.

Practice Problems

  1. Solve AX = B with A = [[1, 2], [0, 3]] and B = [[5], [6]].
  2. Solve XA = B with A = [[2, 0], [1, 1]] and B = [[4, 2], [3, 1]].
  3. Decide whether A is invertible: A = [[1, 2], [2, 4]]. Explain why.
  4. Row-reduce [A | b] for A = [[1, 1], [2, 3]] and b = [[4], [10]].

Want Matrix Arithmetic Checked?

Paste your matrix equation and get X plus a substitution check.

Try AI Math Solver →
How to Solve Matrix Equations | AX = B, Inverses, Row Reduction (with Examples)