Problem: For $X, Y \in \mathbf{R}^{3}$, and for the matrix $$ A=\left(\begin{array}{lll} 1 & a & 1 \\ a & 0 & 0 \\ 1 & 0 & 1 \end{array}\right) $$ we define the bilinear form $f(X, Y)=X^{t} A Y$. Determine for what values of $a \in \mathbf{R}$, the rank of the form is 3 , and for those values determine the signature of $f$.
Attempt: Clearly $ a\neq 0 $ since otherwise we'd have $ rank(A) \leq 2 $. Hence, applying Algorithm for Congruence Diagonalization of Symmetric matrix on $ A $ to find a non singular matrix $ P $ such that $ D = P^TAP $ is diagonal.
First form the block matrix $ M = [A,I] $; that is, let
$M=[A, I]=\left[\begin{array}{rrr:rrr} 1 & a & 1 & 1 & 0 & 0 \\ a & 0 & 0 & 0 & 1 & 0 \\ 1 & 0 & 1 & 0 & 0 & 1\end{array}\right]$.
Apply the row operations "Replace $ R_2 $ by $ -a_{21}R_1+a_{11}R_2 = -aR_1 + R_2 $ " and "Replace $ R_3 $ by $ -a_{31}R_1+a_{11}R_3 = -R_1 + R_3 $ " to $M$, and then apply the corresponding column operations " Replace $ C_2 $ by $ -aC_1 + C_2 $ " and "Replace $ C_3 $ by $-a_{21}C_1+a_{11}C_2 = -C_1+ C_3 $ " to obtain
$ \left[\begin{array}{rrr:rrr} 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & -a^2 & -a & -a & 1 & 0 \\ 0 & -a & 0 & -1 & 0 & 1\end{array}\right]$.
( I think so far's correct since $\left(\begin{array}{ccc}1 & 0 & 0 \\ -a & 1 & 0 \\ -1 & 0 & 1\end{array}\right)\left(\begin{array}{lll}1 & a & 1 \\ a & 0 & 0 \\ 1 & 0 & 1\end{array}\right)\left(\begin{array}{ccc}1 & -a & -1 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{array}\right) $ $ = \left(\begin{array}{ccc}1 & 0 & 0 \\ 0 & -a^2 & -a \\ 0 & -a & 0\end{array}\right) $ ). [ Now's the part where I think there's a problem: ]
Next, Apply the row operation " Replace $R_3$ by $ -a_{32}R_2+a_{22}R_3 = aR_2 - a^2R_3 $ " and " Replace $C_3$ by $ -a_{32}C_2+a_{22}C_3 = aC_2 - a^2C_3 $ ", thus we get
$ \left[\begin{array}{rrr:rrr} 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & -a^2 & 0 & -a & 1 & 0 \\ 0 & 0 & -a^2 & 0 & a & -a^2 \end{array}\right] $
But I got stuck in the last part since $\left(\begin{array}{ccc}1 & 0 & 0 \\ -a & 1 & 0 \\ 0 & a & -a^{2}\end{array}\right)\left(\begin{array}{ccc}1 & a & 1 \\ a & 0 & 0 \\ 1 & 0 & 1\end{array}\right)\left(\begin{array}{ccc}1 & -a & 0 \\ 0 & 1 & a \\ 0 & 0 & -a^{2}\end{array}\right)=\left(\begin{array}{ccc}1 & 0 & 0 \\ 0 & -a^{2} & 0 \\ 0 & 0 & a^{4}\end{array}\right) $ which is not equal to $ \left(\begin{array}{ccc}1 & 0 & 0 \\ 0 & -a^2 & 0 \\ 0 & 0 & -a^2 \end{array}\right) $.
Note: I've been using the following algorithm appearing in the image in the question reference for linear algebra books that teach reverse Hermite method for symmetric matrices
Question: Do you have any idea why in my last step in the algorithm there's a problem? ( If I could proceed any $a\neq 0$ would satisfy $ rank A =3 $), and how can I proceed to find the signature?
Thanks in advance for help!