Matrices can be used to solve systems of equations using elementary row operations and the augmented matrix. This method of solving systems of equations is handy when you have many variables and equations. You may see it being used in fields like economics, statistics and machine learning.
Systems of equations
In algebra, a system of equations is a set of linear equations where the solutions (or values for the variables) satisfy all equations simultaneously. Depending on the type of equations, there may be one solution, no solution, or infinitely many solutions.
To solve systems of equations using matrices, we must first rewrite them as an augmented matrix.
Augmented matrices
An augmented matrix contains a coefficient matrix and a constant matrix next to it, separated by a vertical line.
The best way to understand this is with an example. Let's consider the following system of equations:
The first row is made up of the three coefficients in front of \(x\), \(y\) and \(z\) (\(1,2,-1\)) and the right-hand side \(\left(-3\right)\) from the first equation.
The second row is made up of the three coefficients in front of \(x\), \(y\) and \(z\) (\(2,-3,2\)) and the right-hand side \(\left(13\right)\) from the second equation.
The third row is made up of the three coefficients in front of \(x\), \(y\) and \(z\) (\(-1,4,-4\)) and the right-hand side \(\left(-19\right)\) from the third equation.
Just as when you work with algebraic equations, when working with augmented matrices, everything we do to the left-hand side, you do to the right-hand side.
For augmented matrices, we manipulate the elements using elementary row operations.
Coefficient matrix
The coefficient matrix tells us some helpful information about the number of solutions to a system of equations. Consider the previous example:
non-singular, i.e. the determinant \(\neq0\), there will be a unique solution.
singular, i.e. the determinant is \(0\), there will be an infinite number of solutions or no solutions.
Elementary row operations
Elementary row operations are operations that can be used to simplify an augmented matrix when solving systems of equations. There are three operations that we are allowed to perform on augmented matrices:
interchange any two rows
multiply a row by any constant
add or subtract a multiple of one row to/from another row.
Solving equations with unique solutions
To solve equations with unique solutions using augmented matrices and elementary row operations, we follow a method called row reduction:
Create the augmented matrix.
Use row operations to reduce the augmented matrix to the following form (called the reduced augmented matrix), where the elements under the leading diagonal are \(0\): \[\begin{align*} \left[ \begin{array}{ccc} a & b & c\\
0 & e & f\\
0 & 0 & h
\end{array}
\left|
\begin{array}{c} d\\
g\\
k
\end{array} \right. \right]
\end{align*}\]
From row \(3\), \(hz=k\) and so \(z=\dfrac{k}{h}\).
From row \(2\), we have \(ey+fz=g\). Since \(z\) is known (from Step 3), we can rearrange the equation to find \(y\).
From row \(1\), we have \(ax+by+cz=d\). Since \(x\) and \(y\) are known from Steps 3 and 4, we can find \(x\).
Steps 3 to 5 are called back substitution.
To understand how to use elementary row operations, it is best to look at some examples.
Example 1 – solving equations with unique solutions
Solve the following system of equations for \(x\), \(y\) and \(z\):
\[\begin{align*} x+2y-z & = -3 & (1)\\
2x-3y+2z & = 13 & (2)\\
-x+5y-4z & = -19 & (3)
\end{align*}\]
Then, use row operations to get the \(0\)'s under the leading diagonal. Remember that we can only do the following:
interchange any two rows
multiply a row by any constant
add or subtract a multiple of one row to/from another row.
We will work from left to right, and get the \(0\)'s in row \(2\) and row \(3\) of column \(1\) first.
To do this for row \(2\), we can multiply row \(1\) \(\left(R_{1}\right)\) by \(2\) and subtract it from row \(2\) \(\left(R_{2}\right)\) to get the new row \(2\) or \(R_{2}'\). This operation has been written to the left of the augmented matrix for your reference.
From row \(1\), we have \(x+2y-z=-3\) and we can substitute in \(z=3\) and \(y=-1\) to find \(x\): \[\begin{align*} x+2(-1)-(3) & = -3\\
x-2-3 & = -3\\
x-5 & = -3\\
x & = -3+5\\
& = 2
\end{align*}\]
The solution to the system of equations is therefore, \(x=2\), \(y=-1\) and \(z=3\).
You can check your solution by substituting the values for \(x\), \(y\) and \(z\) into the original equations and making sure it is equal to the right-hand side.
The first step is to try and get a \(1\) in the top left-hand corner of the matrix. In Example 2, we did this by interchanging rows. In this case, that won’t work. However, row \(1\) can be divided by \(2\) to get:
Solving equations with an infinite number of solutions
In all the examples above, we had a unique solution. That is, \(x\), \(y\) and \(z\) were associated with a single number. However, a set of simultaneous equations can have an infinite number of solutions.
Imagine after using row operations, you get an augmented matrix like:
\[\begin{align*} \left[ \begin{array}{ccc} a & b & c\\
0 & e & f\\
0 & 0 & 0
\end{array}
\left|
\begin{array}{c} d\\
g\\
0
\end{array} \right. \right]
\end{align*}\]
In this case, row \(3\) tells us nothing. We essentially have 2 equations and 3 unknowns. Therefore, there are infinitely many solutions, and the variables \(x\), \(y\) and \(z\) will be expressed in terms of a parameter.
What this means is we define one variable as a set of values. We usually say something like, let \(x=t\), where \(t\in\mathbb{R}\). In other words, the variable \(x\) can be any real number, \(\mathbb{R}\). This will give us an infinite number of solutions.
In general, if the reduced augmented matrix has one or more rows of \(0\)'s, there will be an infinite number of solutions to the system of equations.
Example 1 – solving equations with infinite solutions
Solve the following set of equations:
\[\begin{align*} x+y+z & = 3\\
2x-y+z & = 5\\
3x+2z & = 8
\end{align*}\]
This is an equation with two unknowns. In this case, we let one of the variables, either \(y\) or \(z\) be free—that is, we let \(y\) or \(z\) be equal to some parameter \(t\in\mathbb{R}\). It doesn’t matter which variable you choose to be free, though the answer will look different. We will set \(z=t\). Then, we have:
So, the solution here is \(x=\frac{8-2t}{3}\), \(y=\frac{1-t}{3}\) and \(z=t\) where \(t\in\mathbb{R}\). This gives us an infinite number of solutions because \(t\) can be any real number.
To check the solution, you can pick any value of \(t\), determine \(x\), \(y\) and \(z\) and substitute in the original equations. For example, let \(t=0\).
Row \(3\) tells us that \(0x+0y+0z=0\). This is true for any value of \(x\), \(y\) or \(z\). So, we are able to set any one of these variables to some number, \(t\in\mathbb{R}\).
We have only one equation and three unknowns. In this case, we must let two of the variables be free. For example, we can set \(z=t\) where \(t\in\mathbb{R}\) and \(y=s\) where \(s\in\mathbb{R}\).
\(x=\dfrac{1}{2}t\), \(y=-\dfrac{1}{4}t\), \(z=0\) and \(w=t\) where \(t\in\mathbb{R}\)
\(x=-\dfrac{7t}{5}-2\), \(y=\dfrac{t}{5}-1\) and \(z=t\) where \(t\in\mathbb{R}\)
\(x=3-t\), \(y=t\) and \(z=t\) where \(t\in\mathbb{R}\)
Solving equations with no solutions
In some cases, the coefficients in a row are all \(0\)'s, but the constant on the other side of the vertical line is a number. This is contradictory because \(0x+0y+0z\) cannot give us a non-zero number; it must equal \(0\).
Graphically, what this means is that the lines for the equations do not intercept or touch, and so there is no solution for \(x\), \(y\) and \(z\) that satisfies the system of equations. The system of equations is therefore considered inconsistent.
Example – solving equations with no solutions
Solve the following system of equations:
\[\begin{align*} x+2y-2z & = 3\\
2x+y+z & = 4\\
3y-5z & = -1
\end{align*}\]
In this case, row \(3\) says that \(0x+0y+0z=-3\), which is not possible. This means there are no solutions for the system of equations, i.e. it is inconsistent.
Your turn – solving equations with no solutions
Determine whether the following system of equations has a solution.
\[\begin{align*} x+2y-2z & = 7\\
2x-y-z & = -3\\
-x-2y+2z & = 1
\end{align*}\]