# reference for linear algebra books that teach reverse Hermite method for symmetric matrices

May 11, 2019. Evidently the original method should be attributed to Lagrange in 1759. I got confused, Hermite is much more recent.

January 13, 2016: book that does this mentioned in a question today, Linear Algebra Done Wrong by Sergei Treil. He calls it non-orthogonal diagonalization of a quadratic form, calls his first method completion of squares, pages 201-202, section 2.2.1. In section 2.2.2, pages 202-205, he describes this method, calling it Diagonalization using row/column operations.

The method I mean is useful for symmetric matrices with integer, or at least rational entries. It diagonalizes but does NOT orthogonally diagonalize. The direction I do it, I usually call it Hermite reduction or Hermite's method. At the end, I need to find the inverse of my matrix (which usually has determinant one so it is not so bad). This other method produces an answer directly, a cookbook method not conceptually different from row reduction of matrices, especially using that to find its inverse. This method is very similar to Gauss reduction for positive binary quadratic forms, just allowing rational coefficients in the elementary matrices used; Gauss stuck with integers.

The method is mostly Gauss reduction, intended for binary positive forms. We deal with two variables (row/column pairs) at a time. As long as one of the two diagonal entries is nonzero there is no trouble, no choices to be made. We start with a symmetric matrix $$A_0.$$ At each step, call it step $$n,$$ we are going to use some elementary matrix $$E_n,$$ same as in row reduction, such that $$A_n =E_n^T A_{n-1} E_n$$ has one fewer pair of off-diagonal nonzero entries. We also began with $$P_0=I,$$ then each step we take $$P_n=P_{n-1}E_n.$$ Eventually we get to some $$n=N$$ such that $$A_N=D$$ is diagonal and $$P_N=P,$$ with $$P^T A P = D$$ by construction. Oh, also by construction, $$P$$ has determinant $$1.$$

I JUST PUT AN EXAMPLE AT Find the transitional matrix that would transform this form to a diagonal form. not yet typeset, it is input and output from gp-pari and should not be too difficult to read, indeed one may copy the individual commands into pari and see how it progresses. I also put a 4 by 4 answer, the final answer typeset otherwise gp-pari output, at Given a $4\times 4$ symmetric matrix, is there an efficient way to find its eigenvalues and diagonalize it?

Let me go through the two examples, the second involves a choice because we get a zero diagonal element at one point.

First:

Let $$A = \left(\begin{array}{cc} 2&3 \\ 3&4 \end{array}\right) \in M_n(\mathbb{C})$$

Find $$P$$ such that $$P^TAP = D$$ where $$D$$ is a diagonal matrix.

So here's the solution:

$$A = \left(\begin{array}{cc|cc} 2&3&1&0\\ 3&4&0&1 \end{array}\right) \sim \left(\begin{array}{cc|cc} 2&0&1&-3/2\\ 0&-1/2&0&1 \end{array}\right)$$

Therefore, $$P = \left(\begin{array}{cc} 1&-3/2\\ 0&1 \end{array}\right) \\ P^TAP = \left(\begin{array}{cc} 2&0\\ 0&-1/2 \end{array}\right)$$

So, this one was just Gauss reduction, allowing a rational off-diagonal entry in my $$E_1$$ in order to force the $$1,2$$ and $$2,1$$ pair of positions to become zero. As long as the upper left of the two diagonal coefficients is nonzero, we may take our $$E_n$$ to be upper triangular. If we are faced with a zero diagonal entry in the first row/diagonal that possesses any nonzero (therefore off-diagonal) entries, we need to do an extra step to force a nonzero diagonal element.

So, let's do the ever popular form $$2xy$$ this way. $$A = A_0 = \left( \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right)$$ As both diagonal entries are zero, switching row/columns 1 and 2 will still give $$0$$ in the 1,1 position. We do not like that. Instead, we take a lower triangular $$E_n,$$ here $$E_1 = \left( \begin{array}{cc} 1 & 0 \\ 1 & 1 \end{array} \right)$$

The way i am numbering the matrices, this gives $$A_1 = E_1^T A E_1 = \left( \begin{array}{cc} 2 & 1 \\ 1 & 0 \end{array} \right),$$ also $$P_1 = E_1.$$ Next, we go back to the more common upper triangular elementary matrices, with $$E_2 = \left( \begin{array}{cc} 1 & -\frac{1}{2} \\ 0 & 1 \end{array} \right).$$

$$D= A_2 = E_2^T A_1 E_2 = \left( \begin{array}{cc} 2 & 0 \\ 0 & -\frac{1}{2} \end{array} \right),$$ also

$$P = P_2 = P_1 E_2 = E_1 E_2 = \left( \begin{array}{cc} 1 & -\frac{1}{2} \\ 1 & \frac{1}{2} \end{array} \right),$$

Note that, from $$A_1 = E_1^T A E_1$$ and $$D= A_2 = E_2^T A_1 E_2$$ we indeed have $$\color{red}{ D= A_2 = E_2^T (E_1^T A E_1) E_2 = E_2^T E_1^T A E_1 E_2 = (E_1 E_2)^T A (E_1 E_2)}$$ which is why $$P = E_1 E_2.$$

The solution manual that has this would use "augmented" matrices, 4 by 2, not record the individual $$E_i,$$ just the $$A_i$$ augmented by $$P_i.$$ At least, given how I am numbering things, this is how I prefer to write such a summary, it may be slightly different for the examples in the other question:

$$(A_0|P_0) = \left(\begin{array}{cc|cc} 0&1&1&0\\ 1&0&0&1 \end{array}\right)$$ $$\mapsto (A_1|P_1) = \left(\begin{array}{cc|cc} 2&1&1&0\\ 1&0&1&1 \end{array}\right)$$ $$\mapsto (A_2|P_2) = \left(\begin{array}{cc|cc} 2&0&1&-\frac{1}{2}\\ 0&-\frac{1}{2}&1&\frac{1}{2} \end{array}\right)$$ I have been seeing this method lately, but do not know any book that teaches it (or in what language). It would appear to be a book about matrix theory or linear algebra, and may never mention quadratic forms, hard to predict. Or, it may do quadratic forms over the reals, as is pretty common, and ignore the case of integer coefficients. I suspect nobody on MSE has taught this method, perhaps it is a recent book.

Here are recent occurrences, apparently two by the same guy, then two by another person. To find others, look for my answers that use the phrase Hermite reduction. One of the latter is answered my way, just called repeated completing the square, which is exactly right.

Finding $P$ such that $P^TAP$ is a diagonal matrix

Diagonalize a symmetric matrix

Find the transitional matrix that would transform this form to a diagonal form.

diagonal matrix A

Very similar to the method in a Schaum's outline as seen in this answer: Given a $4\times 4$ symmetric matrix, is there an efficient way to find its eigenvalues and diagonalize it?

Indeed, here is the image uploaded by el.Salvador there:

• Certainly the integer-arithmetic Hermite normal form, which does not respect symmetry, is better known. – hardmath Aug 8 '15 at 11:16
• @hardmath, yes, if i am doing a row reduction by hand and the matrix is all integers, I stick with all integers. Makes me wonder whether there might be a mention in Newman's Integral Matrices. – Will Jagy Aug 8 '15 at 20:42
• could it be the algorithm I mention in this answer? – etothepitimesi Aug 9 '15 at 23:35
• @el.Salvador, I think it is, with the exception that they insist on talking about row operations, pivots, and so forth, in effect I think they keep multiplying on the left by $E_n^T,$ with the result that they get $P^T$ – Will Jagy Aug 9 '15 at 23:52

You can find a description of a very similar method in "Schaum's Outline of Linear Algebra", by Lipschutz and Lipson.

In the first edition, which is freely available, it's introduced in exercise 12.9 (page 270). In the third edition, it's introduced as Algorithm 12.1 (page 370); you can find it in this answer.

After some more research, I found another similar algorithm in "Schaum's Outline of Matrix Operations", by Bronson, on page 145 (Chapter 16).

• Today this link worked, about half a page with little detail, also they insist on diagonal elements $0,\pm 1$ books.google.co.il/…^TAP+Diagonal+row+reduce&source=bl&ots=wV5z7XiV2o&sig=CeasZfxZhnWNj1DlE2JYGXHftFY&hl=en&sa=X&ved=0CCwQ6AEwBGoVChMIyNPljpiLxwIVA24UCh0Olg5V#v=onepage&q=P^TAP%20Diagonal%20row%20reduce&f=false – Will Jagy Aug 10 '15 at 0:32
• I finally typeset the 3 by 3 example from the earlier question, just finished that as a new answer. Easier for me to read this way, although I can see how lots of practice would eventually make the $(A|P)$ typesetting style appealing and workable. – Will Jagy Aug 10 '15 at 17:36
• @WillJagy, the method definitely looks nicer and clearer the way you present it. However, when you consider doing it on a piece of paper, you rapidly realize that the expanded matrix is very convenient. I've gone through my book collection and found another similar algorithm (curiously, in another Schaum's Outline book, but from a different author). I've uploaded the respective chapter here. – etothepitimesi Aug 10 '15 at 22:36
• el.Salvador, thanks. After finally doing the 3 by 3 example myself, I can see how, with practice, one could learn to do without writing out each of the elementary matrices i am calling $E_n.$ If I were teaching someone new, I would want to write everything out for them, at least once. – Will Jagy Aug 10 '15 at 22:39
• el.S, I noticed that you uploaded a chapter, and I just downloaded it. Thank you. I think I will go back to the bookstore today, I do not believe they many new Schaum's outlines but i think they have a number of used ones, maybe they have either Bronson or Lipschutz and Lipson, seems the 3rd, 4th, 5th editions are something like years 2000, 2008, 2012, with some confusing changes of title, but fine if I can see the actual book contents before buying. – Will Jagy Aug 11 '15 at 17:00

I think I have the energy today to fill in the details of this png image of a calculation

from this question: Finding $P$ such that $P^TAP$ is a diagonal matrix

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

$$P^T H P = D$$ $$\left( \begin{array}{rrr} 1 & 0 & 0 \\ - 4 & 1 & 1 \\ 0 & - \frac{ 1 }{ 2 } & \frac{ 1 }{ 2 } \\ \end{array} \right) \left( \begin{array}{rrr} 1 & 2 & 2 \\ 2 & 4 & 8 \\ 2 & 8 & 4 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & - 4 & 0 \\ 0 & 1 & - \frac{ 1 }{ 2 } \\ 0 & 1 & \frac{ 1 }{ 2 } \\ \end{array} \right) = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 8 & 0 \\ 0 & 0 & - 2 \\ \end{array} \right)$$ $$Q^T D Q = H$$ $$\left( \begin{array}{rrr} 1 & 0 & 0 \\ 2 & \frac{ 1 }{ 2 } & - 1 \\ 2 & \frac{ 1 }{ 2 } & 1 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 8 & 0 \\ 0 & 0 & - 2 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & 2 & 2 \\ 0 & \frac{ 1 }{ 2 } & \frac{ 1 }{ 2 } \\ 0 & - 1 & 1 \\ \end{array} \right) = \left( \begin{array}{rrr} 1 & 2 & 2 \\ 2 & 4 & 8 \\ 2 & 8 & 4 \\ \end{array} \right)$$

$$H = \left( \begin{array}{rrr} 1 & 2 & 2 \\ 2 & 4 & 8 \\ 2 & 8 & 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}{rrr} 1 & 2 & 2 \\ 2 & 4 & 8 \\ 2 & 8 & 4 \\ \end{array} \right)$$

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

$$E_{1} = \left( \begin{array}{rrr} 1 & - 2 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{1} = \left( \begin{array}{rrr} 1 & - 2 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{1} = \left( \begin{array}{rrr} 1 & 2 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{1} = \left( \begin{array}{rrr} 1 & 0 & 2 \\ 0 & 0 & 4 \\ 2 & 4 & 4 \\ \end{array} \right)$$

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

$$E_{2} = \left( \begin{array}{rrr} 1 & 0 & - 2 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{2} = \left( \begin{array}{rrr} 1 & - 2 & - 2 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{2} = \left( \begin{array}{rrr} 1 & 2 & 2 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{2} = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 0 & 4 \\ 0 & 4 & 0 \\ \end{array} \right)$$

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

$$E_{3} = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 1 & 1 \\ \end{array} \right)$$ $$P_{3} = \left( \begin{array}{rrr} 1 & - 4 & - 2 \\ 0 & 1 & 0 \\ 0 & 1 & 1 \\ \end{array} \right) , \; \; \; Q_{3} = \left( \begin{array}{rrr} 1 & 2 & 2 \\ 0 & 1 & 0 \\ 0 & - 1 & 1 \\ \end{array} \right) , \; \; \; D_{3} = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 8 & 4 \\ 0 & 4 & 0 \\ \end{array} \right)$$

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

$$E_{4} = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 1 & - \frac{ 1 }{ 2 } \\ 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{4} = \left( \begin{array}{rrr} 1 & - 4 & 0 \\ 0 & 1 & - \frac{ 1 }{ 2 } \\ 0 & 1 & \frac{ 1 }{ 2 } \\ \end{array} \right) , \; \; \; Q_{4} = \left( \begin{array}{rrr} 1 & 2 & 2 \\ 0 & \frac{ 1 }{ 2 } & \frac{ 1 }{ 2 } \\ 0 & - 1 & 1 \\ \end{array} \right) , \; \; \; D_{4} = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 8 & 0 \\ 0 & 0 & - 2 \\ \end{array} \right)$$

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

$$P^T H P = D$$ $$\left( \begin{array}{rrr} 1 & 0 & 0 \\ - 4 & 1 & 1 \\ 0 & - \frac{ 1 }{ 2 } & \frac{ 1 }{ 2 } \\ \end{array} \right) \left( \begin{array}{rrr} 1 & 2 & 2 \\ 2 & 4 & 8 \\ 2 & 8 & 4 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & - 4 & 0 \\ 0 & 1 & - \frac{ 1 }{ 2 } \\ 0 & 1 & \frac{ 1 }{ 2 } \\ \end{array} \right) = \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 8 & 0 \\ 0 & 0 & - 2 \\ \end{array} \right)$$ $$Q^T D Q = H$$ $$\left( \begin{array}{rrr} 1 & 0 & 0 \\ 2 & \frac{ 1 }{ 2 } & - 1 \\ 2 & \frac{ 1 }{ 2 } & 1 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & 0 & 0 \\ 0 & 8 & 0 \\ 0 & 0 & - 2 \\ \end{array} \right) \left( \begin{array}{rrr} 1 & 2 & 2 \\ 0 & \frac{ 1 }{ 2 } & \frac{ 1 }{ 2 } \\ 0 & - 1 & 1 \\ \end{array} \right) = \left( \begin{array}{rrr} 1 & 2 & 2 \\ 2 & 4 & 8 \\ 2 & 8 & 4 \\ \end{array} \right)$$

I actually just read this in Shilov's Linear Algebra (Dover edition) while reviewing for my prelims. He handles this at the beginning of chapter 7; he states it as a theorem about finding a canonical basis for quadratic forms, but since those are the same as symmetric bilinear forms in characteristic$\neq 2$, and since the matrix of a bilinear form transforms as $A\mapsto P^t AP$, that is exactly the theorem you're looking for.

• Thank you. My local bookstore has Dover mathematics. – Will Jagy Aug 8 '15 at 20:25
• Looked through it, he does prove it, but when he does an example with integer coefficients he does it the way I always write it, an invertible matrix $Q$ and a diagonal matrix $D$ such that $Q^T D Q = A.$ So, to solve $P^T A P = D,$ I need to invert the $Q$ I find. Someone, possibly a website, is teaching kids who do not know very much to find $P$ without doing a matrix inverse at the end. Let me see which of the sample questions I included shows that best... this , see the squares side-by-side math.stackexchange.com/questions/1382288/… – Will Jagy Aug 8 '15 at 22:40
• Sorry, what are you referring to in the link you gave? So, in looking for canonical form, we're looking for a change of basis matrix $P$, so that $P^tAP$ is diagonal. When you complete squares, what you have now is how the coordinates of vectors transform under $P$. But we know that if $e_i\mapsto Pe_i$, i.e. if $P$ is the change of basis matrix, then coordinate vectors change as $v\mapsto P^{-1}v$. So the matrix $Q$ you get from how the coordinates change is the inverse of $P$. That's why the above is true, and why you're going to need to take an inverse somewhere in the procedure. – user59193 Aug 9 '15 at 7:16
• Seems to be the, except for some ordering and transposes, the method in this answer math.stackexchange.com/questions/395634/… – Will Jagy Aug 10 '15 at 0:01

a problem posted today: Diagonalizing Quadratic forms with aii = 0

$$H = \left( \begin{array}{rrrr} 3 & - 6 & 0 & 0 \\ - 6 & 12 & 0 & 8 \\ 0 & 0 & 0 & 0 \\ 0 & 8 & 0 & 0 \\ \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}{rrrr} 3 & - 6 & 0 & 0 \\ - 6 & 12 & 0 & 8 \\ 0 & 0 & 0 & 0 \\ 0 & 8 & 0 & 0 \\ \end{array} \right)$$

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

$$E_{1} = \left( \begin{array}{rrrr} 1 & 2 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{1} = \left( \begin{array}{rrrr} 1 & 2 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{1} = \left( \begin{array}{rrrr} 1 & - 2 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{1} = \left( \begin{array}{rrrr} 3 & 0 & 0 & 0 \\ 0 & 0 & 0 & 8 \\ 0 & 0 & 0 & 0 \\ 0 & 8 & 0 & 0 \\ \end{array} \right)$$

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

$$E_{2} = \left( \begin{array}{rrrr} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ \end{array} \right)$$ $$P_{2} = \left( \begin{array}{rrrr} 1 & 2 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ \end{array} \right) , \; \; \; Q_{2} = \left( \begin{array}{rrrr} 1 & - 2 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & - 1 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{2} = \left( \begin{array}{rrrr} 3 & 0 & 0 & 0 \\ 0 & 16 & 0 & 8 \\ 0 & 0 & 0 & 0 \\ 0 & 8 & 0 & 0 \\ \end{array} \right)$$

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

$$E_{3} = \left( \begin{array}{rrrr} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & - \frac{ 1 }{ 2 } \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{array} \right)$$ $$P_{3} = \left( \begin{array}{rrrr} 1 & 2 & 0 & - 1 \\ 0 & 1 & 0 & - \frac{ 1 }{ 2 } \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & \frac{ 1 }{ 2 } \\ \end{array} \right) , \; \; \; Q_{3} = \left( \begin{array}{rrrr} 1 & - 2 & 0 & 0 \\ 0 & \frac{ 1 }{ 2 } & 0 & \frac{ 1 }{ 2 } \\ 0 & 0 & 1 & 0 \\ 0 & - 1 & 0 & 1 \\ \end{array} \right) , \; \; \; D_{3} = \left( \begin{array}{rrrr} 3 & 0 & 0 & 0 \\ 0 & 16 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & - 4 \\ \end{array} \right)$$

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

$$E_{4} = \left( \begin{array}{rrrr} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{array} \right)$$ $$P_{4} = \left( \begin{array}{rrrr} 1 & 2 & - 1 & 0 \\ 0 & 1 & - \frac{ 1 }{ 2 } & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & \frac{ 1 }{ 2 } & 0 \\ \end{array} \right) , \; \; \; Q_{4} = \left( \begin{array}{rrrr} 1 & - 2 & 0 & 0 \\ 0 & \frac{ 1 }{ 2 } & 0 & \frac{ 1 }{ 2 } \\ 0 & - 1 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{array} \right) , \; \; \; D_{4} = \left( \begin{array}{rrrr} 3 & 0 & 0 & 0 \\ 0 & 16 & 0 & 0 \\ 0 & 0 & - 4 & 0 \\ 0 & 0 & 0 & 0 \\ \end{array} \right)$$

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

$$P^T H P = D$$ $$\left( \begin{array}{rrrr} 1 & 0 & 0 & 0 \\ 2 & 1 & 0 & 1 \\ - 1 & - \frac{ 1 }{ 2 } & 0 & \frac{ 1 }{ 2 } \\ 0 & 0 & 1 & 0 \\ \end{array} \right) \left( \begin{array}{rrrr} 3 & - 6 & 0 & 0 \\ - 6 & 12 & 0 & 8 \\ 0 & 0 & 0 & 0 \\ 0 & 8 & 0 & 0 \\ \end{array} \right) \left( \begin{array}{rrrr} 1 & 2 & - 1 & 0 \\ 0 & 1 & - \frac{ 1 }{ 2 } & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & \frac{ 1 }{ 2 } & 0 \\ \end{array} \right) = \left( \begin{array}{rrrr} 3 & 0 & 0 & 0 \\ 0 & 16 & 0 & 0 \\ 0 & 0 & - 4 & 0 \\ 0 & 0 & 0 & 0 \\ \end{array} \right)$$ $$Q^T D Q = H$$ $$\left( \begin{array}{rrrr} 1 & 0 & 0 & 0 \\ - 2 & \frac{ 1 }{ 2 } & - 1 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & \frac{ 1 }{ 2 } & 1 & 0 \\ \end{array} \right) \left( \begin{array}{rrrr} 3 & 0 & 0 & 0 \\ 0 & 16 & 0 & 0 \\ 0 & 0 & - 4 & 0 \\ 0 & 0 & 0 & 0 \\ \end{array} \right) \left( \begin{array}{rrrr} 1 & - 2 & 0 & 0 \\ 0 & \frac{ 1 }{ 2 } & 0 & \frac{ 1 }{ 2 } \\ 0 & - 1 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{array} \right) = \left( \begin{array}{rrrr} 3 & - 6 & 0 & 0 \\ - 6 & 12 & 0 & 8 \\ 0 & 0 & 0 & 0 \\ 0 & 8 & 0 & 0 \\ \end{array} \right)$$