Now that we have our system of linear equations in augmented matrix form, we can solve for the unknown variables using a technique called *Gauss-Jordan Elimination*. In regular algebra, we may try to solve the system by combining equations to eliminate variables until we can solve for a single one. Having one variable solved for then allows us to solve for a second variable, and we can continue that process until all variables are solved for.

The same goal can be used for solving for the unknown variables when in the matrix representation. We start with forming our augmented matrix.

```
$\begin{bmatrix}
a_{1} & b_{1} & c_{1} \bigm| d_{1} \\
a_{2} & b_{2} & c_{2} \bigm| d_{2} \\
a_{3} & b_{3} & c_{3} \bigm| d_{3} \\
\end{bmatrix}$
```

To solve for the system, we want to put our augmented matrix into something called *row echelon form* where all elements below the diagonal are equal to zero. This looks like the following:

```
$\begin{bmatrix}
a_{1} & b_{1} & c_{1} \bigm| d_{1} \\
a_{2} & b_{2} & c_{2} \bigm| d_{2} \\
a_{3} & b_{3} & c_{3} \bigm| d_{3} \\
\end{bmatrix}
\rightarrow
\begin{bmatrix}
1 & b_{1}' & c_{1}' \bigm| d_{1}' \\
0 & 1 & c_{2}' \bigm| d_{2}' \\
0 & 0 & 1 \hspace{1.25mm} \bigm| d_{3}' \\
\end{bmatrix}$
```

Note that the values with apostrophes in the *row echelon form* matrix mean that they have been changed in the process of updating the matrix. Once in this form we can rewrite our original equation as:

```
$\begin{aligned}
x + b_{1}' y + c_{1}'z = d_{1}' \\
y + c_{2}'z = d_{2}' \\
z = d_{3}' \\
\end{aligned}$
```

This allows us to solve the equations directly using simple algebra. But how do we get to this form?

To get to row echelon form we swap rows and/or add or subtract rows against other rows. A typical strategy is to add or subtract row 1 against all rows below in order to make all elements in column 1 equal to 0 under the diagonal. Once this is achieved, we can do the same with row 2 and all rows below to make all elements below the diagonal in column 2 equal to 0.

Once all elements below the diagonal are equal to 0, we can simply solve for the variable values, starting at the bottom of the matrix and working our way up.

It’s important to realize that not all systems of equations are solvable! For example, we can perform Gauss-Jordan Elimination and end up with the following augmented matrix.

```
$\begin{bmatrix}
1 & -2 & -2 \bigm| 5 \\
\bf 0 & 3 & -1 \bigm| 3 \\
\bf 0 & \bf 0 & \enspace\; {\bf 0 } \bigm| 2
\end{bmatrix}$
```

This final augmented matrix here suggests that 0*z* = 2, which is impossible!

### Instructions

Let’s walk through an example of Gauss-Jordan elimination going through the animation on the right step-by-step.