# How do you solve x-y+z=3 and 2y-z=1 and -x+2y= -1 using matrices?

Feb 11, 2016

$x = 3$, $y = 1$, $z = 1$

#### Explanation:

Your linear equation can be written as the following matrix (first column representing the $x$, second column the $y$ and third column the $z$):

$\left(\begin{matrix}1 & - 1 & 1 & | & 3 \\ 0 & 2 & - 1 & | & 1 \\ - 1 & 2 & 0 & | & - 1\end{matrix}\right) \text{ } \left.\begin{matrix}I \\ I I \\ I I I\end{matrix}\right.$

To eliminate the $- 1$ in the first column, compute $I + I I I \to \textcolor{b l u e}{I I I}$:

$\Rightarrow \left(\begin{matrix}1 & - 1 & 1 & | & 3 \\ 0 & 2 & - 1 & | & 1 \\ \textcolor{b l u e}{0} & \textcolor{b l u e}{1} & \textcolor{b l u e}{1} & | & \textcolor{b l u e}{2}\end{matrix}\right) \text{ } \left.\begin{matrix}I \\ I I \\ \textcolor{b l u e}{I I I}\end{matrix}\right.$

To eliminate the $2$ in the second column, compute $I I - 2 I I I \to \textcolor{red}{I I}$:

$\Rightarrow \left(\begin{matrix}1 & - 1 & 1 & | & 3 \\ \textcolor{red}{0} & \textcolor{red}{0} & \textcolor{red}{- 3} & | & \textcolor{red}{- 3} \\ 0 & 1 & 1 & | & 2\end{matrix}\right) \text{ } \left.\begin{matrix}I \\ \textcolor{red}{I I} \\ I I I\end{matrix}\right.$

Compute $- \frac{1}{3} I I \to \textcolor{g r e e n}{I I}$:

$\Rightarrow \left(\begin{matrix}1 & - 1 & 1 & | & 3 \\ \textcolor{g r e e n}{0} & \textcolor{g r e e n}{0} & \textcolor{g r e e n}{1} & | & \textcolor{g r e e n}{1} \\ 0 & 1 & 1 & | & 2\end{matrix}\right) \text{ } \left.\begin{matrix}I \\ \textcolor{g r e e n}{I I} \\ I I I\end{matrix}\right.$

Now, use the second row to eliminate the $1$ in the third row, third column:
compute $I I I - I I \to \textcolor{\mathmr{and} a n \ge}{I I I}$:

$\Rightarrow \left(\begin{matrix}1 & - 1 & 1 & | & 3 \\ 0 & 0 & 1 & | & 1 \\ \textcolor{\mathmr{and} a n \ge}{0} & \textcolor{\mathmr{and} a n \ge}{1} & \textcolor{\mathmr{and} a n \ge}{0} & | & \textcolor{\mathmr{and} a n \ge}{1}\end{matrix}\right) \text{ } \left.\begin{matrix}I \\ I I \\ \textcolor{\mathmr{and} a n \ge}{I I I}\end{matrix}\right.$

We are almost done. Now, you need to use the third row to eliminate the $- 1$ in the first row, and the second row to eliminate the $1$ in the first row, third column.

Let's do it step by step: first, $I + I I I \to \textcolor{v i o \le t}{I}$:

$\Rightarrow \left(\begin{matrix}\textcolor{v i o \le t}{1} & \textcolor{v i o \le t}{0} & \textcolor{v i o \le t}{1} & | & \textcolor{v i o \le t}{4} \\ 0 & 0 & 1 & | & 1 \\ 0 & 1 & 0 & | & 1\end{matrix}\right) \text{ } \left.\begin{matrix}\textcolor{v i o \le t}{I} \\ I I \\ I I I\end{matrix}\right.$

Last step: compute $I - I I \to \textcolor{g r a y}{I}$:

$\Rightarrow \left(\begin{matrix}\textcolor{g r a y}{1} & \textcolor{g r a y}{0} & \textcolor{g r a y}{0} & | & \textcolor{g r a y}{3} \\ 0 & 0 & 1 & | & 1 \\ 0 & 1 & 0 & | & 1\end{matrix}\right) \text{ } \left.\begin{matrix}\textcolor{g r a y}{I} \\ I I \\ I I I\end{matrix}\right.$

If you would like, you can also swap $I I$ and $I I I$ to have the perfect "step format" in your matrix.

The solution is $x = 3$, $y = 1$ and $z = 1$.