Until now, I used "+" to do row reduction to get the upper triangular form. For example:
\begin{bmatrix}1&0& &a&b\\0&1& &a&2b\end{bmatrix} \begin{bmatrix}1&0& &a&b\\-1&1& &0&b\end{bmatrix}
However, when I practised LU decomposition today, I encountered something that I don't understand.
Added complete solution processes
Task: Compute the LU decomposition of matrix A without swapping rows.
A = \begin{bmatrix}2&2&-3&-1\\0&1&-3&-2\\-8&-7&7&7\\4&1&3&4\end{bmatrix}
Solution with my "+" method:
\begin{bmatrix}1&0&0&0& &2&2&-3&-1\\0&1&0&0& &0&1&-3&-2\\0&0&1&0& &-8&-7&7&7\\0&0&0&1& &4&1&3&4\end{bmatrix} \begin{bmatrix}1&0&0&0& &2&2&-3&-1\\0&1&0&0& &0&1&-3&-2\\4&0&1&0& &0&1&-5&3\\-2&0&0&1& &0&-3&9&6\end{bmatrix} \begin{bmatrix}1&0&0&0& &2&2&-3&-1\\0&1&0&0& &0&1&-3&-2\\4&-1&1&0& &0&0&-2&5\\-2&3&0&1& &0&0&0&0\end{bmatrix}
Correct solution with "-":
\begin{bmatrix}1&0&0&0& &2&2&-3&-1\\0&1&0&0& &0&1&-3&-2\\0&0&1&0& &-8&-7&7&7\\0&0&0&1& &4&1&3&4\end{bmatrix} \begin{bmatrix}1&0&0&0& &2&2&-3&-1\\0&1&0&0& &0&1&-3&-2\\-4&0&1&0& &0&1&-5&3\\2&0&0&1& &0&-3&9&6\end{bmatrix} \begin{bmatrix}1&0&0&0& &2&2&-3&-1\\0&1&0&0& &0&1&-3&-2\\-4&1&1&0& &0&0&-2&5\\2&-3&0&1& &0&0&0&0\end{bmatrix}
If I multiply L and U from the correct solution, I get matrix A back. Logically, that is not the case with my solution.
What's wrong with my approach?
With that method, that should automatically build the $L$ matrix on the left side, you have to be careful that in it you must use the inverse operation on the left that you use on the right. Basically, if $L_i$ is the matrix on the left and $U_i$ is the matrix on the right at step $i$, you have $$ A=L_iU_i $$ at each step. If $E$ denotes the elementary matrix you use in passing from step $i$ to step $i+1$, you basically are doing $$ A=L_i\,E^{-1}\,E\,U_i $$ and setting $$ L_{i+1}=E^{-1},\quad U_{i+1}=EU_i $$ So, if you sum to the third row of the matrix on the right the first row multiplied by $4$, you have to perform a similar transformation on the matrix on the right on the columns, but using the inverse elementary matrix, which becomes
Similarly, if you use the operation multiply the $k$-th row by $c$ on the right-hand side matrix, you have to do multiply the $k$-th column by $c^{-1}$ on the left-hand side matrix.