<s>[INST] Solving Linear Equation with non-invertible matrix? Find X when AX = B.
A= \begin{bmatrix}1&2&1\\2&5&4\end{bmatrix}
B = \begin{bmatrix}3&1\\5&4\end{bmatrix}
I know how to solve for x when A is invertible. I know it would just be $A^{-1}$B.
I'm confused with how to do this when A is non-invertible, I was trying to use the free variables. I can give the actual matrices if needed.
Thanks 
 [/INST] reducing, saving a little typing
$$
\left(
\begin{array}{rrr|rr}
1 & 2 & 1 & 3 & 1 \\
2 & 5 & 4 & 5 & 4
\end{array}
\right)
$$
$$
\left(
\begin{array}{rrr|rr}
1 & 2 & 1 & 3 & 1 \\
0 & 1 & 2 & -1 & 2
\end{array}
\right)
$$
$$
\left(
\begin{array}{rrr|rr}
1 & 0 & -3 & 5 & -3 \\
0 & 1 & 2 & -1 & 2
\end{array}
\right)
$$
As Robert said from the beginning, you now have familiar augmented systems for the two columns of $X,$
$$
\left(
\begin{array}{rrr|r}
1 & 0 & -3 & 5  \\
0 & 1 & 2 & -1 
\end{array}
\right)
$$
$$
\left(
\begin{array}{rrr|r}
1 & 0 & -3 &  -3 \\
0 & 1 & 2 &  2
\end{array}
\right)
$$
</s>