Find a basis with respect to which this bilinear form is diagonal We have the following symmetric bilinear form on $\\Q^4$ (vector space over rational numbers) 
with respect to standard basis $\{e_1,e_2,e_3,e_4\}$ $$g(v,w)=v^tAw$$
$$A=\begin{bmatrix}1 & 2 &3&4\\2 & 3 & 4 & 5\\3&4&5&6\\4&5&6&7\end{bmatrix}$$
How to find a basis on which g is diagonal. I suppose using Gram-Schmidt algorithm we find orthogonal basis, but could someone explain this explicitly, please?
 A: There is no need to look for an orthogonal basis. Note that our goal is not to diagonalize $A$ using similarity transform, but to diagonalize $A$ using congruence. That is, what we are looking for is not an invertible matrix $P$ such that $P^{-1}AP$ is diagonal, but an invertible $P$ such that $P^TAP$ is diagonal.
(When $P$ is a real orthogonal matrix, $P^{-1}AP$ and $P^TAP$ coincide, but it is not always possible to find such an orthogonal $P$ over the rationals and this is not our goal anyway.)
You may apply simultaneous elementary row and column reductions to obtain $P$. More specificically, let
$$
E_1=\begin{pmatrix}1&0&0&0\\-2&1&0&0\\-3&0&1&0\\-4&0&0&1\end{pmatrix}.
$$
Then
$$
B=E_1AE_1^T=\begin{pmatrix}1&0&0&0\\0&-1&-2&-3\\0&-2&-4&-6\\0&-3&-6&-9\end{pmatrix}.
$$
Now let
$$
E_2=\begin{pmatrix}1&0&0&0\\0&1&0&0\\0&-2&1&0\\0&-3&0&1\end{pmatrix}.
$$
Then
$$
D=E_2BE_2^T=\begin{pmatrix}1&0&0&0\\0&-1&0&0\\0&0&0&0\\0&0&0&0\end{pmatrix}.
$$
Now $D=(E_2E_1)A(E_1^TE_2^T)$. So you may take the basis vectors as the column vectors of $P=E_1^TE_2^T$.
