Symmetric matrix congruency There is a sentense that says that every symmetric matrix is congruent to a diagonal matrix.
I've been trying to find the congruent matrix and the transition matrix for the following:
$$
\begin{pmatrix}
  1 & 0 & 0 & 0 \\
  0 & 0 & 1 & 0 \\
  0 & 1 & 0 & 0 \\
  0 & 0 & 0 & 1
\end{pmatrix}
$$
The method I learned to get to a solution is to do row operations on both the matrix and the identity matrix, and the according column operations on the original matrix only until I get  to a diagonal matrix from the original and the transition matrix from the identity matrix.
This process seems to loop infinitly in with this matrix when I switch rows 2 and 3.
So I need to know how to find the congruent diagonal matrix and the transition matrix for the given matrix and a method which will be fail-proof.
 A: A fool proof algorithm :)
1) Find the eigenvalues. The eigenvalues are the roots of the polynomial $det(A-\lambda I)$
The eigenvalues are also the values that you will see on the diagonal.
2) Find the eigenvectors, and insert them as columns of a matrix named $P$.
Edit: in your case, since the matrix is symmetric, not only will you find a basis of eigenvectors, you will find an orthonormal basis of eigenvectors.
3) check that $P^{-1}AP = D$ where $D$ is a diagonal matrix with the eigenvalues on the diagonal.
A: Rather than switching the columns, add the third row to the second, and work from there.
I am not familiar with the algorithm you describe, and so I can't tell you why switch the rows would cause it to fail.  However, you should find that
$$
P = \pmatrix{1&0&0&0\\
0&1&1&0\\
0&1&-1&0\\
0&0&0&1}
$$
will work for your purposes (incidentally, note that $P = P^T$).
In terms of row-column operations, here's how it would go:
$$
\pmatrix{1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1} \quad \text{...II = II + III}\\
\pmatrix{
1&0&0&0\\
0&2&1&0\\
0&1&0&0\\
0&0&0&1} \quad \text{...III= 2 III - II}\\
\pmatrix{
1&0&0&0\\
0&2&0&0\\
0&0&-2&0\\
0&0&0&1} 
$$
I'm not sure if this is correct
