In general I know how to do PA = LU. Basically we do A = LU decomposition first, and then do row swap and change the value of P.
But I've got a weird problem from my prof.
$ A = \left[ {\begin{array}{ccccc} 0 & 0 & 1 & -3 & 2 \\ 2 & -1 & 4 & 2 & 1 \\ 4 & -2 & 9 & 1 & 4 \\ 2 & -1 & 5 & -1 & 5 \\ \end{array} } \right] $
Here'a my steps to do the decomposition:
Remove the last column because PA = LU decomposition can only perform on n by n matrix.
row 4 <-- row 2 - row 4
$ U = \left[ {\begin{array}{cccc} 0 & 0 & 1 & -3 \\ 2 & -1 & 4 & 2 \\ 4 & -2 & 9 & 1 \\ 0 & 0 & -1 & 3 \\ \end{array} } \right] $
$ L = \left[ {\begin{array}{cccc} 1 & & & \\ & 1 & & \\ & & 1 & \\ 1 & 1 & & 1 \\ \end{array} } \right] $
row 4 <-- row 1 + row 4
$ U = \left[ {\begin{array}{ccccc} 0 & 0 & 1 & -3 \\ 2 & -1 & 4 & 2 \\ 4 & -2 & 9 & 1 \\ 0 & 0 & 0 & 0 \\ \end{array} } \right] $
$ L = \left[ {\begin{array}{cccc} 1 & & & \\ & 1 & & \\ & & 1 & \\ 1 & 1& -1 & 1 \\ \end{array} } \right] $
row 3 <-- (-2) * row 2 + row 3
$ U = \left[ {\begin{array}{ccccc} 0 & 0 & 1 & -3 \\ 2 & -1 & 4 & 2 \\ 0 & 0 & 1 & -3 \\ 0 & 0 & 0 & 0 \\ \end{array} } \right] $
$ L = \left[ {\begin{array}{cccc} 1 & & & \\ & 1 & & \\ 2 & 2 & 1 & \\ 1 & 1& -1 & 1 \\ \end{array} } \right] $
row 3 <-- row 1 - row 3
$ U = \left[ {\begin{array}{ccccc} 0 & 0 & 1 & -3 \\ 2 & -1 & 4 & 2 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ \end{array} } \right] $
$ L = \left[ {\begin{array}{cccc} 1 & & & \\ 0 & 1 & & \\ 2 & 2 & 1 & \\ 1 & 1 & -1 & 1 \\ \end{array} } \right] $
However
L * U = $\left[ {\begin{array}{cccc} 1 & & & \\ 0 & 1 & & \\ 2 & 2 & 1 & \\ 1 & 1 & -1 & 1 \\ \end{array} } \right]$
- $\left[ {\begin{array}{cccc} 0 & 0 & 1 & -3 \\ 2 & -1 & 4 & 2 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ \end{array} } \right]$
=
$\left[ {\begin{array}{ccccc} 0 & 0 & 1 & -3 \\ 2 & -1 & 4 & 2 \\ 4 & -2 & 10 & -2 \\ 2 & -1 & 5 & -3 \\ \end{array} } \right]$
The third and fourth rows are different from the original A, but I am not sure which steps are wrong..