Row Reduction of a matrix Let us consider the following matrix $$M= \left[ {\begin{array}{cc}
             1 & 1 & 2 & 1 & 5 \\
             1 & 1 & 2 & 6 & 10 \\
             1 & 2 & 5 & 2 & 7 \\
                \end{array} } \right]$$
I was able to reduce the above matrix to a row echelon matrix:
$$M'=\left[ {\begin{array}{cc}
             1 & 0 & -1 & 0 & 3 \\
             0 & 1 & 3 & 0 & 1 \\
             0 & 0 & 0 & 1 & 1 \\
                \end{array} } \right]$$
But I don't know how to express M' as a multiplication by a sequence $E_1,...,E_k$ of elementary matrices: $$M'=E_k...E_2E_1M$$
Thank you in advance
 A: $M'=E_k...E_2E_1M$
From the row operations you provided, we arrive at:
$\begin{bmatrix} 1& 0& 0 \\0& 1& -1 \\ 0& 0& 1  \end{bmatrix} \begin{bmatrix} 1& 0& 0 \\ 0& 1& 0 \\ 0& 0& 1/5  \end{bmatrix}\begin{bmatrix} 1& -1& 0 \\ 0& 1& 0 \\ 0& 0& 1 \end{bmatrix}\begin{bmatrix} 1& 0& 0 \\ 0& 0& 1 \\ 0&1& 0 \end{bmatrix}\begin{bmatrix} 1& 0& 0 \\ 0& 1& 0 \\ -1& 0& 1 \end{bmatrix}\begin{bmatrix} 1& 0& 0 \\ -1& 1& 0 \\ 0& 0& 1 \end{bmatrix}\begin{bmatrix} 1 & 1 & 2 & 1 & 5 \\ 1 & 1 & 2 & 6 & 10 \\ 1 & 2 & 5 & 2 & 7 \\ \end{bmatrix} = \begin{bmatrix}1 & 0 & -1 & 0 & 3 \\0 & 1 & 3 & 0 & 1 \\ 0 & 0 & 0 & 1 & 1\end{bmatrix}$
A: Hint: To remember how to express each type of row operation as an elementary matrix, simply perform that row operation on the identity matrix. Thus, for example, the first elementary matrix $E_1$ corresponding to your first row operation (adding $(-1) \cdot R_1$ to $R_2$) would be:
$$
E_1 = \begin{bmatrix}
 1 & 0 & 0 \\
-1 & 1 & 0 \\
 0 & 0 & 1 \\
\end{bmatrix}$$
Can you see how this matrix was obtained? Can you see why its size is $3 \times 3$, and not $5 \times 5$?
A: If we take $A\in\mathbb{F}^{n\times m}$ and $x\in\mathbb{F}^n$, then $x^TA\in\mathbb{F}^m$ is a linear combination of $A$'s rows with coefficients $x_1,x_2\ldots,x_n$. It follows that for $E\in\mathbb{F}^{n\times n}$, each row of $EA$ is a linear combination of $A$'s rows with coefficients given by the corresponding row of $E$. This should be helpful in constructing the different types of elementary matrices.
