Matrix: determinant & Diagonal There is a question that comes up in my mind after I watched Prof. Gilbert Strang's lectures. He was saying:
For any matrix $A$, Since $A = LU$, $\det(A) = \det(LU)$ and $\det(L) = 1$, hence $\det(A) = \det(U)$, furthermore, $\det(U) = \det(D)$ when $U$ is the upper triangular and $D$ is the diagonal.
Then do I get the conclusion that $\det(A) = \det(D)$???
However, I don't think this is the case, to the least, not true in 2-D, as we all know what is the formula of determinant of a 2-D matrix.
Am I missing something here? Thanks!
 A: One remark first, the determinant is defined for square matrices, not for vectors. Maybe the problem here is you view $D$ as a vector, whereas what is meant is "the square matrix with the same diagonal as $U$ and zeros everywhere else".
The LU decomposition yields a lower triangular matrix $L$ and an upper triangular matrix $U$ with
$$A=LU$$
The the determinant of a product is always the product of the determinants, it's perfectly safe to write
$$\det A=\det L \det U$$
Now, the determinant of a triangular matrix is the product of it's diagonal elements, and $L$ has only ones in its diagonal, whereas the diagonal of $U$ may be called $D$, and
$$\det A=\det D$$
For example, with $A=\left(\begin{matrix}
1 & 0 & 1 \\
2 & 1 & 0 \\
1 & 2 & 2 \\
\end{matrix}\right)$, you get the factorization
$$A=\left(\begin{matrix}
1 & 0 & 0 \\
2 & 1 & 0 \\
1 & 2 & 1 \\
\end{matrix}\right)\cdot\left(\begin{matrix}
1 & 0 & 1 \\
0 & 1 & -2 \\
0 & 0 & 5 \\
\end{matrix}\right)$$
And of course
$$\det \left(\begin{matrix}
1 & 0 & 0 \\
2 & 1 & 0 \\
1 & 2 & 1 \\
\end{matrix}\right)=\det \left(\begin{matrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\end{matrix}\right)=1$$
$$\det \left(\begin{matrix}
1 & 0 & 1 \\
0 & 1 & -2 \\
0 & 0 & 5 \\
\end{matrix}\right)=\det \left(\begin{matrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 5 \\
\end{matrix}\right)=5$$
Hence $\det A=5$.
There is another $LU$ factorization, with ones in the diagonal of $U$ instead of $L$, but of course that does not change the answer, if $D$ is the diagonal of $L$.

There may be another concern: often, the $LU$ decomposition is written
$$PA=LU$$
Where $P$ is a permutation matrix. If happens when pivoting is used in de $LU$ decomposition.
Then $\det P \det A=\det L\det U$, but $\det P=\pm1$, since a permutation matrix is always orthogonal. Thus you must be careful with the sign of $\det A$. And $\det P$ is simply the sign of the permutation on which $P$ is based.
