Rearranging elements in a matrix It's been a while since I studied linear algebra. I am trying to get the elements of a matrix to be in a certain order to follow a convention used in optics. In that context, the elements of the matrix are partial derivatives. Here, imagine the simpler scenario where I have the equations:
$2x+y=1$
$x-y=0$
I can represent these as:
\begin{bmatrix}
2 & 1 & x & 1\\
1 & -1 & y &0
\end{bmatrix}
In the convention, I want the $x$ to be next to the $1$ and the $y$ next to the $0$. Therefor, the system can be equally represented as:
\begin{bmatrix}
-1 & 1& y & 0\\
1 & 2 & x & 1
\end{bmatrix}
If I were to generalize this to a $3\times 3$ (or higher order) matrix (i.e. add another equation to the list), how could I change change the order of the elements while still keeping the $x$ next to $1$ (and $y$ next to $0$)?
 A: In this problem, if you represent
$2x+y=1$
$x-y=0$ as
$-y+x=0$
$y+2x=1$
then you get the matrix
\begin{bmatrix}
-1 & 1& y & 0\\
1 & 2 & x & 1
\end{bmatrix}
So in general what you want to do is rearrange the variables in whichever order you prefer, then rearrange the order of the equations so that the equation with a 1 is in the position of x in the rearranged variables.
As an example if you had
$2x+y=1$
$x-y=0$
$x+y+z=0$
I can represent these as:
\begin{bmatrix}
2 & 1 &0& x & 1\\
1 & -1 &0& y &0\\
1&1&1&z&0
\end{bmatrix}
If you want to rearrange the variables so that it $xyz$ goes to $zyx$ then you would consider the equations as
$y+2x=1$
$-y+x=0$
$z+y+x=0$
To get the $x$ next to the 1, since for $zyx$, $x$ is in the third position, you want the equation with a 1 to be in the third position also, so
$-y+x=0$
$z+y+x=0$
$y+2x=1$ to get the matrix
\begin{bmatrix}
0 & -1 &1& z &0 \\
1 & 1 &1& y &0\\
0&1&2&x&1
\end{bmatrix}
A: The best way to understand how to use elementary operations in linear algebra is to discard conventions such as that in your question. Yes, discard!
You can use it for communication. And that should be the end of it. Never use it for understanding.
What
$$
\begin{equation}\tag{1}
\begin{bmatrix}
-1 & 1& y & 0\\
1 & 2 & x & 1
\end{bmatrix}
\end{equation}
$$
truly means is as follows.
$$
\begin{bmatrix}
-1 & 1\\
1 & 2
\end{bmatrix}
\begin{bmatrix}
x\\
y
\end{bmatrix}
=\begin{bmatrix}
0\\
1
\end{bmatrix}
$$
In the above matrix-vector multiplication, you can clearly see your original equations.
Applying elementary row operations means to left-multiple both sides of the equation by the corresponding elementary matrix. And that corresponding matrix can be obtained by performing the same elementary row operation on the identity matrix.
For example, suppose you want to make row 2 add row 1. Perform that to the identity matrix, you get:
$$
\begin{bmatrix}
1 & 0\\
0 & 1
\end{bmatrix}
\longrightarrow
\begin{bmatrix}
1 & 0\\
1 & 1
\end{bmatrix}
$$
The row operation on the original equation is thus
$$
\begin{bmatrix}
1 & 0\\
1 & 1
\end{bmatrix}
\begin{bmatrix}
-1 & 1\\
1 & 2
\end{bmatrix}
\begin{bmatrix}
x\\
y
\end{bmatrix}
=\begin{bmatrix}
1 & 0\\
1 & 1
\end{bmatrix}
\begin{bmatrix}
0\\
1
\end{bmatrix}
$$
which simplifies to
$$
\begin{equation}\tag{2}
\begin{bmatrix}
-1 & 1\\
0 & 3
\end{bmatrix}
\begin{bmatrix}
x\\
y
\end{bmatrix}
=\begin{bmatrix}
0\\
1
\end{bmatrix}
\end{equation}
$$
(1) is true if and only if (2) is true. Thus, you can solve (2) and get the answer for (1). You do that because the answer for (2) is (more) obvious.

To the specific question of "how could I change change the order of the elements while still keeping the x next to 1?"
It is the same idea. Switching row 1 and row 2 on identity matrix first. (1 and 2 are ofc arbitrary choices. You can generalize it to any pair of rows.)
In 2D, you get
$$
\begin{bmatrix}
1 & 0\\
0 & 1
\end{bmatrix}
\longrightarrow
\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}
$$
from here, perhaps you can try simplifying the multiplication and see what you get.

Now that you understand what elementary row operations are. You should be able to state any linear system of equations in matrix-vector multiplication.
With the understanding, you should be able to re-derive the rule for switching rows any time, which is: you also need to switch the corresponding rows on the RHS of the equation.
