Math Home

Solving Systems of Equations Using Elimination

For a moment we will take a step back from vectors and matrices and review how a system of equations can be solved using elimination. For this example, we will use the following system of equations: \[x - y + z = 4\] \[2x + z = 5\] \[2y - 2z - x = -6\]

Step 1: We will start by using the first equation to eliminate \(x\) in all the other equations. Multiplying the first equation by \(-2\) gives \[-2x + 2y -2z = -8\] Step 2: Adding this to the second equation by adding the left sides together and the right sides together gives \[-2x +2y -2z + 2x + z = -8 + 5 \Rightarrow 2y - z = -3\] Step 3: Adding the first equation to the third equation gives \[x - y + z + 2y - 2z - x = 4 - 6 \Rightarrow y - z = -2\]

By using the first equation to eliminate \(x\) in the second two equations, we have reduced to \(2\) equations with \(2\) unknowns. Next we can eliminate \(y.\) Multiply \(y - z = -2\) by \(-2\) and add it to the other equation to cancel the \(y.\)

Step 4: Multiply the last equation by \(-2:\) \[y - z = -2 \Rightarrow -2y + 2z = 4\]

Step 5: Add the equations: \[2y - z - 2y + 2z = -3 + 4 \Rightarrow z = 1.\]

Step 6: Now we can plug back in \(z = 1\) to find \(y.\) Using \(y - z = -2,\) we have \(y - 1 = -2 \Rightarrow y = -1.\)

Step 7: Finally, use \(z = 1\) and \(y = -1\) to find \(x.\) We have \(x - y + z = 4 \Rightarrow x - (-1) + 1 = 4 \Rightarrow x = 2.\)

So, the solution to the system of equations is \(x = 2, y = -1, z = 1.\)

Doing it the Linear Algebra way!

We are going to solve the system of equations using the same steps as above but this time we will use shorthand from Linear Algebra. Here is the system of equations again: \[x - y + z = 4\] \[2x + z = 5\] \[2y - 2z - x = -6\]

Rewrite the system of equations. The order of the variables is up to us, so we will use \((x,y,z)\) in that order. Keep in mind the last equation has the variables out of order. We can rewrite it as \(-x + 2y - 2z = -6\) just to be sure the right numbers to in the right places. Also, the second equation has no \(y.\) To fill in the gap, we can rewrite it as \(2x + 0y + z = 5.\) Neither of these rewrites is necessary but may be helpful when you are starting out.

Here is the system of equations in matrix form: \[ \begin{bmatrix} 1 & -1 & 1 \\ 2 & 0 & 1 \\ -1 & 2 & -2 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 4 \\ 5 \\ -6 \end{bmatrix} \]

Linear algebra is all about organizing a bunch of data using shorthand. Now that we have the system of equations in the form \(A\overrightarrow{v} = \overrightarrow{b},\) we can do the rest of our work without copying down the \(\overrightarrow{v}\) vector and \(=\) sign over and over again. This shorthand is called an augmented matrix. The matrix A goes on the left, then a vertical bar, then the vector \(\overrightarrow{b}.\) The augmented matrix is \([A|\overrightarrow{b}]:\) \[ \left[ \begin{array}{ccc|c} 1 & -1 & 1 & 4 \\ 2 & 0 & 1 & 5 \\ -1 & 2 & -2 & -6 \\ \end{array} \right] \]

Now we will repeat the same steps to solve the equations.

Step 1: Multiply both sides of the first equation by \(-2\) so we can cancel the \(x\) in the second equation. Multiplying by \(-2\) gives: \[ \left[ \begin{array}{ccc|c} -2 & 2 & -2 & -8 \\ 2 & 0 & 1 & 5 \\ -1 & 2 & -2 & -6 \\ \end{array} \right] \] Multiplying both sides of an equation is the same as multiplying a row by a constant.

Step 2: Add the left hand sides and right hands sides of the first equation to the second equation. This is the same as adding the first row to the second row. \[ \left[ \begin{array}{ccc|c} -2 & 2 & -2 & -8 \\ 0 & 2 & -1 & -3 \\ -1 & 2 & -2 & -6 \\ \end{array} \right] \] Add two equations is the same as adding two rows vectors.

Step 3: Using the original first equation (or multiplying by \(-1/2\) to cancel the \(-2\),) we can cancel the \(x\) in the third equation by adding the first row to the third. \[ \left[ \begin{array}{ccc|c} 1 & -1 & 1 & 4 \\ 0 & 2 & -1 & -3 \\ 0 & 1 & -1 & -2 \\ \end{array} \right] \]

Step 4: We will cancel the \(y\) in the second equation by multiplying the third equation by \(-2\) and adding the result to the second. Instead of writing out \(-2\) times the third row, you can just mentally add \(-2\) row \(3\) to row \(2.\) \[ \left[ \begin{array}{ccc|c} 1 & -1 & 1 & 4 \\ 0 & 0 & 1 & 1 \\ 0 & 1 & -1 & -2 \\ \end{array} \right] \]

For organizational reasons (and other reasons we will get to next lesson) we will swap the second and third rows. The three equations we are solving don't have an order, so the second equation, \(z = 1,\) could be the second or third equation. Here is the matrix with the rows swapped: \[ \left[ \begin{array}{ccc|c} 1 & -1 & 1 & 4 \\ 0 & 1 & -1 & -2 \\ 0 & 0 & 1 & 1 \\ \end{array} \right] \] Notice that the last equation is \(z = 1,\) so we have solved for \(z.\)

Step 6: Use the row \(z = 1\) to solve for \(y.\) Add row \(3\) to row \(2.\) \[ \left[ \begin{array}{ccc|c} 1 & -1 & 1 & 4 \\ 0 & 1 & 0 & -1 \\ 0 & 0 & 1 & 1 \\ \end{array} \right] \] Now the second equation is \(y = -1\) and we have solved for \(y.\)

Step 7: Subtract row \(3\) from row \(1\) and add row \(2\) to row \(1\) to solve for \(x.\) \[ \left[ \begin{array}{ccc|c} 1 & 0 & 0 & 2 \\ 0 & 1 & 0 & -1 \\ 0 & 0 & 1 & 1 \\ \end{array} \right] \] The equations are now \(x = 2,\) \(y = -1\) and \(z = 1.\)

Review

Once we set up the augmented matrix, there were 3 operations we could perform on the rows:

1. Multiplying a row by a scalar is the same as multiplying the equation on the left and right by that number.

2. Adding two rows is the same as adding the left sides and right sides of the two equations.

3. Swapping two rows is the same as changing the order in which the equations are written.

By using the 3 operations, we were able to rewrite the matrix as \[ \left[ \begin{array}{ccc|c} 1 & 0 & 0 & x \\ 0 & 1 & 0 & y \\ 0 & 0 & 1 & z \\ \end{array} \right] \]