<s>[INST] Symmetric matrix (completing the square/diagonal form) Let $A=\begin{pmatrix} 0 & -2 & 1 \\ -2 & 1 & 2 \\ 1 & 2 & 0 \end{pmatrix} \in M_3(\mathbb{R})$.
I want to find an invertible matrix $C$ such that $C^TAC=\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & -1 \end{pmatrix}$, since there are three eigenvalues, two of them are positive, one is negative.
I want to use completing the square with the bilinear form $s(v,v)=\langle v,Av \rangle$:
$s(v,v)= \langle v,Av \rangle=(v_1,v_2,v_3)\begin{pmatrix} 0 & -2 & 1 \\ -2 & 1 & 2 \\ 1 & 2 & 0 \end{pmatrix}\begin{pmatrix} v_1\\v_2\\v_3 \end{pmatrix}=-4v_1v_2+2v_1v_3+v_2^2+4v_2v_3$
Now I tried to use the formula $ax^2+bx=a(x+\frac{b}{2a})^2-\frac{b^2}{2a}$, but there is no $v_1^2$.
So I started with $v_2^2$:
$s(v,v)=(v_2+2v_3)^2-4v_1v_2+2v_1v_3-4v_3^2$
Here I don't see how to use completing the square again with $-4v_1v_2+2v_1v_3$, since $v_1^2$ is not available. Is there a method how to continue?
 [/INST] Perhaps not what you're looking for but we can diagonalize the symmetric matrix $A$ as
$$P^TAP =\begin{pmatrix}
 -\frac{1}{\sqrt{3}} & -\frac{1}{\sqrt{6}} & \frac{1}{\sqrt{2}} \\
 -\frac{1}{\sqrt{3}} & \frac{2}{\sqrt{6}} & 0 \\
 \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{6}} & \frac{1}{\sqrt{2}} \\
\end{pmatrix} \begin{pmatrix} 0 & -2 & 1 \\ -2 & 1 & 2 \\ 1 & 2 & 0 \end{pmatrix}\begin{pmatrix}
 -\frac{1}{\sqrt{3}} & -\frac{1}{\sqrt{3}} & \frac{1}{\sqrt{3}} \\
 -\frac{1}{\sqrt{6}} & \frac{2}{\sqrt{6}} & \frac{1}{\sqrt{6}} \\
 \frac{1}{\sqrt{2}} & 0 & \frac{1}{\sqrt{2}} \\
\end{pmatrix}= \begin{pmatrix} -3 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 1 \end{pmatrix}$$
so for $u = P^Tv$ we have
$$\langle Av,v\rangle = \langle A(Pu),(Pu)\rangle = \langle P^TAPu,u\rangle = -3u_1^2+3u_2^2+u_3^2$$
This turns out to be 
\begin{align}
\langle Av,v\rangle &= -3 \left(-\frac{v_1}{\sqrt{3}} - \frac{v_2}{\sqrt{3}} + \frac{v_3}{\sqrt{3}}\right)^2 + 
 3 \left(-\frac{v_1}{\sqrt{6}} + \sqrt{\frac23}v_2 + \frac{v_3}{\sqrt{6}}\right)^2 +\left(\frac{v_1}{\sqrt{2}} + \frac{v_3}{\sqrt{2}}\right)^2\\
&= \left(-\frac{v_1}{\sqrt{2}} + \sqrt{2}v_2 + \frac{v_3}{\sqrt{2}}\right)^2+ \left(\frac{v_1}{\sqrt{2}} + \frac{v_3}{\sqrt{2}}\right)^2-(-v_1-v_2+v_3)^2\\
\end{align}
</s>