Solution (source code)

= Solution

Take the <invertible matrix> $A=\left(\begin{smallmatrix}0&1\\1&0\end{smallmatrix}\right)$, whose determinant is $-1$. Suppose it had an <LU factorization> with any lower triangular $L$ and upper triangular $U$:
$$
L=\begin{pmatrix}\ell_{11}&0\\\ell_{21}&\ell_{22}\end{pmatrix},\qquad U=\begin{pmatrix}u_{11}&u_{12}\\0&u_{22}\end{pmatrix}.
$$
The $(1,2)$ entry gives $\ell_{11}u_{12}=1$, so $\ell_{11}\ne0$. The $(1,1)$ entry gives $\ell_{11}u_{11}=0$, so $u_{11}=0$. But then the $(2,1)$ entry would be $\ell_{21}u_{11}=0$, contradicting $a_{21}=1$. Thus \b[this nonsingular matrix has no unpermuted LU factorization], even without imposing a unit diagonal on $L$. A row permutation resolves the zero pivot, explaining the role of <partial pivoting>.