# $LDL^\top$ for symmetric positive semidefinite matrices that are not positive definite

I have a symmetric positive semidefinite matrix (which is not positive definite) with integer entries and I know that I have an $$LDL^\top$$ decomposition for it (well mainly because Maple gives me one). I have blindly implemented an $$LDL^\top$$ decomposition myself in python which I more-or-less copied from Golub's book. But as far as I know, this will only work if the $$D$$ in the decomposition has no zeros (so positive definite case). I am curious how the naive algorithm (where you do have a division by entries in $$D$$) is changed so that you get Maple's result. I suspected that my implementation would work and just yield me undef entries where there should be 0. Indeed this happened, the result from the traditional algorithm will give the same result as Maple's output if we substitute any division by 0's (due to diagonal entries being 0) by simply 0. I am not sure though why this will work. Can anyone explain this to me? Is there a theorem for the "strict" positive semidefinite case that explains this?. Here is my implementation and my example:

def LDL(mat): #note: mat should be square!
diag=[]
n = mat.rowDim()
L = mat
for j in xrange(n):
v=[]
for i in xrange(j):
v.append(L[j,i]*L[i,i])
if j>0:
L[j,j]=L[j,j]-dot(L.row(j)[0:j],v)
for k in xrange(j+1,n):
L[k,j]=(L[k,j]-dot(L.row(k)[0:j],v))/L[j,j]
else:
for k in xrange(j+1,n):
L[k,j]=L[k,j]/L[j,j]
diag.append(L[j,j])
#convert to 0 the upper triangle of L
for i in xrange(n):
L[i,i] = 1
for k in xrange(i+1,n):
L[i,k] = 0
return diag, L


The example that I had in mind is this (with output of the above implementation):

input: matrix[[10,3,-11,15,3,2],[3,9,-15,0,0,6],[-11,-15,29,-10,-2,-10],[15,0,-10,25,5,0],[3,0,-2,5,1,0],[2,6,-10,0,0,4]]
output: ([10, 81/10, 0, undef, undef, undef], matrix[[1,0,0,0,0,0],[3/10,1,0,0,0,0],[-11/10,-13/9,1,0,0,0],[3/2,-5/9,undef,1,0,0],[3/10,-1/9,undef,undef,1,0],[1/5,2/3,undef,undef,undef,1]])


## 1 Answer

$$P^T H P = D$$ $$\left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ - \frac{ 3 }{ 10 } & 1 & 0 & 0 & 0 & 0 \\ \frac{ 2 }{ 3 } & \frac{ 13 }{ 9 } & 1 & 0 & 0 & 0 \\ - \frac{ 5 }{ 3 } & \frac{ 5 }{ 9 } & 0 & 1 & 0 & 0 \\ - \frac{ 1 }{ 3 } & \frac{ 1 }{ 9 } & 0 & 0 & 1 & 0 \\ 0 & - \frac{ 2 }{ 3 } & 0 & 0 & 0 & 1 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 10 & 3 & - 11 & 15 & 3 & 2 \\ 3 & 9 & - 15 & 0 & 0 & 6 \\ - 11 & - 15 & 29 & - 10 & - 2 & - 10 \\ 15 & 0 & - 10 & 25 & 5 & 0 \\ 3 & 0 & - 2 & 5 & 1 & 0 \\ 2 & 6 & - 10 & 0 & 0 & 4 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 2 }{ 3 } & - \frac{ 5 }{ 3 } & - \frac{ 1 }{ 3 } & 0 \\ 0 & 1 & \frac{ 13 }{ 9 } & \frac{ 5 }{ 9 } & \frac{ 1 }{ 9 } & - \frac{ 2 }{ 3 } \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ \end{array} \right)$$ $$Q^T D Q = H$$ $$\left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ \frac{ 3 }{ 10 } & 1 & 0 & 0 & 0 & 0 \\ - \frac{ 11 }{ 10 } & - \frac{ 13 }{ 9 } & 1 & 0 & 0 & 0 \\ \frac{ 3 }{ 2 } & - \frac{ 5 }{ 9 } & 0 & 1 & 0 & 0 \\ \frac{ 3 }{ 10 } & - \frac{ 1 }{ 9 } & 0 & 0 & 1 & 0 \\ \frac{ 1 }{ 5 } & \frac{ 2 }{ 3 } & 0 & 0 & 0 & 1 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & \frac{ 1 }{ 5 } \\ 0 & 1 & - \frac{ 13 }{ 9 } & - \frac{ 5 }{ 9 } & - \frac{ 1 }{ 9 } & \frac{ 2 }{ 3 } \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrrrrr} 10 & 3 & - 11 & 15 & 3 & 2 \\ 3 & 9 & - 15 & 0 & 0 & 6 \\ - 11 & - 15 & 29 & - 10 & - 2 & - 10 \\ 15 & 0 & - 10 & 25 & 5 & 0 \\ 3 & 0 & - 2 & 5 & 1 & 0 \\ 2 & 6 & - 10 & 0 & 0 & 4 \\ \end{array} \right)$$

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Algorithm discussed at http://math.stackexchange.com/questions/1388421/reference-for-linear-algebra-books-that-teach-reverse-hermite-method-for-symmetr
https://en.wikipedia.org/wiki/Sylvester%27s_law_of_inertia
$$H = \left( \begin{array}{rrrrrr} 10 & 3 & - 11 & 15 & 3 & 2 \\ 3 & 9 & - 15 & 0 & 0 & 6 \\ - 11 & - 15 & 29 & - 10 & - 2 & - 10 \\ 15 & 0 & - 10 & 25 & 5 & 0 \\ 3 & 0 & - 2 & 5 & 1 & 0 \\ 2 & 6 & - 10 & 0 & 0 & 4 \\ \end{array} \right)$$ $$D_0 = H$$ $$E_j^T D_{j-1} E_j = D_j$$ $$P_{j-1} E_j = P_j$$ $$E_j^{-1} Q_{j-1} = Q_j$$ $$P_j Q_j = Q_j P_j = I$$ $$P_j^T H P_j = D_j$$ $$Q_j^T D_j Q_j = H$$

$$H = \left( \begin{array}{rrrrrr} 10 & 3 & - 11 & 15 & 3 & 2 \\ 3 & 9 & - 15 & 0 & 0 & 6 \\ - 11 & - 15 & 29 & - 10 & - 2 & - 10 \\ 15 & 0 & - 10 & 25 & 5 & 0 \\ 3 & 0 & - 2 & 5 & 1 & 0 \\ 2 & 6 & - 10 & 0 & 0 & 4 \\ \end{array} \right)$$

==============================================

$$E_{1} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{1} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{1} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{1} = \left( \begin{array}{rrrrrr} 10 & 0 & - 11 & 15 & 3 & 2 \\ 0 & \frac{ 81 }{ 10 } & - \frac{ 117 }{ 10 } & - \frac{ 9 }{ 2 } & - \frac{ 9 }{ 10 } & \frac{ 27 }{ 5 } \\ - 11 & - \frac{ 117 }{ 10 } & 29 & - 10 & - 2 & - 10 \\ 15 & - \frac{ 9 }{ 2 } & - 10 & 25 & 5 & 0 \\ 3 & - \frac{ 9 }{ 10 } & - 2 & 5 & 1 & 0 \\ 2 & \frac{ 27 }{ 5 } & - 10 & 0 & 0 & 4 \\ \end{array} \right)$$

==============================================

$$E_{2} = \left( \begin{array}{rrrrrr} 1 & 0 & \frac{ 11 }{ 10 } & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{2} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 11 }{ 10 } & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{2} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{2} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 15 & 3 & 2 \\ 0 & \frac{ 81 }{ 10 } & - \frac{ 117 }{ 10 } & - \frac{ 9 }{ 2 } & - \frac{ 9 }{ 10 } & \frac{ 27 }{ 5 } \\ 0 & - \frac{ 117 }{ 10 } & \frac{ 169 }{ 10 } & \frac{ 13 }{ 2 } & \frac{ 13 }{ 10 } & - \frac{ 39 }{ 5 } \\ 15 & - \frac{ 9 }{ 2 } & \frac{ 13 }{ 2 } & 25 & 5 & 0 \\ 3 & - \frac{ 9 }{ 10 } & \frac{ 13 }{ 10 } & 5 & 1 & 0 \\ 2 & \frac{ 27 }{ 5 } & - \frac{ 39 }{ 5 } & 0 & 0 & 4 \\ \end{array} \right)$$

==============================================

$$E_{3} = \left( \begin{array}{rrrrrr} 1 & 0 & 0 & - \frac{ 3 }{ 2 } & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{3} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 11 }{ 10 } & - \frac{ 3 }{ 2 } & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{3} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{3} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 3 & 2 \\ 0 & \frac{ 81 }{ 10 } & - \frac{ 117 }{ 10 } & - \frac{ 9 }{ 2 } & - \frac{ 9 }{ 10 } & \frac{ 27 }{ 5 } \\ 0 & - \frac{ 117 }{ 10 } & \frac{ 169 }{ 10 } & \frac{ 13 }{ 2 } & \frac{ 13 }{ 10 } & - \frac{ 39 }{ 5 } \\ 0 & - \frac{ 9 }{ 2 } & \frac{ 13 }{ 2 } & \frac{ 5 }{ 2 } & \frac{ 1 }{ 2 } & - 3 \\ 3 & - \frac{ 9 }{ 10 } & \frac{ 13 }{ 10 } & \frac{ 1 }{ 2 } & 1 & 0 \\ 2 & \frac{ 27 }{ 5 } & - \frac{ 39 }{ 5 } & - 3 & 0 & 4 \\ \end{array} \right)$$

==============================================

$$E_{4} = \left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & - \frac{ 3 }{ 10 } & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{4} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 11 }{ 10 } & - \frac{ 3 }{ 2 } & - \frac{ 3 }{ 10 } & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{4} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{4} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 2 \\ 0 & \frac{ 81 }{ 10 } & - \frac{ 117 }{ 10 } & - \frac{ 9 }{ 2 } & - \frac{ 9 }{ 10 } & \frac{ 27 }{ 5 } \\ 0 & - \frac{ 117 }{ 10 } & \frac{ 169 }{ 10 } & \frac{ 13 }{ 2 } & \frac{ 13 }{ 10 } & - \frac{ 39 }{ 5 } \\ 0 & - \frac{ 9 }{ 2 } & \frac{ 13 }{ 2 } & \frac{ 5 }{ 2 } & \frac{ 1 }{ 2 } & - 3 \\ 0 & - \frac{ 9 }{ 10 } & \frac{ 13 }{ 10 } & \frac{ 1 }{ 2 } & \frac{ 1 }{ 10 } & - \frac{ 3 }{ 5 } \\ 2 & \frac{ 27 }{ 5 } & - \frac{ 39 }{ 5 } & - 3 & - \frac{ 3 }{ 5 } & 4 \\ \end{array} \right)$$

==============================================

$$E_{5} = \left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & - \frac{ 1 }{ 5 } \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{5} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 11 }{ 10 } & - \frac{ 3 }{ 2 } & - \frac{ 3 }{ 10 } & - \frac{ 1 }{ 5 } \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{5} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & \frac{ 1 }{ 5 } \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{5} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & - \frac{ 117 }{ 10 } & - \frac{ 9 }{ 2 } & - \frac{ 9 }{ 10 } & \frac{ 27 }{ 5 } \\ 0 & - \frac{ 117 }{ 10 } & \frac{ 169 }{ 10 } & \frac{ 13 }{ 2 } & \frac{ 13 }{ 10 } & - \frac{ 39 }{ 5 } \\ 0 & - \frac{ 9 }{ 2 } & \frac{ 13 }{ 2 } & \frac{ 5 }{ 2 } & \frac{ 1 }{ 2 } & - 3 \\ 0 & - \frac{ 9 }{ 10 } & \frac{ 13 }{ 10 } & \frac{ 1 }{ 2 } & \frac{ 1 }{ 10 } & - \frac{ 3 }{ 5 } \\ 0 & \frac{ 27 }{ 5 } & - \frac{ 39 }{ 5 } & - 3 & - \frac{ 3 }{ 5 } & \frac{ 18 }{ 5 } \\ \end{array} \right)$$

==============================================

$$E_{6} = \left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & \frac{ 13 }{ 9 } & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{6} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 2 }{ 3 } & - \frac{ 3 }{ 2 } & - \frac{ 3 }{ 10 } & - \frac{ 1 }{ 5 } \\ 0 & 1 & \frac{ 13 }{ 9 } & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{6} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & \frac{ 1 }{ 5 } \\ 0 & 1 & - \frac{ 13 }{ 9 } & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{6} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & - \frac{ 9 }{ 2 } & - \frac{ 9 }{ 10 } & \frac{ 27 }{ 5 } \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & - \frac{ 9 }{ 2 } & 0 & \frac{ 5 }{ 2 } & \frac{ 1 }{ 2 } & - 3 \\ 0 & - \frac{ 9 }{ 10 } & 0 & \frac{ 1 }{ 2 } & \frac{ 1 }{ 10 } & - \frac{ 3 }{ 5 } \\ 0 & \frac{ 27 }{ 5 } & 0 & - 3 & - \frac{ 3 }{ 5 } & \frac{ 18 }{ 5 } \\ \end{array} \right)$$

==============================================

$$E_{7} = \left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & \frac{ 5 }{ 9 } & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{7} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 2 }{ 3 } & - \frac{ 5 }{ 3 } & - \frac{ 3 }{ 10 } & - \frac{ 1 }{ 5 } \\ 0 & 1 & \frac{ 13 }{ 9 } & \frac{ 5 }{ 9 } & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{7} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & \frac{ 1 }{ 5 } \\ 0 & 1 & - \frac{ 13 }{ 9 } & - \frac{ 5 }{ 9 } & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{7} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & 0 & - \frac{ 9 }{ 10 } & \frac{ 27 }{ 5 } \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & - \frac{ 9 }{ 10 } & 0 & 0 & \frac{ 1 }{ 10 } & - \frac{ 3 }{ 5 } \\ 0 & \frac{ 27 }{ 5 } & 0 & 0 & - \frac{ 3 }{ 5 } & \frac{ 18 }{ 5 } \\ \end{array} \right)$$

==============================================

$$E_{8} = \left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & \frac{ 1 }{ 9 } & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{8} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 2 }{ 3 } & - \frac{ 5 }{ 3 } & - \frac{ 1 }{ 3 } & - \frac{ 1 }{ 5 } \\ 0 & 1 & \frac{ 13 }{ 9 } & \frac{ 5 }{ 9 } & \frac{ 1 }{ 9 } & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{8} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & \frac{ 1 }{ 5 } \\ 0 & 1 & - \frac{ 13 }{ 9 } & - \frac{ 5 }{ 9 } & - \frac{ 1 }{ 9 } & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{8} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & 0 & 0 & \frac{ 27 }{ 5 } \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 27 }{ 5 } & 0 & 0 & 0 & \frac{ 18 }{ 5 } \\ \end{array} \right)$$

==============================================

$$E_{9} = \left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & - \frac{ 2 }{ 3 } \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{9} = \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 2 }{ 3 } & - \frac{ 5 }{ 3 } & - \frac{ 1 }{ 3 } & 0 \\ 0 & 1 & \frac{ 13 }{ 9 } & \frac{ 5 }{ 9 } & \frac{ 1 }{ 9 } & - \frac{ 2 }{ 3 } \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{9} = \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & \frac{ 1 }{ 5 } \\ 0 & 1 & - \frac{ 13 }{ 9 } & - \frac{ 5 }{ 9 } & - \frac{ 1 }{ 9 } & \frac{ 2 }{ 3 } \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{9} = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ \end{array} \right)$$

==============================================

$$P^T H P = D$$ $$\left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ - \frac{ 3 }{ 10 } & 1 & 0 & 0 & 0 & 0 \\ \frac{ 2 }{ 3 } & \frac{ 13 }{ 9 } & 1 & 0 & 0 & 0 \\ - \frac{ 5 }{ 3 } & \frac{ 5 }{ 9 } & 0 & 1 & 0 & 0 \\ - \frac{ 1 }{ 3 } & \frac{ 1 }{ 9 } & 0 & 0 & 1 & 0 \\ 0 & - \frac{ 2 }{ 3 } & 0 & 0 & 0 & 1 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 10 & 3 & - 11 & 15 & 3 & 2 \\ 3 & 9 & - 15 & 0 & 0 & 6 \\ - 11 & - 15 & 29 & - 10 & - 2 & - 10 \\ 15 & 0 & - 10 & 25 & 5 & 0 \\ 3 & 0 & - 2 & 5 & 1 & 0 \\ 2 & 6 & - 10 & 0 & 0 & 4 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 1 & - \frac{ 3 }{ 10 } & \frac{ 2 }{ 3 } & - \frac{ 5 }{ 3 } & - \frac{ 1 }{ 3 } & 0 \\ 0 & 1 & \frac{ 13 }{ 9 } & \frac{ 5 }{ 9 } & \frac{ 1 }{ 9 } & - \frac{ 2 }{ 3 } \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ \end{array} \right)$$ $$Q^T D Q = H$$ $$\left( \begin{array}{rrrrrr} 1 & 0 & 0 & 0 & 0 & 0 \\ \frac{ 3 }{ 10 } & 1 & 0 & 0 & 0 & 0 \\ - \frac{ 11 }{ 10 } & - \frac{ 13 }{ 9 } & 1 & 0 & 0 & 0 \\ \frac{ 3 }{ 2 } & - \frac{ 5 }{ 9 } & 0 & 1 & 0 & 0 \\ \frac{ 3 }{ 10 } & - \frac{ 1 }{ 9 } & 0 & 0 & 1 & 0 \\ \frac{ 1 }{ 5 } & \frac{ 2 }{ 3 } & 0 & 0 & 0 & 1 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 10 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{ 81 }{ 10 } & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ \end{array} \right) \left( \begin{array}{rrrrrr} 1 & \frac{ 3 }{ 10 } & - \frac{ 11 }{ 10 } & \frac{ 3 }{ 2 } & \frac{ 3 }{ 10 } & \frac{ 1 }{ 5 } \\ 0 & 1 & - \frac{ 13 }{ 9 } & - \frac{ 5 }{ 9 } & - \frac{ 1 }{ 9 } & \frac{ 2 }{ 3 } \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right) = \left( \begin{array}{rrrrrr} 10 & 3 & - 11 & 15 & 3 & 2 \\ 3 & 9 & - 15 & 0 & 0 & 6 \\ - 11 & - 15 & 29 & - 10 & - 2 & - 10 \\ 15 & 0 & - 10 & 25 & 5 & 0 \\ 3 & 0 & - 2 & 5 & 1 & 0 \\ 2 & 6 & - 10 & 0 & 0 & 4 \\ \end{array} \right)$$