How do you decide which rows to swap for a matrix while doing gaussian elimination?

262 Views Asked by At

I'm trying to do LU factorization and for one of the examples I found online, the question is to solve the equation Ax=b with A and b as follows : A_and_b

In their solution for finding the upper triangular matrix (U), they started by swapping rows 1 and 4 while I started by swapping 1 and 3. This is the solution they got and here is my solution :

\begin{bmatrix}-1&2&3&-1\\0&5&5&-1\\0&0&3&-2/5\\0&0&0&2/5\end{bmatrix}

The solution they got is the correct answer which I'm able to get if in the beginning I swap rows 1 and 4 instead of 1 and 3. However I'm confused about how they decided which row to swap. I had no particular reason for choosing to swap 1 with 3, I just chose a random row. Can someone please explain the reason behind swapping 1 with 4?

Edit : This is my full solution Not sure where I went wrong...