Find the permutation matrix P so that PA can be factored into the product LU, where L is lower triangular with 1's on its diagonal and U is upper triangular for these matrices.

$\displaystyle A = \left[ \begin{array}{cccc} 1 & 2 & -1 \\ 2 & 4 & 0 \\ 0 & 1 & -1 \end{array} \right]$

So the back of the book shows: $\displaystyle P = \left[ \begin{array}{cccc} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{array} \right]$

Which I tried working out and got the same answer. I didn't interchange the first and second row which I assume the book didn't either.

But MATLAB shows this: $\displaystyle U = \left[ \begin{array}{cccc} 2 & 4 & 0 \\ 0 & 1 & -1 \\ 0 & 0 & -1 \end{array} \right]$ $\displaystyle P = \left[ \begin{array}{cccc} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{array} \right]$

The other one I did was $\displaystyle A = \left[ \begin{array}{cccc} 1 & 1 & -1 & 2 \\ -1 & -1 & 1 & 5 \\ 2 & 2 & 3 & 7 \\ 2 & 3 & 4 & 5 \end{array} \right]$ and got $\displaystyle A = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{array} \right]$ but MATLAB shows $\displaystyle U = \left[\begin{array}{cccc} 2 & 2 & 3 & 7\\ 0 & 1 & 1 & -2\\ 0 & 0 & - \frac{5}{2} & - \frac{3}{2}\\ 0 & 0 & 0 & 7 \end{array}\right]$ $\displaystyle P = \left[\begin{array}{cccc} 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\\ 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \end{array}\right]$

All the other questions, the P in the back of the book and MATLAB are the same. I noticed in MATLAB, it chooses biggest number in the first column and sets that as the first row.

So is the book wrong and am I supposed to choose the biggest number in the first column and set that as the first row before I start row reducing? But how do I know if [2 2 3 7] or [2 3 4 5] is bigger?