Tutorials › Linear Algebra › Solving Matrix Equations with Inverses

Elementary Matrices and Inverses · Tutorial 108 of 1000

Solving Matrix Equations with Inverses

Learn how to isolate an unknown matrix in equations of the forms \(\mathbf{A}\mathbf{X}=\mathbf{B}\) and \(\mathbf{X}\mathbf{A}=\mathbf{B}\), and verify the result.

Beginner 9 min read

What You'll Learn

  • Identify the dimensions of the unknown matrix in each equation.
  • Solve \(\mathbf{A}\mathbf{X}=\mathbf{B}\) by multiplying on the left by \(\mathbf{A}^{-1}\).
  • Solve \(\mathbf{X}\mathbf{A}=\mathbf{B}\) by multiplying on the right by \(\mathbf{A}^{-1}\).
  • Prove that each equation has exactly one solution when \(\mathbf{A}\) is invertible.
  • Check a proposed solution by multiplying in the original order.
  • Recognize why the inverse method does not apply when the coefficient matrix is singular.

Two Equations, Two Sides

In a scalar equation such as \(ax=b\), multiplication can be rearranged without changing its order. Matrix multiplication does not generally commute: \(\mathbf{A}\mathbf{B}\) and \(\mathbf{B}\mathbf{A}\) may be different, and one product may not even be defined. So solving a matrix equation means paying attention not only to which matrix is unknown, but also to which side each factor occupies.

We will consider square invertible coefficient matrices \(\mathbf{A}\in\mathbb{R}^{n\times n}\). An inverse of \(\mathbf{A}\) is a matrix \(\mathbf{A}^{-1}\) satisfying \(\mathbf{A}\mathbf{A}^{-1}=\mathbf{A}^{-1}\mathbf{A}=\mathbf{I}_n\). For \(\mathbf{A}\mathbf{X}=\mathbf{B}\), if \(\mathbf{B}\in\mathbb{R}^{n\times p}\), then \(\mathbf{X}\) must be in \(\mathbb{R}^{n\times p}\). For \(\mathbf{X}\mathbf{A}=\mathbf{B}\), if \(\mathbf{B}\in\mathbb{R}^{m\times n}\), then \(\mathbf{X}\) must be in \(\mathbb{R}^{m\times n}\). These dimensions make the products and the proposed solutions well-defined.

Key rule: If \(\mathbf{A}\) is invertible, then \(\mathbf{A}\mathbf{X}=\mathbf{B}\) is solved by multiplying by \(\mathbf{A}^{-1}\) on the left, giving \(\mathbf{X}=\mathbf{A}^{-1}\mathbf{B}\). The equation \(\mathbf{X}\mathbf{A}=\mathbf{B}\) is solved by multiplying by \(\mathbf{A}^{-1}\) on the right, giving \(\mathbf{X}=\mathbf{B}\mathbf{A}^{-1}\).

The side is determined by the original equation. In the first equation, \(\mathbf{A}\) stands immediately to the left of \(\mathbf{X}\), so its inverse must act on the left to cancel it. In the second, \(\mathbf{A}\) stands to the right of \(\mathbf{X}\), so its inverse must act on the right. The order of the other factors is not free to change.

Solving \(\mathbf{A}\mathbf{X}=\mathbf{B}\)

Theorem: Let \(\mathbf{A}\in\mathbb{R}^{n\times n}\) be invertible and \(\mathbf{B}\in\mathbb{R}^{n\times p}\). Then the equation \(\mathbf{A}\mathbf{X}=\mathbf{B}\) has exactly one solution \(\mathbf{X}\in\mathbb{R}^{n\times p}\), namely \(\mathbf{X}=\mathbf{A}^{-1}\mathbf{B}\).

Proof. For existence, set \(\mathbf{X}=\mathbf{A}^{-1}\mathbf{B}\), which has size \(n\times p\). Then \(\mathbf{A}\mathbf{X}=\mathbf{A}(\mathbf{A}^{-1}\mathbf{B})=(\mathbf{A}\mathbf{A}^{-1})\mathbf{B}=\mathbf{I}_n\mathbf{B}=\mathbf{B}\), using associativity and the identity law. For uniqueness, suppose \(\mathbf{Y}\) is any solution, so \(\mathbf{A}\mathbf{Y}=\mathbf{B}\). Multiplying this equality on the left by \(\mathbf{A}^{-1}\) gives \(\mathbf{A}^{-1}(\mathbf{A}\mathbf{Y})=\mathbf{A}^{-1}\mathbf{B}\), hence \((\mathbf{A}^{-1}\mathbf{A})\mathbf{Y}=\mathbf{A}^{-1}\mathbf{B}\) and \(\mathbf{Y}=\mathbf{A}^{-1}\mathbf{B}\). Thus every solution equals the one already found. \(\square\)

Worked Example: Solve a Left-Multiplication Equation

Solve \(\mathbf{A}\mathbf{X}=\mathbf{B}\), where \(\mathbf{A}=\begin{bmatrix}1&2\\0&1\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}3&1&0\\2&4&1\end{bmatrix}\). Here \(\mathbf{A}\) is \(2\times2\), \(\mathbf{B}\) is \(2\times3\), and \(\mathbf{X}\) must be \(2\times3\).

The inverse is \(\mathbf{A}^{-1}=\begin{bmatrix}1&-2\\0&1\end{bmatrix}\), since multiplying in either order gives \(\mathbf{I}_2\). The inverse goes on the left of \(\mathbf{B}\):

$$ \mathbf{X}=\mathbf{A}^{-1}\mathbf{B} =\begin{bmatrix}1&-2\\0&1\end{bmatrix} \begin{bmatrix}3&1&0\\2&4&1\end{bmatrix} =\begin{bmatrix}-1&-7&-2\\2&4&1\end{bmatrix}. $$

For example, the first row of the product is \((3-4,\;1-8,\;0-2)=(-1,-7,-2)\), and the second row is \((2,4,1)\). Check by multiplying in the original order:

$$ \mathbf{A}\mathbf{X} =\begin{bmatrix}1&2\\0&1\end{bmatrix} \begin{bmatrix}-1&-7&-2\\2&4&1\end{bmatrix} =\begin{bmatrix}-1+4&-7+8&-2+2\\2&4&1\end{bmatrix} =\begin{bmatrix}3&1&0\\2&4&1\end{bmatrix} =\mathbf{B}. $$

The product has the required size and equals \(\mathbf{B}\), so it verifies the solution. The theorem also guarantees there is no second solution.

Solving \(\mathbf{X}\mathbf{A}=\mathbf{B}\)

Theorem: Let \(\mathbf{A}\in\mathbb{R}^{n\times n}\) be invertible and \(\mathbf{B}\in\mathbb{R}^{m\times n}\). Then the equation \(\mathbf{X}\mathbf{A}=\mathbf{B}\) has exactly one solution \(\mathbf{X}\in\mathbb{R}^{m\times n}\), namely \(\mathbf{X}=\mathbf{B}\mathbf{A}^{-1}\).

Proof. For existence, set \(\mathbf{X}=\mathbf{B}\mathbf{A}^{-1}\), which has size \(m\times n\). Then \(\mathbf{X}\mathbf{A}=(\mathbf{B}\mathbf{A}^{-1})\mathbf{A}=\mathbf{B}(\mathbf{A}^{-1}\mathbf{A})=\mathbf{B}\mathbf{I}_n=\mathbf{B}\). For uniqueness, suppose \(\mathbf{Y}\mathbf{A}=\mathbf{B}\). Multiply on the right by \(\mathbf{A}^{-1}\): \((\mathbf{Y}\mathbf{A})\mathbf{A}^{-1}=\mathbf{B}\mathbf{A}^{-1}\). Associativity gives \(\mathbf{Y}(\mathbf{A}\mathbf{A}^{-1})=\mathbf{B}\mathbf{A}^{-1}\), so \(\mathbf{Y}\mathbf{I}_n=\mathbf{B}\mathbf{A}^{-1}\) and therefore \(\mathbf{Y}=\mathbf{B}\mathbf{A}^{-1}\). Every solution must be this matrix. \(\square\)

Worked Example: Solve a Right-Multiplication Equation

Use the same \(\mathbf{A}=\begin{bmatrix}1&2\\0&1\end{bmatrix}\), and solve \(\mathbf{X}\mathbf{A}=\mathbf{B}\) for \(\mathbf{B}=\begin{bmatrix}3&1\\2&4\\1&0\end{bmatrix}\). Since \(\mathbf{B}\) is \(3\times2\), the unknown \(\mathbf{X}\) must be \(3\times2\).

This time the inverse belongs on the right of \(\mathbf{B}\):

$$ \mathbf{X}=\mathbf{B}\mathbf{A}^{-1} =\begin{bmatrix}3&1\\2&4\\1&0\end{bmatrix} \begin{bmatrix}1&-2\\0&1\end{bmatrix} =\begin{bmatrix}3&-5\\2&0\\1&-2\end{bmatrix}. $$

The rows are computed separately: \((3,1)\mathbf{A}^{-1}=(3,-6+1)=(3,-5)\), \((2,4)\mathbf{A}^{-1}=(2,-4+4)=(2,0)\), and \((1,0)\mathbf{A}^{-1}=(1,-2)\). Check by multiplying on the right by \(\mathbf{A}\):

$$ \mathbf{X}\mathbf{A} =\begin{bmatrix}3&-5\\2&0\\1&-2\end{bmatrix} \begin{bmatrix}1&2\\0&1\end{bmatrix} =\begin{bmatrix}3&6-5\\2&4\\1&2-2\end{bmatrix} =\begin{bmatrix}3&1\\2&4\\1&0\end{bmatrix} =\mathbf{B}. $$

This check confirms the order as well as the arithmetic: the product is \(\mathbf{X}\mathbf{A}\), as required.

Why the Two Answers Can Differ

When \(\mathbf{A}\) and \(\mathbf{B}\) are square, both forms may be written with the same matrices, but they still ask different questions. The equation \(\mathbf{A}\mathbf{X}=\mathbf{B}\) has answer \(\mathbf{A}^{-1}\mathbf{B}\), whereas \(\mathbf{X}\mathbf{A}=\mathbf{B}\) has answer \(\mathbf{B}\mathbf{A}^{-1}\). These expressions need not be equal. They would be equal only in cases where \(\mathbf{A}^{-1}\mathbf{B}=\mathbf{B}\mathbf{A}^{-1}\); no such equality is guaranteed for arbitrary matrices.

Worked Example: Compare the Two Orders

Let \(\mathbf{A}=\begin{bmatrix}1&2\\0&1\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}3&1\\2&4\end{bmatrix}\). First solve \(\mathbf{A}\mathbf{X}=\mathbf{B}\):

$$ \mathbf{X}=\mathbf{A}^{-1}\mathbf{B} =\begin{bmatrix}1&-2\\0&1\end{bmatrix} \begin{bmatrix}3&1\\2&4\end{bmatrix} =\begin{bmatrix}-1&-7\\2&4\end{bmatrix}. $$

Then solve the different equation \(\mathbf{X}\mathbf{A}=\mathbf{B}\):

$$ \mathbf{X}=\mathbf{B}\mathbf{A}^{-1} =\begin{bmatrix}3&1\\2&4\end{bmatrix} \begin{bmatrix}1&-2\\0&1\end{bmatrix} =\begin{bmatrix}3&-5\\2&0\end{bmatrix}. $$

Check the first answer: \(\begin{bmatrix}1&2\\0&1\end{bmatrix}\begin{bmatrix}-1&-7\\2&4\end{bmatrix}=\begin{bmatrix}3&1\\2&4\end{bmatrix}=\mathbf{B}\). Check the second: \(\begin{bmatrix}3&-5\\2&0\end{bmatrix}\begin{bmatrix}1&2\\0&1\end{bmatrix}=\begin{bmatrix}3&1\\2&4\end{bmatrix}=\mathbf{B}\). The two solutions differ because the equations put \(\mathbf{A}\) on opposite sides of \(\mathbf{X}\).

Common Mistake: Multiplying on the Wrong Side

A frequent error is to remember “multiply by the inverse” but ignore which side it must be on. In the first equation of the example above, a wrong step would be to write \(\mathbf{X}=\mathbf{B}\mathbf{A}^{-1}\). That expression actually solves \(\mathbf{X}\mathbf{A}=\mathbf{B}\), not \(\mathbf{A}\mathbf{X}=\mathbf{B}\). Substituting it into the left-multiplication equation exposes the error:

$$ \mathbf{A}(\mathbf{B}\mathbf{A}^{-1}) =\begin{bmatrix}1&2\\0&1\end{bmatrix} \begin{bmatrix}3&-5\\2&0\end{bmatrix} =\begin{bmatrix}7&-5\\2&0\end{bmatrix} \ne \begin{bmatrix}3&1\\2&4\end{bmatrix} =\mathbf{B}. $$

The correction follows the original order: from \(\mathbf{A}\mathbf{X}=\mathbf{B}\), multiply both sides on the left by \(\mathbf{A}^{-1}\), obtaining \(\mathbf{A}^{-1}\mathbf{A}\mathbf{X}=\mathbf{A}^{-1}\mathbf{B}\), and hence \(\mathbf{X}=\mathbf{A}^{-1}\mathbf{B}\). For \(\mathbf{X}\mathbf{A}=\mathbf{B}\), multiply both sides on the right instead. Always substitute the proposed answer into the original equation; checking a product in a different order is not a valid verification.

When the Inverse Method Does Not Apply

The two theorems require that \(\mathbf{A}\) be square and invertible. If \(\mathbf{A}\) is singular, the inverse formulas are unavailable, but that does not by itself tell us whether an equation has no solution or many solutions. For example, let \(\mathbf{A}=\begin{bmatrix}1&0\\0&0\end{bmatrix}\). For \(\mathbf{A}\mathbf{X}=\mathbf{O}\), both \(\mathbf{X}=\mathbf{O}\) and \(\mathbf{X}=\begin{bmatrix}0&0\\1&0\end{bmatrix}\) are solutions, since multiplying either on the left by \(\mathbf{A}\) gives \(\mathbf{O}\). In contrast, \(\mathbf{A}\mathbf{X}=\mathbf{I}_2\) has no solution: every product \(\mathbf{A}\mathbf{X}\) has a zero second row, but \(\mathbf{I}_2\) has second row \((0,1)\). Thus invertibility guarantees one solution for every right-hand side, while a singular coefficient requires a separate analysis.

1
Check the equation's form.
Decide whether the unknown appears as \(\mathbf{A}\mathbf{X}\) or \(\mathbf{X}\mathbf{A}\).
2
Check dimensions and invertibility.
Confirm that \(\mathbf{A}\) is square and invertible, and determine the required size of \(\mathbf{X}\).
3
Apply the inverse on the matching side.
Use \(\mathbf{A}^{-1}\mathbf{B}\) for \(\mathbf{A}\mathbf{X}=\mathbf{B}\), and \(\mathbf{B}\mathbf{A}^{-1}\) for \(\mathbf{X}\mathbf{A}=\mathbf{B}\).
4
Verify in the original order.
Multiply the candidate by \(\mathbf{A}\) on the side specified in the equation and confirm that the result is \(\mathbf{B}\).

This method matters because matrix equations often encode several ordinary linear systems at once. The rules above handle all the columns of a left-multiplication equation or all the rows of a right-multiplication equation while preserving the order of matrix products. Keeping dimensions, side, and verification together prevents a plausible-looking inverse formula from solving the wrong equation.

Check Your Understanding

For each problem, identify the required size of the unknown and check any proposed answer by substitution.

  1. If \(\mathbf{A}\) is an invertible \(3\times3\) matrix and \(\mathbf{B}\) is \(3\times2\), what is the solution formula and size of \(\mathbf{X}\) in \(\mathbf{A}\mathbf{X}=\mathbf{B}\)?
  2. If \(\mathbf{A}\) is an invertible \(2\times2\) matrix and \(\mathbf{B}\) is \(4\times2\), what is the solution formula and size of \(\mathbf{X}\) in \(\mathbf{X}\mathbf{A}=\mathbf{B}\)?
  3. For \(\mathbf{A}=\begin{bmatrix}1&1\\0&1\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}2&3\\1&0\end{bmatrix}\), find \(\mathbf{X}\) satisfying \(\mathbf{A}\mathbf{X}=\mathbf{B}\), then verify.
  4. Explain why \(\mathbf{B}\mathbf{A}^{-1}\) is the appropriate formula for \(\mathbf{X}\mathbf{A}=\mathbf{B}\), not for \(\mathbf{A}\mathbf{X}=\mathbf{B}\).
  5. Give one reason a singular coefficient matrix can lead to no solution, and one reason it can lead to more than one solution.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon