Skip to main content
Logo image

Section 3.6 Solving Systems of Equations Using Matrices

In this section, we will see how to use matrices to solve systems of equations. In both the graphical method and the expected value method, you have had to solve a system of equations. In the graphical method you had systems consisting of two lines such as Example 3.6.1.

Example 3.6.1. Two Equations.

An example of a system of two lines:
\begin{align*} y \amp = \frac{3}{5}x-\frac{1}{5}\\ y \amp =-x+3. \end{align*}
In the expected value method we had systems of three equations such as Example 3.6.2.

Example 3.6.2. Three Equations.

An example of a system of three equations where the variables are \(E_1(A), E_1(B), P_2(C), P_2(D)\text{:}\)
\begin{align*} E_1(A) \amp = P_2(C)-P_2(D)\\ E_1(B) \amp = 2P_2(D)\\ 1 \amp = P_2(C)+P_2(D). \end{align*}
In Example 3.6.2, even after setting \(E_1(A)=E_1(B)\) so that there were only 2 variables, the algebra began to get cumbersome. What if we wanted to solve a much larger game, such as a 5 X 5 game?
We’ve used matrices to represent our games, but now we want to use them as a mathematical tool to help us solve systems of equations. In order to use matrices to solve our systems of equations, we want to write all our equations in the same form: we will have all the variable terms on the left of the equals sign and all constants on the right.

Example 3.6.3. Turning a System of Equations into a Matrix.

The equations in Example 3.6.1 we can be rewritten as
\begin{align*} \frac{3}{5}x-y \amp =\frac{1}{5}\\ x+y \amp = 3. \end{align*}
In fact, we can simplify the first equation by multiplying both sides by 5:
\begin{align*} 3x-5y \amp =1\\ x+y \amp = 3. \end{align*}
We can use the coefficients and constants to create a matrix:
\begin{equation*} \left[ \begin{matrix}3 \amp -5 \amp 1\\ 1 \amp 1 \amp 3 \end{matrix} \right]. \end{equation*}
In this matrix you have a column for the coefficients of each variable. So the coefficients of \(x\) are in the first column, the coefficients of \(y\) are in the second. The constant terms are always in the last column. Each row corresponds to one equation.
The matrix in Example 3.6.3 is called an augmented matrix. It is really just a matrix, but we call it augmented if we include information from both sides of the equation (the coefficients and the constants).
The algebraic method for solving the system of equations (finding the \(x\) and \(y\) values that satisfy both equations) is called row reduction. It is based on the elimination method that you may have seen in a precalculus or college algebra course. We won’t go through the algebra here, as we really don’t need it. Since our goal is to be able to easily solve larger systems of equations, we will rely on technology to do the algebra.
Computer algebra systems such as Sage, Mathematica, and Maple, as well as graphing calculators, can easily do the row reduction for us. In this section we will use the Desmos matrix calculator first, then show how to use Sage. Note that any graphing claculator will work similarly to Desmos.

Example 3.6.4. Using the Desmos Matrix Calculator.

On Desmos, use the Matrix Calculator under Math Tools: Desmos Matrix Calculator
 1 
www.desmos.com/matrix
. Use the New Matrix button to enter the matrix. If we want to enter the matrix
\begin{equation*} \left[ \begin{matrix}3 \amp -5 \amp 1\\ 1 \amp 1 \amp 3 \end{matrix} \right] \end{equation*}
we will need a matrix with 2 rows and 3 columns. Enter the values in the matrix. You can either Tab to each entry or use the arrow buttons. Once you have entered the values in the matrix, use the blue Enter button (the blue arrow in the bottom right corner. Then use the “rref” button (this stands for “reduced row echelon form”) and the matrix name, probably A . The result will be the following matrix:
\begin{equation*} \left[ \begin{matrix}1 \amp 0 \amp 2\\ 0 \amp 1 \amp 1 \end{matrix} \right]. \end{equation*}
This is the matrix we will use to determine the solution for the system of equations. We’ll get to how we do that shortly.

Example 3.6.5. Using Sage.

We can also find the reduced row echolon form of a matrix using Sage, as in the following Sage Cell.
Recall that when we set up the original matrix, the first column is for \(x\) and the second is for \(y\text{.}\) Each row represents an equation. We can take the matrix
\begin{equation*} \left[ \begin{matrix}1 \amp 0 \amp 2\\ 0 \amp 1 \amp 1 \end{matrix} \right]. \end{equation*}
and translate each row back to equations. This gives us the following system of equations:
\begin{align*} x+0y \amp =2\\ 0x+y \amp = 1 \end{align*}
which simplifies to
\begin{align*} x \amp =2\\ y \amp = 1. \end{align*}
By plugging these values back into the original equations, you can verify that this is in fact the solution to the system of equations in Example 3.6.3.
Since the technology does all the algebra for us, our job is to translate the equations into an appropriate matrix and then translate the final matrix back into the solution to the system of equations. Remember, when using a matrix to solve a game, the matrix is only a tool, it is not the solution to the game.
Now, let’s try the equations for the expected value method in Example 3.6.2. As presented, how many variables does the system have?
\begin{align*} E_1(A) \amp = P_2(C)-P_2(D)\\ E_1(B) \amp = 2P_2(D)\\ 1 \amp = P_2(C)+P_2(D) \end{align*}
It has 4: \(E_1(A), E_1(B), P_2(C)\) and \(P_2(D)\text{.}\) But when we solved these equations, we set the expected values equal to each other. This gives us the two equations
\begin{align*} P_2(C)-P_2(D) \amp = 2P_2(D)\\ 1 \amp = P_2(C)+P_2(D). \end{align*}
Now if we put these into the equation form with all variables on the left and constants on the right, we get
\begin{align*} P_2(C)-3P_2(D) \amp = 0\\ P_2(C)+P_2(D) \amp = 1. \end{align*}
Putting these equations into an augmented matrix, gives us
\begin{equation*} \left[ \begin{matrix}1 \amp -3 \amp 0\\ 1 \amp 1 \amp 1 \end{matrix} \right], \end{equation*}
where the first column corresponds to \(P_2(C)\) and the second column corresponds to \(P_2(D)\text{.}\) We can do the row reduction using either Desmos or the Sage cell below.
Using row reduction, we get
\begin{equation*} \left[ \begin{matrix}1 \amp 0 \amp 3/4\\ 0 \amp 1 \amp 1/4 \end{matrix} \right]. \end{equation*}
Thus, recalling Column 1 is for \(P_2(C)\) and Column 2 is for \(P_2(D)\text{,}\) our solution is \(P_2(C)=3/4\text{,}\) and \(P_2(D)=1/4\text{.}\)
Here are some more systems of equations to practice solving using augmented matrices. If you want to use the above Sage cells just edit the values for each row in the cell.

Activity 3.6.1. Solve a system of 2 equations.

Solve the system of equations.
\begin{equation*} \begin{matrix}2x-2y\amp =6\\x+3y\amp =7 \end{matrix} \end{equation*}

Activity 3.6.2. Solve another system of 2 equations.

Solve the system of equations.
\begin{equation*} \begin{matrix}4p_1-2p_2\amp =0\\p_1+p_2\amp =1 \end{matrix} \end{equation*}
For larger matrices, you can edit the Sage cell by adding additional terms in each row, and adding more rows. For example, you can replace \([3,-5,1],[1,1,3]\) with \([4,8,-4,4],[3,8,5,-11],[-2,1,12,-17]\text{.}\)

Activity 3.6.3. Solve a system of 3 equations.

Consider the system of equations
\begin{equation*} \begin{matrix}4x+8y-4z\amp =4\\3x+8y+5z\amp =-11\\-2x+y+12z\amp =-17. \end{matrix} \end{equation*}

(a)

Set up the augmented matrix for this system.

(b)

Use row reduction to find the solution.

Activity 3.6.4. Solve another system of 3 equations.

Consider the system of equations
\begin{equation*} \begin{matrix}2x+y-4z\amp =10\\3x+5z\amp =-5\\y+2z\amp =7. \end{matrix} \end{equation*}

(a)

Set up the augmented matrix for this system.

(b)

Use row reduction to find the solution.

Activity 3.6.5. Even more practice with 3 equations.

Consider the system of equations
\begin{equation*} \begin{matrix}a+b-5c\amp =0\\-4a-b+6c\amp =0\\a+b+c\amp =1. \end{matrix} \end{equation*}

(a)

Set up the augmented matrix for this system.

(b)

Use row reduction to find the solution.

Activity 3.6.6. Now, a sytem with 5 equations.

Consider the system of equations
\begin{equation*} \begin{matrix}3x+2y-w-v\amp =0\\2x-y+3z+w+5v\amp =0\\x+2y+6z-w\amp =0\\ -y+z-3w+v\amp =0\\x+y+z+w+v\amp =1. \end{matrix} \end{equation*}

(a)

Set up the augmented matrix for this system.

(b)

Use row reduction to find the solution.
Now we are ready to apply everything we have learned about solving repeated zero-sum games to a much more challenging game in the next section.

Reading Questions Check Your Understanding

1.

    Suppose we have the system of equations
    \begin{equation*} \begin{matrix}3x -4 \amp =y\\z+2x\amp =5\\x-2y\amp =3z. \end{matrix} \end{equation*}
    Which is the corresponding augmented matrix for this system?
  • \(\left[ \begin{matrix}3 \amp -4 \amp 1\\ 1 \amp 2 \amp 5\\ 1 \amp -2 \amp 3\\ \end{matrix} \right]\)
  • How many variables are in the system? How many columns do you need?
  • \(\left[ \begin{matrix}3 \amp -1 \amp 4\\ 2 \amp 1 \amp 5\\ 1 \amp -2 \amp 3\\ \end{matrix} \right]\)
  • How many variables are in the system? How many columns do you need?
  • \(\left[ \begin{matrix}3 \amp -1\amp 0 \amp 4\\ 2 \amp 0 \amp 1 \amp 5\\ 1 \amp -2 \amp -3 \amp 0\\ \end{matrix} \right]\)
  • Correct.
  • \(\left[ \begin{matrix}3 \amp 1\amp 0 \amp -4\\ 2 \amp 0 \amp 1 \amp 5\\ 1 \amp -2 \amp 3 \amp 0\\ \end{matrix} \right]\)
  • Make sure the variables are on one side of each equation and the constants are on the other.

2.

Suppose after doing row reduction on a system of equations with variables \(x, y, z\text{,}\) we have the following matrix
\begin{equation*} \left[ \begin{matrix}1 \amp 0\amp 0 \amp 3\\ 0 \amp 1 \amp 0 \amp 2\\ 0 \amp 0 \amp 1 \amp -1\\ \end{matrix} \right]. \end{equation*}
Then the solution to the system of equations is
\(x= \)
\(y= \)
\(z= \)

3.

Use row reduction to solve the following system of equations.
\begin{equation*} \begin{matrix}2x-3y+z\amp =7\\-x+2y-2z\amp =-7\\x+y+z\amp =2. \end{matrix} \end{equation*}
Then the solution to the system of equations is
\(x= \)
\(y= \)
\(z= \)

4.

    Suppose we finding the mixed strategy equilibrium for a \(2\times 2\) game using row reduction. After row reducing we have the following matrix where the first column represents \(P(A)\) and the second represents \(P(B)\text{.}\)
    \begin{equation*} \left[ \begin{matrix}1 \amp 0\amp -1\\ 0 \amp 1 \amp 2\\ \end{matrix} \right]. \end{equation*}
    What can we conclude?
  • \(P(A)=-1, P(B)=2\)
  • Remember, \(P(A), P(B)\) represent probabilities in this context.
  • \(P(A)=1, P(B)=2\)
  • Remember, \(P(A), P(B)\) represent probabilities in this context.
  • \(P(A)=-1/3, P(B)=2/3\)
  • We can’t get this solution from the above matrix.
  • \(P(A)=-1/3, P(B)=2/3\)
  • We can’t get this solution from the above matrix.
  • We must have made a mistake since \(P(A)+P(B)=1\) in this context.
  • Although \(2-1=1\text{,}\) there is another condition for probabilities.
  • We must have made a mistake since \(P(A)\) and \(P(B)\) must be between 0 and 1 in this context.
  • Correct.

5.

    Suppose we finding the mixed strategy equilibrium for a \(2\times 2\) game using row reduction. After row reducing we have the following matrix where the first column represents \(P(A)\) and the second represents \(P(B)\text{.}\)
    \begin{equation*} \left[ \begin{matrix}1 \amp 0\amp 1/3\\ 0 \amp 1 \amp 1/3\\ \end{matrix} \right]. \end{equation*}
    What can we conclude?
  • \(P(A)=1/3, P(B)=1/3\)
  • Remember, \(P(A), P(B)\) must sum to 1.
  • \(P(A)=1/3, P(B)=2/3\)
  • We can’t get this solution from the above matrix.
  • We must have made a mistake since \(P(A)+P(B)=1\) in this context.
  • Correct.
  • We must have made a mistake since \(P(A)\) and \(P(B)\) must be between 0 and 1 in this context.
  • \(1/3\) is between 0 and 1, but there is another condition.

6.

    Suppose we finding the mixed strategy equilibrium for a \(2\times 2\) game using row reduction. After row reducing we have the following matrix where the first column represents \(P(A)\) and the second represents \(P(B)\text{.}\)
    \begin{equation*} \left[ \begin{matrix}1 \amp 0\amp 1/3\\ 0 \amp 1 \amp 2/3\\ \end{matrix} \right]. \end{equation*}
    What can we conclude?
  • \(P(A)=2/3, P(B)=1/3\)
  • Be careful of the order of \(P(A), P(B)\text{.}\)
  • \(P(A)=1/3, P(B)=2/3\)
  • Correct.
  • We must have made a mistake since \(P(A)+P(B)=1\) in this context.
  • \((1/3)+(2/3)=1\)
  • We must have made a mistake since \(P(A)\) and \(P(B)\) must be between 0 and 1 in this context.
  • \(1/3, 2/3\) are between 0 and 1.