Finding the A=LDU factorization for matrices I am trying to factorize the matrix on the picture, but I am not sure how can I get the upper triangular matrix. Do I have to reverse every step of the matrix operation that I performed? Any help will be greatly appreciated!
 
 A: I am including the $L$ component of the answer as well.  But $U$ is explained clearly too:
The goal of row reduction is to reduce a matrix $A$ to an upper-triangular matrix $A^{'}$, which you have as a step in your picture. $$A=\begin{bmatrix}1&0&1\\2&2&2\\3&4&5\end{bmatrix}\to \, \, A^{'} = \begin{bmatrix}1&0&1\\0&2&0\\0&0&2\end{bmatrix} $$
But each row operation can be represented as multiplying $A$on the left by some matrix $E$.  In your picture, you use 3 row operations to get to $A^{'}$, so $ E = E_1 E_2 E_3 $ and we have $$ EA = A^{'}$$
Now we can solve for $A$ and see $$A = E^{-1} A^{'} $$
Note that $A^{'}$ can be written as the product of a diagonal matrix and an upper triangular matrix with 1 on the diagonals, $A^{'} = DU = \begin{bmatrix}1&0&0\\0&2&0\\0&0&2\end{bmatrix} \begin{bmatrix}1&0&1\\0&1&0\\0&0&1\end{bmatrix}$.  
It turns out that $E^{-1}$ is already lower triangular, so we have
$$ A = LDU = E^{-1} \begin{bmatrix}1&0&0\\0&2&0\\0&0&2\end{bmatrix} \begin{bmatrix}1&0&1\\0&1&0\\0&0&1\end{bmatrix} $$
A: I usually work out row reduction in Gauss-Jordan form:
\begin{align}
A=\begin{bmatrix}
1&0&1\\
2&2&2\\
3&4&5
\end{bmatrix}
&\xrightarrow{\substack{E_{31}(-3)\\E_{21}(-2)}}
\begin{bmatrix}
1&0&1\\
0&2&0\\
0&4&2
\end{bmatrix}
\\[6px]&\xrightarrow{E_2(1/2)}
\begin{bmatrix}
1&0&1\\
0&1&0\\
0&4&2
\end{bmatrix}
\\[6px]&\xrightarrow{E_{32}(-4)}
\begin{bmatrix}
1&0&1\\
0&1&0\\
0&0&2
\end{bmatrix}
\\[6px]&\xrightarrow{E_{3}(1/2)}
\begin{bmatrix}
1&0&1\\
0&1&0\\
0&0&1
\end{bmatrix}=U
\end{align}
The notation used is


*

*$E_i(c)$ means multiplying the $i$th row by $c\ne0$

*$E_{ij}(d)$ means summing to the $i$th row the $j$th row multiplied by $d$
These can be seen as elementary matrices that successively multiply on the left, so I get
$$
L_0=E_{21}(2)E_{31}(3)E_2(2)E_{31}(4)E_3(2)=
\begin{bmatrix}
1 & 0 & 0 \\
2 & 2 & 0 \\
3 & 4 & 2
\end{bmatrix}
$$
the product of the inverses in the reverse order.
It can be shown that the entries are exactly as dictated by the elementary matrices, with $0$ added off-diagonal and missing entries on the diagonal are $1$.
Now writing $L_0=LD$ is easy:
$$
L=
\begin{bmatrix}
1 & 0 & 0 \\
2 & 1 & 0 \\
3 & 2 & 1
\end{bmatrix}
\qquad
D=\begin{bmatrix}
1 & 0 & 0 \\
0 & 2 & 0 \\
0 & 0 & 2
\end{bmatrix}
$$
(divide each column by the corresponding entry in the diagonal of $D$).
