Find invertible matrix $Q$ From the book "Bilinear forms and their matrices" by Prof. Joel Kamnitzer:

Consider: $$ A=\pmatrix{0 & 4 \\ 4 & 2} $$
  After doing simultaneous row and column operations we reach:
  $$ Q^tAQ= \pmatrix{-8 & 0 \\ 0 & 2} $$

And then he implies that $ Q= \pmatrix{1 & 0 \\ -2 & 1 }$ , which indeed verifies the result, but I do not know how he found that matrix. So I found the post "How to diagonalize a matrix" and tried to follow those steps. However the eigenvalues I found involve $\sqrt{17}$, and that number does not go away once I try to diagonlize the matrix. So I must be doing something wrong.
So, how can one find Q? A general solution is of course welcome too.
 A: Let $R_1, R_2$ be the first and second row, $C_1, C_2$ be the first and second column.
Then to get to diagonal form take $R_1-2R_2$ then we get the martix $$\begin{bmatrix} -8 & 0 \\
4 & 2
\end{bmatrix}.$$
Now since we are doing simulataneous row and column transformations we need to take $C_{1}-2C_{2}$. This yields the matrix $$\begin{bmatrix} -8 & 0 \\
0 & 2
\end{bmatrix}.$$
The elementary matrix that represents $C_{1}-2C_{2}$ is exactly $$Q=\begin{bmatrix} 1 & 0 \\
-2 & 1
\end{bmatrix}.$$
Similarly $$Q^{T}=\begin{bmatrix} 1 & -2 \\
0 & 1
\end{bmatrix}$$
represents $R_{1}-2R_{2}$. Hence we get $Q^{T}AQ=\begin{bmatrix} -8 & 0 \\
0 & 2
\end{bmatrix}.$
In general right multiplication by an elementary matrix is equivalent to column operations and left multiplications is row operations and since we are doing simultaneous reduction the left and right matrices are just transposes of each other.
A: 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}{rr} 
0 & 4 \\ 
4 & 2 \\ 
\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}{rr} 
0 & 4 \\ 
4 & 2 \\ 
\end{array}
\right) 
$$
==============================================
$$ E_{1} = \left( 
\begin{array}{rr} 
0 & 1 \\ 
1 & 0 \\ 
\end{array}
\right) 
$$
$$  P_{1} = \left( 
\begin{array}{rr} 
0 & 1 \\ 
1 & 0 \\ 
\end{array}
\right) 
, \; \; \; Q_{1} = \left( 
\begin{array}{rr} 
0 & 1 \\ 
1 & 0 \\ 
\end{array}
\right) 
, \; \; \; D_{1} = \left( 
\begin{array}{rr} 
2 & 4 \\ 
4 & 0 \\ 
\end{array}
\right) 
$$
==============================================
$$ E_{2} = \left( 
\begin{array}{rr} 
1 &  - 2 \\ 
0 & 1 \\ 
\end{array}
\right) 
$$
$$  P_{2} = \left( 
\begin{array}{rr} 
0 & 1 \\ 
1 &  - 2 \\ 
\end{array}
\right) 
, \; \; \; Q_{2} = \left( 
\begin{array}{rr} 
2 & 1 \\ 
1 & 0 \\ 
\end{array}
\right) 
, \; \; \; D_{2} = \left( 
\begin{array}{rr} 
2 & 0 \\ 
0 &  - 8 \\ 
\end{array}
\right) 
$$
==============================================
$$ P^T H P = D  $$
$$\left( 
\begin{array}{rr} 
0 & 1 \\ 
1 &  - 2 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rr} 
0 & 4 \\ 
4 & 2 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rr} 
0 & 1 \\ 
1 &  - 2 \\ 
\end{array}
\right) 
 = \left( 
\begin{array}{rr} 
2 & 0 \\ 
0 &  - 8 \\ 
\end{array}
\right) 
$$
$$ Q^T D Q = H  $$
$$\left( 
\begin{array}{rr} 
2 & 1 \\ 
1 & 0 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rr} 
2 & 0 \\ 
0 &  - 8 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rr} 
2 & 1 \\ 
1 & 0 \\ 
\end{array}
\right) 
 = \left( 
\begin{array}{rr} 
0 & 4 \\ 
4 & 2 \\ 
\end{array}
\right) 
$$
..............
