Section3.2Using Matrices To Solve Systems of Linear Equations
In Section 3.1 we solved a linear system using familiar techniques. Later, we commented that in the linear equations we formed, the most important information was the coefficients and the constants; the names of the variables really didn’t matter. In Example 3.1.1 we had the following three equations:
Let’s rewrite these equations so that all variables are on the left of the equal sign and all constants are on the right. Also, for a bit more consistency, let’s list the variables in alphabetical order in each equation. Therefore we can write the equations as
As we mentioned before, there isn’t just one “right” way of finding the solution to this system of equations. Here is another way to do it, a way that is a bit different from our method in Section 3.1.
First, let’s add the first and last equations together, and write the result as a new third equation. This gives us:
Let’s now do two steps in a row; our goal is to get rid of the \(g\)’s in the first and third equations. In order to remove the \(g\) in the first equation, let’s multiply the second equation by \(-1\) and add that to the first equation, replacing the first equation with that sum. To remove the \(g\) in the third equation, let’s multiply the second equation by \(-2\) and add that to the third equation, replacing the third equation. Our new system of equations now becomes
Now let’s get rid of the \(r\)’s in the first and second equation. To remove the \(r\) in the first equation, let’s multiply the third equation by \(-\frac32\) and add the result to the first equation, replacing the first equation with that sum. To remove the \(r\) in the second equation, we can multiply the third equation by \(\frac12\) and add that to the second equation, replacing the second equation with that sum. This gives us:
Clearly we have discovered the same result as when we solved this problem in Section 3.1.
Now again revisit the idea that all that really matters are the coefficients and the constants. There is nothing special about the letters \(b\text{,}\)\(g\) and \(r\text{;}\) we could have used \(x\text{,}\)\(y\) and \(z\) or \(x_1\text{,}\)\(x_2\) and \(x_3\text{.}\) And even then, since we wrote our equations so carefully, we really didn’t need to write the variable names at all as long as we put things “in the right place.”
Let’s look again at our system of equations in Equation (3.2.1) and write the coefficients and the constants in a rectangular array. This time we won’t ignore the zeros, but rather write them out.
Notice how even the equal signs are gone; we don’t need them, for we know that the last column contains the coefficients.
The mathematical object we have created on the right is called a matrix. We will give a formal mathematical definition in Chapter 4, where we will see that matrices are interesting objects in their own right, with numerous interesting properties and applications. For now we can think of a matrix simply as a rectangular table of numbers that allows us to keep track of certain information; namely, the constants that define our system of linear equations. Note that each row in our matrix represents one of the equations, while each column (except for the last) represents a variable. We will often want to distinguish between the coefficient matrix of a system; that is, the matrix containing the coefficients (the numbers in front of the variables) of a system of linear equations, and the matrix that also includes the column of constants, as above. When we include the constants, we refer to the resulting matrix as an augmented matrix.
It is common (but not mandatory) to place a vertical line separating the final column of an augmented matrix (containing the constants) from the other columns (containing the coefficients). One advantage of doing so is that we can quickly recognize that we’re dealing with an augmented matrix rather than a coefficient matrix. For example, the augmented matrix for the system Equation (3.2.1) would be written as seen below on the right:
Figure3.2.1.Two ways of writing an augmented matrix
We can use augmented matrices to find solutions to linear equations by using essentially the same steps we used above. Every time we used the word “equation” above, substitute the word “row,” as we show below. The comments explain how we get from the current set of equations (or matrix) to the one on the next line.
Let us look back at the steps we used to solve the system of equations at the beginning of this section. Clearly, the order in which we right down our equations does not affect the solution; in terms of our matrix, this means we can rearrange the rows as we please. Note, however, that we cannot rearrange the columns. To do so would mix up our variables, causing us to lose track of our system.
In addition to changing the order of our equations, we also saw that we can multiply both sides of any equation by a constant, and we can add a multiple of one equation to another. These three manipulations are known as the elementary operations used to solve a system of linear equations. We will see that with these three elementary operations, we can determine the solution (if any) to any linear system.
Each of these elementary operations corresponds to an operation performed on the corresponding augmented matrix known as an elementary row operation. We use a shorthand notation to describe these matrix operations; let \(R_1\text{,}\)\(R_2\) represent “row 1” and “row 2,” respectively. We can write “add row 1 to row 3, and replace row 3 with that sum” as “\(R_1+R_3\to R_3\text{.}\)” The expression “\(R_1 \leftrightarrow R_2\)” means “interchange row 1 and row 2.”
The final matrix contains the same solution information as we have on the left in the form of equations. Recall that the first column of our matrices held the coefficients of the \(b\) variable; the second and third columns held the coefficients of the \(g\) and \(r\) variables, respectively. Therefore, the first row of the matrix can be interpreted as “\(b+0g+0r=15\text{,}\)” or more concisely, “\(b=15\text{.}\)”
Let’s practice this manipulation again.
Example3.2.2.Solving a system using augmented matrices.
Find a solution to the following system of linear equations by simultaneously manipulating the equations and the corresponding augmented matrices.
We’ll first convert this system of equations into a matrix, then we’ll proceed by manipulating the system of equations (and hence the matrix) to find a solution. Again, there is not just one “right” way of proceeding; we’ll choose a method that is pretty efficient, but other methods certainly exist (and may be “better”!). The method use here, though, is a good one, and it is the method that we will be learning in the future.
The given system and its corresponding augmented matrix are seen below.
We’ll proceed by trying to get the \(x_1\) out of the second and third equation.
\begin{align*}
\scriptstyle{\begin{matrix}\text{Replace equation 2 with the}\\ \text{sum of} -2 \text{ times equation 1}\\ \text{plus equation 2;}\\
\text{Replace equation 3 with}\\ \text{the sum of equation 1}\\ \text{ and equation 3}\end{matrix}}
\amp \quad \amp \quad \amp \scriptstyle{\begin{matrix}\text{Replace row 2 with the sum of}\\ -2 \text{ times row 1 plus row 2}\\(-2R_1+R_2\rightarrow R_2)\\
\text{Replace row 3 with the sum of}\\ \text{row 1 and row 3}\\(R_1+R_3\rightarrow R_3)\end{matrix}}\\
\displaystyle\begin{array}{ccccccc}
x_1\amp +\amp x_2\amp +\amp x_3\amp =\amp 0\\
\amp \amp \amp \amp -x_3\amp =\amp 0\\
\amp \amp 2x_2\amp -\amp x_3\amp =\amp 2
\end{array} \amp \quad \amp \quad \amp \left[\begin{array}{ccc|c}
1\amp 1\amp 1\amp 0\\ 0\amp 0\amp -1\amp 0\\ 0\amp 2\amp -1\amp 2\\
\end{array}\right]
\end{align*}
Notice that the second equation no longer contains \(x_2\text{.}\) We’ll exchange the order of the equations so that we can follow the convention of solving for the second variable in the second equation.
Notice that the last equation (and also the last row of the matrix) show that \(x_3=0\text{.}\) Knowing this would allow us to simply eliminate the \(x_3\) from the first two equations. However, we will formally do this by manipulating the equations (and rows) as we have previously.
\begin{align*}
\scriptstyle{\begin{matrix}\text{Replace equation 1 with the}\\ \text{sum of } -1 \text{ times equation 3}\\ \text{plus equation 1;}\\
\text{Replace equation 2 with the}\\ \text{sum of } \frac12 \text{ times equation 3} \\ \text{plus equation 2}\end{matrix}}
\amp \quad \amp \quad \amp \scriptstyle\scriptstyle{\begin{matrix}\text{Replace row 1 with the sum of}\\ -1 \text{ times row 3 plus row 1}\\(-R_3+R_1\rightarrow R_1)\\
\text{Replace row 2 with the sum of}\\ \frac12 \text{ times row 3 plus row 2}\\(\frac12R_3+R_2\rightarrow R_2)\end{matrix}}\\
\amp \\
\displaystyle\begin{array}{ccccccc}
x_1\amp +\amp x_2\amp \amp \amp =\amp 0\\
\amp \amp x_2\amp \amp \amp =\amp 1\\
\amp \amp \amp \amp x_3\amp =\amp 0
\end{array} \amp \quad \amp \quad \amp \left[\begin{array}{ccc|c}
1\amp 1\amp 0\amp 0\\ 0\amp 1\amp 0\amp 1\\ 0\amp 0\amp 1\amp 0\\
\end{array}\right]
\end{align*}
Notice how the second equation shows that \(x_2 = 1\text{.}\) All that remains to do is to solve for \(x_1\text{.}\)
Obviously the equations on the left tell us that \(x_1 = -1\text{,}\)\(x_2 = 1\) and \(x_3=0\text{,}\) and notice how the matrix on the right tells us the same information.
ExercisesExercises
Exercise Group.
Convert the system of equations into an augmented matrix.