row exchange results in wrong answer? This is probably a very simple, but why is it that when I do row exchanges I end up with the wrong answer.  I have the matrix equation $Ax = B$, as:
$$
\underbrace{
\begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & -2 \\ -1 & -1 & 1 \end{bmatrix}
}_A
\begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix}
=
\underbrace{
\begin{bmatrix} 3 \\ 1 \\ -6 \end{bmatrix}
}_B$$
I know the answer is $x = \begin{bmatrix} 7 \\ -3 \\ -2 \end{bmatrix}$, but when I do a row exchange (whether needed or not) I end up with the wrong answer.  Why?  NOTE: I exchanged rows 2 and 3.
 A: Let's look at a simple example: 
$$
\begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix}
\begin{bmatrix} x \\y \end{bmatrix}\begin{bmatrix} 6\\12 \end{bmatrix}
$$
which is the same as the equations
$$
2x + 0y = 6\\
0x + 3y = 12
$$
whose solutions are $x = 3, y = 4$. Now swap rows of the matrix. You get
$$
\begin{bmatrix}  0 & 3 \\2 & 0 \end{bmatrix}
\begin{bmatrix} x \\y \end{bmatrix}\begin{bmatrix} 6\\12 \end{bmatrix}
$$
which is the same as the equations
$$
0x + 3y = 6\\
2x + 0y = 12
$$
whose solutions are $y = 2, x = 6$. So you can see from this example that just swapping rows in the matrix $A$ will generally lead to different answers. but if instead you swap things both in $A$ and $B$, then things work out. From the original equation, you get
$$
\begin{bmatrix}  0 & 3 \\2 & 0 \end{bmatrix}
\begin{bmatrix} x \\y \end{bmatrix}\begin{bmatrix} 12\\6 \end{bmatrix}
$$
which is the same as the equations
$$
0x + 3y = 12\\
2x + 0y = 6
$$
whose solutions are $y = 4, x = 3$, which is the same as the original equation.
Typically we do this by forming an "augmented" matrix, consisting of $A$  with an extra column added on for $B$, i.e., forming
$$
\begin{bmatrix}  0 & 3 & | & 12 \\2 & 0 & | & 6  \end{bmatrix}
$$
and then doing row operations to this augmented matrix, so that when you swap rows of $A$ (in the left half of the matrix) you automatically swap rows of $B$ as well. You usually do row-operations until the left side is a nice diagonal matrix (one row swap works in this case!) and then solve. (Sometimes you can't make the left side diagonal, in which case there is more than one solution...which you should learn about as you study these equations further.)
A: $$\left[ \begin{array} {rrr|r}
 1 &  0 &  2 &  3 \\
 0 &  1 & -2 &  1 \\
-1 & -1 &  1 & -6 \\
\end{array}\right]$$
Exchange row 2 and 3 :
$$\left[ \begin{array} {rrr|r}
 1 &  0 &  2 &  3 \\
-1 & -1 &  1 & -6 \\
 0 &  1 & -2 &  1 \\
\end{array}\right]$$
Add row 1 to row 2:
$$\left[ \begin{array} {rrr|r}
 1 &  0 &  2 &  3 \\
 0 & -1 &  3 & -3 \\
 0 &  1 & -2 &  1 \\
\end{array}\right]$$
Add row 2 to row 3:
$$\left[ \begin{array} {rrr|r}
 1 &  0 &  2 &  3 \\
 0 & -1 &  3 & -3 \\
 0 &  0 &  1 & -2 \\
\end{array}\right]$$
Multiply row 2 by -1:
$$\left[ \begin{array} {rrr|r}
 1 &  0 &  2 &  3 \\
 0 &  1 & -3 &  3 \\
 0 &  0 &  1 & -2 \\
\end{array}\right]$$
Add 3 times row 3 to row 2:
$$\left[ \begin{array} {rrr|r}
 1 &  0 &  2 &  3 \\
 0 &  1 &  0 & -3 \\
 0 &  0 &  1 & -2 \\
\end{array}\right]$$
Add -2 times row 3 to row 1:
$$\left[ \begin{array} {rrr|r}
 1 &  0 &  0 &  7 \\
 0 &  1 &  0 & -3 \\
 0 &  0 &  1 & -2 \\
\end{array}\right]$$
