When does a real symmetric matrix have $LDL^{T}$ decomposition? And when is the $LDL^{T}$ decomposition unique

linear algebramatricesmatrix decomposition

Suppose that $A$ is an $n \times n$ real symmetric indefinite matrix, ${\rm rank}(A) = k$ and $k \leq n$.
If the $LDL^{T}$ decomposition of $A$ exists, we denote it as $A=LDL^{T}$, where $L$ is a lower unit triangular matrix and $D$ is a diagonal matrix.

I have two questions about it:
(1) What is the necessity and sufficiency of "the $LDL^{T}$ decomposition of $A$ exists"?
(2) What is the necessity and sufficiency of "the $LDL^{T}$ decomposition of $A$ is unique"?

I read the wiki and some books but I can't find the answer. I have an example as follows:
\begin{align}
A_1 &=
\begin{bmatrix}
1 & 0 & 3 \\
0 & 0 & 3 \\
3 & 3 & 3 \\
\end{bmatrix} {\rm\ is\ invertible\ and\ has\ no\ } LDL^{T} {\rm\ decomposition},\\
A_2 &=
\begin{bmatrix}
1 & 1 & 3 \\
1 & 1 & 3 \\
3 & 3 & 3 \\
\end{bmatrix} =
\begin{bmatrix}
1 & 0 & 0 \\
1 & 1 & 0 \\
3 & 3 & 1 \\
\end{bmatrix}
\begin{bmatrix}
1 & 0 & 0 \\
0 & 0 & 0 \\
0 & 0 & -6 \\
\end{bmatrix}
\begin{bmatrix}
1 & 1 & 3 \\
0 & 1 & 3 \\
0 & 0 & 1 \\
\end{bmatrix}{\rm\ is\ singular}, \\
A_3 &=
\begin{bmatrix}
0 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
\end{bmatrix} {\rm\ is\ singular\ and\ has\ no\ } LDL^{T} {\rm\ decomposition}.\\
\end{align}

Best Answer

Let us answer the questions one by one:

Point1: The factorization $LDU$ relies on the factorization $LU$ and then we use $D$ to make $U$ as an upper triangular matrix with $1$'s in the main diagonal. BUT NOT all matrices even symmetric can be written in the form $A=LU$. Take as an example $A=\begin{pmatrix} 0 &2 \\ 2 &4 \\ \end{pmatrix}$. If we assume that this can be written in $LU$ form then

$A=\begin{pmatrix} 1&0 \\ a & 1 \\ \end{pmatrix}\begin{pmatrix} u &v \\ 0 &w \\ \end{pmatrix}$

which gives $u=0,v=2$ and

$LU=\begin{pmatrix} 0 & 2 \\ 0 & av+w \\ \end{pmatrix}$ which is clearly false! What goes wrong? We need in many cases to interchange rows to carry out the Gauss elimination. So the rigorous statement is that there always exist a permutation matrix $P$ such that $PA=LU$.

Point 2: Assume that no row interchanges are needed, so we can have by Gauss elimination $A=LU$. Then we can write $U=DU_{1}$ where $U_{1}$ has $1$'s in the main diagonal. (It is easy to do that by dividing the rows of $U$ by the non-zero elements of the diagonal of $U$).

Point 3: If $A$ is symmetric then $A=A^{T}$ implies: $LDU=U^{T}DL^{T}$ and

$(U^{T})^{-1}LD=DL^{T}U^{-1}$. Notice that the matrix on the l.h.s is lower triangular and the matrix on the r.h.s. is upper triangular. Hence the only possible case to be equal is that both are diagonal and since $D$ is diagonal both $L^{T}U^{-1}$ and $(U^{T})^{-1}L$ are diagonal and because there are only $1$'s in the diagonal there are the identity matrix. Therefore $L^{T}=U$ and $(U^{T})=L^{-1}$ i.e. $U=L^{T}$. Thus, the factorization can be written as $LDL^{T}$.

Point 4: The factorization is unique only if there are no zero elements on the diagonal of $D$. Because if $A=L_{1}D_{1}U_{1}=L_{2}D_{2}U_{2}$ then $L^{-1}_{2}L_{1}D_{1}=D_{2}U_{2}U^{-1}_{1}$. The two matrices are lower triangular=upper triangular hence diagonal. Clearly $L^{-1}_{2}L_{1}D_{1}=D_{1}$ and likewise on the r.h.s. hence $D_{1}=D_{2}$. Now since $D_{1}$ is invertible we obtain $L^{-1}_{2}L_{1}=I$ and $L_{1}=L_{2}$. Likewise $U_{1}=U_{2}$. So the factorization is unique!!!