Precalculus · Grades 11, 12

Solving Systems with Matrix Equations

Quick answer

A system of linear equations can be written as one matrix equation, AX = B: the coefficients in a matrix, the unknowns in a column, the constants in a column. If A has an inverse, multiplying both sides by it leaves X by itself, the way dividing by a number solves 3x = 12. If A has no inverse, the system has no single solution. Larger systems work the same way with technology.

What you'll learn

  • Write a system of linear equations as a matrix equation
  • Solve a 2×2 system with the inverse matrix
  • Interpret a zero determinant and solve larger systems with technology

A system as one equation

Here is a system of two equations:

{2x+y=5x−y=1\begin{cases} 2x + y = 5 \\[2pt] x - y = 1 \end{cases}

The coefficients, the unknowns and the constants each fit in their own matrix:

[211−1]⏟A[xy]⏟X=[51]⏟B\underbrace{\begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix}}_{A} \underbrace{\begin{bmatrix} x \\ y \end{bmatrix}}_{X} = \underbrace{\begin{bmatrix} 5 \\ 1 \end{bmatrix}}_{B}

Multiplying out the left side gives back 2x+y2x + y and x−yx - y, so this single equation says exactly what the two did. Written short, it is

AX=BAX = B

It looks like 3x=123x = 12, and it is solved in the same spirit.

Solving with the inverse

For 3x=123x = 12 you multiply both sides by 13\tfrac{1}{3}. For AX=BAX = B you multiply both sides by A−1A^{-1}, on the left.

AA has determinant 2(−1)−1(1)=−32(-1) - 1(1) = -3, so by the inverse formula:

A−1=1−3[−1−1−12]=[131313−23]A^{-1} = \frac{1}{-3}\begin{bmatrix} -1 & -1 \\ -1 & 2 \end{bmatrix} = \begin{bmatrix} \tfrac{1}{3} & \tfrac{1}{3} \\ \tfrac{1}{3} & -\tfrac{2}{3} \end{bmatrix}

Then

X=A−1B=[131313−23][51]=[21]X = A^{-1}B = \begin{bmatrix} \tfrac{1}{3} & \tfrac{1}{3} \\ \tfrac{1}{3} & -\tfrac{2}{3} \end{bmatrix}\begin{bmatrix} 5 \\ 1 \end{bmatrix} = \begin{bmatrix} 2 \\ 1 \end{bmatrix}

So x=2x = 2 and y=1y = 1. Check: 2(2)+1=52(2) + 1 = 5 ✓ and 2−1=12 - 1 = 1 ✓

Why multiplying by the inverse solves the system

Start from AX=BAX = B and multiply both sides on the left by A−1A^{-1}:

A−1(AX)=A−1BA^{-1}(AX) = A^{-1}B

Matrix multiplication is associative, so the left side can be regrouped:

(A−1A)X=A−1B⟹IX=A−1B⟹X=A−1B(A^{-1}A)X = A^{-1}B \quad\Longrightarrow\quad IX = A^{-1}B \quad\Longrightarrow\quad X = A^{-1}B

Each step uses one fact from the matrices lesson: associativity to regroup, A−1A=IA^{-1}A = I to cancel, and IX=XIX = X to finish.

The inverse has to go on the left. Matrix multiplication is not commutative, and A−1A^{-1} only cancels AA when it sits right beside it. Writing BA−1BA^{-1} instead is a different product, and here it does not even fit: BB has one column but A−1A^{-1} has two rows.

When there is no inverse

If det⁡A=0\det A = 0, the inverse does not exist, and the system does not have a single solution.

{x+2y=32x+4y=7det⁡[1224]=4−4=0\begin{cases} x + 2y = 3 \\[2pt] 2x + 4y = 7 \end{cases} \qquad \det\begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix} = 4 - 4 = 0

The second equation’s left side is twice the first’s, but 77 is not twice 33. The lines are parallel, and there is no solution. Had the right side been 66, the equations would describe the same line, with infinitely many solutions.

det⁡A\det AThe system has
not 00exactly one solution, X=A−1BX = A^{-1}B
00no solution or infinitely many

Larger systems

The method does not change with size. A system in three unknowns is still AX=BAX = B:

{x+y+z=62y+5z=−42x+5y−z=27A=[11102525−1]B=[6−427]\begin{cases} x + y + z = 6 \\[2pt] 2y + 5z = -4 \\[2pt] 2x + 5y - z = 27 \end{cases} \qquad A = \begin{bmatrix} 1 & 1 & 1 \\ 0 & 2 & 5 \\ 2 & 5 & -1 \end{bmatrix} \quad B = \begin{bmatrix} 6 \\ -4 \\ 27 \end{bmatrix}

Inverting a 3×33 \times 3 matrix by hand is long, so this is where a graphing calculator or a spreadsheet takes over: enter AA and BB and compute A−1BA^{-1}B. The result is

X=[53−2]X = \begin{bmatrix} 5 \\ 3 \\ -2 \end{bmatrix}

Substituting is the check a machine cannot skip for you: 5+3−2=65 + 3 - 2 = 6 ✓, 6−10=−46 - 10 = -4 ✓, 10+15+2=2710 + 15 + 2 = 27 ✓

Worked examples

Common mistakes

Practice problems

  1. Write x+y=20x + y = 20 and 5x+3y=765x + 3y = 76 as a matrix equation.

    Answer

    [1153][xy]=[2076]\begin{bmatrix} 1 & 1 \\ 5 & 3 \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 20 \\ 76 \end{bmatrix}

    Full solution

    Coefficients go in the matrix, row by row; the unknowns in a column; the constants in a column.

  2. Solve the system in problem 1 with the inverse matrix.

    Answer

    x=8x = 8, y=12y = 12

    Full solution

    det⁡=3−5=−2\det = 3 - 5 = -2. A−1=1−2[3−1−51]A^{-1} = \tfrac{1}{-2}\begin{bmatrix} 3 & -1 \\ -5 & 1 \end{bmatrix}.

    A−1B=1−2[60−76−100+76]=1−2[−16−24]=[812]A^{-1}B = \tfrac{1}{-2}\begin{bmatrix} 60 - 76 \\ -100 + 76 \end{bmatrix} = \tfrac{1}{-2}\begin{bmatrix} -16 \\ -24 \end{bmatrix} = \begin{bmatrix} 8 \\ 12 \end{bmatrix}.

    Check: 8+12=208 + 12 = 20 ✓ and 40+36=7640 + 36 = 76 ✓

  3. A bake sale sells 2020 items, pies at 55 dollars and cookies at 33, for 7676 dollars. How many pies were sold?

    Answer

    88 pies

    Full solution

    This is the system from problem 1, with xx pies and yy cookies. It gives 88 pies and 1212 cookies.

  4. Solve 2x+y=52x + y = 5 and x−y=1x - y = 1 using A−1A^{-1}.

    Answer

    x=2x = 2, y=1y = 1

    Full solution

    det⁡A=−3\det A = -3, A−1=[131313−23]A^{-1} = \begin{bmatrix} \tfrac{1}{3} & \tfrac{1}{3} \\ \tfrac{1}{3} & -\tfrac{2}{3} \end{bmatrix}, and A−1[51]=[21]A^{-1}\begin{bmatrix} 5 \\ 1 \end{bmatrix} = \begin{bmatrix} 2 \\ 1 \end{bmatrix}.

  5. Find the determinant of the coefficient matrix for x+2y=3x + 2y = 3 and 2x+4y=72x + 4y = 7. What does it say about the system?

    Answer

    00; the system has no single solution — here, none.

    Full solution

    1⋅4−2⋅2=01 \cdot 4 - 2 \cdot 2 = 0. The second equation’s left side is twice the first, but 7≠67 \ne 6, so the lines are parallel.

  6. Change one number in problem 5 so the system has infinitely many solutions.

    Answer

    Replace 77 with 66.

    Full solution

    Then the second equation is exactly twice the first, so both describe the same line, and every point on it is a solution.

  7. Write the 3×33 \times 3 system x+y+z=6x + y + z = 6, 2y+5z=−42y + 5z = -4, 2x+5y−z=272x + 5y - z = 27 as AX=BAX = B.

    Answer

    A=[11102525−1]A = \begin{bmatrix} 1 & 1 & 1 \\ 0 & 2 & 5 \\ 2 & 5 & -1 \end{bmatrix}, X=[xyz]X = \begin{bmatrix} x \\ y \\ z \end{bmatrix}, B=[6−427]B = \begin{bmatrix} 6 \\ -4 \\ 27 \end{bmatrix}

    Full solution

    The second equation has no xx, so its first coefficient is 00.

  8. Check that (5,3,−2)(5, 3, -2) solves the system in problem 7.

    Answer

    All three equations hold.

    Full solution

    5+3−2=65 + 3 - 2 = 6 ✓, 2(3)+5(−2)=−42(3) + 5(-2) = -4 ✓, and 2(5)+5(3)−(−2)=272(5) + 5(3) - (-2) = 27 ✓

  9. Explain why X=A−1BX = A^{-1}B follows from AX=BAX = B.

    Answer

    Multiply both sides on the left by A−1A^{-1}, regroup, and use A−1A=IA^{-1}A = I and IX=XIX = X.

    Full solution

    A−1(AX)=A−1BA^{-1}(AX) = A^{-1}B. By associativity the left side is (A−1A)X=IX=X(A^{-1}A)X = IX = X. So X=A−1BX = A^{-1}B.

  10. Solving AX=BAX = B, Nate computes X=BA−1X = BA^{-1}. Find his error.

    Hint

    Where does A−1A^{-1} need to sit to cancel AA?

    Answer

    The inverse must multiply on the left: X=A−1BX = A^{-1}B.

    Full solution

    In AX=BAX = B, the matrix AA is on the left of XX. Only a factor of A−1A^{-1} placed directly beside it, on the left, can combine with it to give II.

    Matrix multiplication is not commutative, so BA−1BA^{-1} is a different product. For a 2×22 \times 2 system it does not even exist: BB is 2×12 \times 1 and A−1A^{-1} is 2×22 \times 2, and the inner sizes 11 and 22 do not match.

Frequently asked questions

How do I write a system as a matrix equation?

Put the coefficients in a matrix A, the unknowns in a column X, and the constants in a column B. The system is AX = B.

How does the inverse solve AX = B?

Multiply both sides on the left by A⁻¹. Since A⁻¹A = I and IX = X, the equation becomes X = A⁻¹B.

Why must A⁻¹ go on the left?

Matrix multiplication is not commutative. A⁻¹ has to sit next to A to cancel it, and A is on the left of X.

What if the determinant is zero?

Then A has no inverse, and the system has either no solution or infinitely many — the lines are parallel or the same line.

How do I solve a 3×3 system?

Write it as AX = B and let a calculator or spreadsheet compute A⁻¹B. The method is the same; only the arithmetic grows.

What to learn next

Standards alignment

This lesson covers the following Common Core State Standards for Mathematics.

  • CCSS.MATH.CONTENT.HSA.REI.C.8Reasoning with Equations and Inequalities(+) Represent a system of linear equations as a single matrix equation in a vector variable.
  • CCSS.MATH.CONTENT.HSA.REI.C.9Reasoning with Equations and Inequalities(+) Find the inverse of a matrix if it exists and use it to solve systems of linear equations (using technology for matrices of dimension 3 × 3 or greater).