<s>[INST] How to solve a linear system when there isn't an exact solution? I've been trying to solve this linear system using Gaussian elimination, but I can't seem to finish it.
$ x +0y - z + w = 0 $
$ 0x + 2y + 2z + 2w = 2 $
$ x + y + 0z + 2w = 1 $
$$ \left[
\begin{array}{cccc|c}
1 & 0 & -1 & 1 & 0 \\
0 & 2 & 2 & 2 & 2 \\
1 & 1 & 0 & 2 & 1
\end{array}
\right] \Rightarrow \left[
\begin{array}{cccc|c}
1 & 0 & -1 & 1 & 2 \\
0 & 1 & 1 & 1 & 1 \\
0 & 1 & 1 & 1 & 1
\end{array}
\right] $$
$$ \\ -R_1\rightarrow R_3 \\ \frac{1}{2} R_2 \\ $$ 
And what then? I couldn't come up with a conventional solution where I just start with finding the rightmost variable and all other variables show themselves easily then. $ -R_2 \rightarrow R_3 $ doesn't end up in anything sensible. Could you please give me a hint on how to move on from here?
p.s. First time using the formatting, pardon my mistakes.
 [/INST] From
$\left[
\begin{array}{cccc|c}
1 & 0 & -1 & 1 & 0 \\
0 & 1 & 1 & 1 & 1 \\
0 & 0 & 0 & 0 & 0
\end{array}
\right]$
add the free variables $z=s$, $w=t$ to get
$\left[
\begin{array}{cccc|c}
1 & 0 & -1 & 1 & 0 \\
0 & 1 & 1 & 1 & 1 \\
0 & 0 & 1 & 0 & s\\
0 & 0 & 0 & 1 & t
\end{array}
\right]\to
\left[\begin{array}{cccc|c}
1 & 0 & 0 & 1 & s \\
0 & 1 & 0 & 1 & 1-s \\
0 & 0 & 1 & 0 & s\\
0 & 0 & 0 & 1 & t
\end{array}
\right]\to
\left[\begin{array}{cccc|c}
1 & 0 & 0 & 0 & s-t \\
0 & 1 & 0 & 0 & 1-s-t \\
0 & 0 & 1 & 0 & s\\
0 & 0 & 0 & 1 & t
\end{array}
\right]$
obtaining
$$\left(
\begin{array}{c}
x\\y\\z\\w
\end{array}
\right)=
\left(
\begin{array}{c}
0\\1\\0\\0
\end{array}
\right)+
\left(\begin{array}{r}
1\\-1\\1\\0
\end{array}
\right)s+
\left(\begin{array}{r}
-1\\-1\\0\\1
\end{array}
\right)t$$
</s>