CP 3.7 - Solving three equations with matrices

CP 3.7 - Solving three equations with matrices

Three simultaneous linear equations can be written as one matrix equation. You will use an inverse matrix to recover the three unknowns, check the result in the original equations, and solve systems whose coefficients contain a parameter.

Writing a system as a matrix equation

Three numbers have pairwise sums 55, 44 and 33. What are the numbers? If the numbers are xx, yy and zz, the information is

x+y=5,y+z=4,x+z=3x+y=5,\qquad y+z=4,\qquad x+z=3

You could eliminate variables. There is also one reusable operation that solves all three equations together: multiply their matrix equation by an inverse.

You already know

From A-level Mathematics, a simultaneous solution must satisfy every original equation. From the previous lesson, A−1A=I\mathbf{A}^{-1}\mathbf{A}=\mathbf{I} when det⁡A≠0\det\mathbf{A}\ne0. Row-by-column multiplication turns a coefficient matrix times a column of unknowns into a column of linear expressions.

Put the coefficients in rows, always using the same variable order. Put the constants in a separate column in the same equation order:

(110011101)⏟A(xyz)⏟x=(543)⏟b\underbrace{\begin{pmatrix}1&1&0\\0&1&1\\1&0&1\end{pmatrix}}_{\mathbf{A}} \underbrace{\begin{pmatrix}x\\y\\z\end{pmatrix}}_{\mathbf{x}} =\underbrace{\begin{pmatrix}5\\4\\3\end{pmatrix}}_{\mathbf{b}}

For example, the second row produces 0x+y+z=40x+y+z=4. A missing variable needs a zero entry; otherwise the remaining coefficients would slide into the wrong columns.

Coefficient matrix

For a system of three linear equations in xx, yy and zz, the coefficient matrix A\mathbf{A} has one row per equation and one column per variable. The system is Ax=b\mathbf{A}\mathbf{x}=\mathbf{b}, with x=(xyz)T\mathbf{x}=\begin{pmatrix}x&y&z\end{pmatrix}^{\mathrm{T}}. The constants belong in b\mathbf{b}, not in A\mathbf{A}.

If an equation is written as z−2x=7z-2x=7, its row in this variable order is (−2,0,1)(-2,0,1). The order on the page is allowed to change; the order of the matrix columns is fixed. If you reorder equations, reorder the constants as well. The resulting system has the same solutions.

Key idea

Fix the variable order once, then read one complete equation into each row. Zeros keep missing variables in their places.

The following check focuses on that translation, before any inverse calculation gets involved.

Solving by an inverse matrix

The unknown column is on the right of the coefficient matrix, so multiply both sides on the left by the inverse. This puts the cancelling matrices beside one another.

Inverse method for simultaneous equations

For a non-singular coefficient matrix A\mathbf{A},

Ax=bA−1Ax=A−1bx=A−1b\begin{aligned} \mathbf{A}\mathbf{x}&=\mathbf{b}\\ \mathbf{A}^{-1}\mathbf{A}\mathbf{x}&=\mathbf{A}^{-1}\mathbf{b}\\ \mathbf{x}&=\mathbf{A}^{-1}\mathbf{b} \end{aligned}

The condition is det⁡A≠0\det\mathbf{A}\ne0. There is then exactly one solution.

Not in the formula booklet: learn it.

You already know how to calculate a three by three inverse. Here the new task is using it correctly: multiply each row by the entire constants column, keep any outside factor, then state the values of the unknowns.

Worked example 1: the pairwise sums

Question. Solve x+y=5x+y=5, y+z=4y+z=4, x+z=3x+z=3 using an inverse matrix.

Plan. Form the coefficient matrix, calculate its inverse, and multiply by the constants column.

A=(110011101),det⁡A=2\mathbf{A}=\begin{pmatrix}1&1&0\\0&1&1\\1&0&1\end{pmatrix},\qquad \det\mathbf{A}=2

Its cofactor matrix is (11−1−1111−11)\begin{pmatrix}1&1&-1\\-1&1&1\\1&-1&1\end{pmatrix}, so

x=12(1−1111−1−111)(543)inverse times constants=12(5−4+35+4−3−5+4+3)one row per unknown=(231)apply the factor\begin{aligned} \mathbf{x}&=\frac12\begin{pmatrix}1&-1&1\\1&1&-1\\-1&1&1\end{pmatrix}\begin{pmatrix}5\\4\\3\end{pmatrix} && \text{inverse times constants}\\ &=\frac12\begin{pmatrix}5-4+3\\5+4-3\\-5+4+3\end{pmatrix} && \text{one row per unknown}\\ &=\begin{pmatrix}2\\3\\1\end{pmatrix} && \text{apply the factor} \end{aligned}

Why this step? The 12\frac12 multiplies every component. The integer column (4,6,2)T(4,6,2)^{\mathrm{T}} is not yet the solution.

Answer. x=2x=2, y=3y=3, z=1z=1.

Check. 2+3=52+3=5, 3+1=43+1=4, and 2+1=32+1=3, so all three original equations hold.

Worked example 2 changes only the constants column. The coefficient matrix is unchanged, so you can reuse its inverse. This is one of the main attractions of the method.

Worked example 2: a new constants column

Question. Use the same inverse matrix to solve x+y=2x+y=2, y+z=7y+z=7, x+z=1x+z=1.

Plan. Keep A−1\mathbf{A}^{-1}, replace the constants column, and perform the multiplication.

(xyz)=12(1−1111−1−111)(271)same inverse=12(2−7+12+7−1−2+7+1)row by column=(−243)divide every entry by 2\begin{aligned} \begin{pmatrix}x\\y\\z\end{pmatrix} &=\frac12\begin{pmatrix}1&-1&1\\1&1&-1\\-1&1&1\end{pmatrix}\begin{pmatrix}2\\7\\1\end{pmatrix} && \text{same inverse}\\ &=\frac12\begin{pmatrix}2-7+1\\2+7-1\\-2+7+1\end{pmatrix} && \text{row by column}\\ &=\begin{pmatrix}-2\\4\\3\end{pmatrix} && \text{divide every entry by }2 \end{aligned}

Why reuse the inverse? It depends only on the coefficients, not on the right-hand sides.

Answer. x=−2x=-2, y=4y=4, z=3z=3.

Check. −2+4=2-2+4=2, 4+3=74+3=7, and −2+3=1-2+3=1.

A calculator's matrix operations can perform this multiplication, but still write x=A−1b\mathbf{x}=\mathbf{A}^{-1}\mathbf{b} and identify the final variables. If coordinates of an intersection point are requested, give a coordinate triple, with the outside factor already applied.

Watch out

Wrong: x=bA−1\mathbf{x}=\mathbf{b}\mathbf{A}^{-1}. A three by one column cannot multiply a three by three matrix in that order. Right: x=A−1b\mathbf{x}=\mathbf{A}^{-1}\mathbf{b}, a three by three matrix times a three by one column.

The next constants column produces fractions. Keep them exact rather than rounding midway.

Systems with a parameter

A parameter makes the arithmetic longer, but the structure stays the same. State the values for which the inverse exists before dividing by an expression containing that parameter.

Consider

M=(11001110k)\mathbf{M}=\begin{pmatrix}1&1&0\\0&1&1\\1&0&k\end{pmatrix}

Its determinant is k+1k+1. Cofactors give

M−1=1k+1(k−k11k−1−111),k≠−1\mathbf{M}^{-1}=\frac1{k+1} \begin{pmatrix}k&-k&1\\1&k&-1\\-1&1&1\end{pmatrix},\qquad k\ne-1

This particular inverse is derived by the previous lesson's method; it is not in the formula booklet. Keep its denominator outside the multiplication until you have simplified the numerator entries.

Worked example 3: parameter in a coefficient

Question. Given k≠−1k\ne-1, solve x+y=5x+y=5, y+z=4y+z=4, x+kz=3x+kz=3, using M−1\mathbf{M}^{-1}.

Plan. Multiply by the constants column, simplify the three numerators, then give the three values.

(xyz)=1k+1(k−k11k−1−111)(543)=1k+1(5k−4k+35+4k−3−5+4+3)form each numerator=(k+3k+14k+2k+12k+1)simplify\begin{aligned} \begin{pmatrix}x\\y\\z\end{pmatrix} &=\frac1{k+1}\begin{pmatrix}k&-k&1\\1&k&-1\\-1&1&1\end{pmatrix}\begin{pmatrix}5\\4\\3\end{pmatrix}\\ &=\frac1{k+1}\begin{pmatrix}5k-4k+3\\5+4k-3\\-5+4+3\end{pmatrix} && \text{form each numerator}\\ &=\begin{pmatrix}\frac{k+3}{k+1}\\\frac{4k+2}{k+1}\\\frac2{k+1}\end{pmatrix} && \text{simplify} \end{aligned}

Why state k≠−1k\ne-1? At k=−1k=-1, the inverse does not exist. A fraction with denominator zero is not a solution.

Answer. x=k+3k+1x=\frac{k+3}{k+1}, y=4k+2k+1y=\frac{4k+2}{k+1}, z=2k+1z=\frac2{k+1}, for k≠−1k\ne-1.

Check. x+y=5k+5k+1=5x+y=\frac{5k+5}{k+1}=5, y+z=4k+4k+1=4y+z=\frac{4k+4}{k+1}=4, and x+kz=3k+3k+1=3x+kz=\frac{3k+3}{k+1}=3.

Worked example 4 changes only the right-hand side of the last equation. It now depends on the same parameter, which allows cancellation.

Worked example 4: a solution that stays fixed

Question. For k≠−1k\ne-1, solve x+y=5x+y=5, y+z=4y+z=4, x+kz=k+2x+kz=k+2 using the inverse matrix.

Plan. Replace the last entry of the constants column by k+2k+2, then simplify before dividing.

(xyz)=1k+1(k−k11k−1−111)(54k+2)=1k+1(2k+23k+3k+1)collect like terms=(231)k+1≠0\begin{aligned} \begin{pmatrix}x\\y\\z\end{pmatrix} &=\frac1{k+1}\begin{pmatrix}k&-k&1\\1&k&-1\\-1&1&1\end{pmatrix}\begin{pmatrix}5\\4\\k+2\end{pmatrix}\\ &=\frac1{k+1}\begin{pmatrix}2k+2\\3k+3\\k+1\end{pmatrix} && \text{collect like terms}\\ &=\begin{pmatrix}2\\3\\1\end{pmatrix} && k+1\ne0 \end{aligned}

Why this step? Each numerator has a factor k+1k+1, so the apparent parameter dependence cancels for the permitted values.

Answer. x=2x=2, y=3y=3, z=1z=1 for every real k≠−1k\ne-1.

Check. 2+3=52+3=5, 3+1=43+1=4, and 2+k(1)=k+22+k(1)=k+2, for any such kk.

Cancellation must preserve the domain on which the inverse was calculated.

Watch out

Wrong: cancelling k+1k+1 means the inverse method is valid at k=−1k=-1 too. Cancellation requires k+1≠0k+1\ne0. The correct inverse-based conclusion remains x=2, y=3, z=1x=2,\ y=3,\ z=1 for k≠−1k\ne-1; any singular case must be checked in the original equations separately.

This is a useful surprise: infinitely many different coefficient matrices can give exactly the same solution. Changing an equation need not change the answer if the replacement equation is still satisfied by the same triple and the coefficient matrix stays non-singular.

If the determinant is zero, do not conclude “no solution” from the failed inverse operation. There may be no solution or infinitely many; the next lesson distinguishes those possibilities geometrically.

Exam tip

When asked for an answer in simplest form, distribute any outside factor and simplify each component. For a point, finish with (x,y,z)(x,y,z), rather than leaving a scalar times an unevaluated column.

The pairwise-sum puzzle has answer (2,3,1)(2,3,1). The parameter examples show both what the inverse changes and what it can leave unexpectedly fixed.

Quick Recap

  • Write the equations as Ax=b\mathbf{A}\mathbf{x}=\mathbf{b}, keeping variable and equation orders consistent.
  • If det⁡A≠0\det\mathbf{A}\ne0, the unique solution is x=A−1b\mathbf{x}=\mathbf{A}^{-1}\mathbf{b}.
  • Apply every outside factor, simplify the three components, and substitute into all the original equations.
  • For a parameter, exclude values that make the determinant zero before using the inverse.

The opening three numbers are 22, 33 and 11: the inverse recovers them in one matrix multiplication.