<s>[INST] Find a diagonal form of the quadratic form $f(x) = \sum_{i = 1}^nx_i^2 + \sum_{i < j}x_ix_j$ Find a diagonal form of the quadratic form
$$f(x) = \sum_{i = 1}^nx_i^2 + \sum_{i < j}x_ix_j.$$ 
It turned out to be such a problem:
How to change quadratic form $f(x) = \sum_{i = 1}^nx_i^2 + \sum_{i < j}x_ix_j$ into diagonal form?
We can solve it with congruent transformation, although it is a little complex.
Besides, I tried to transform it into a diagonal form by orthogonal transformation, since its quadratic matrix has the same diagonal elements and the same non-diagonal elements(I thought that I can find a simple way to find its eigenvalues and eigenvectors, but failed. Maybe you can try it).
Is there any other way?
 [/INST] This is too long for the comment box.
The essence of your exercise is given in the following example.
Suppose we have $f(x, y, z) = x^2 + y^2 + z^2 + xy + xz + yz.$ We complete the square by getting rid of one of the variables, say we pick the first one ($x$ in my notation). So you get,
$$\begin{align*}
f(x, y, z) &= (x^2 + xy + xz) + y^2 + z^2 + yz \\
&= \left( x + \dfrac{y}{2} + \dfrac{z}{2} \right)^2 - \frac{y^2}{4} - \frac{z^2}{4} -\frac{yz}{2} + y^2 + z^2 + yz\\
&=u^2 + \dfrac{3y^2}{4} + \dfrac{yz}{2} + \dfrac{3z^2}{4}
\end{align*},$$
where $u = x + \dfrac{y}{2} + \dfrac{z}{2}.$ Now, we can get rid of the second variable, $y$ in my case, by, again, completing the square
$$\begin{align*}
f(x, y, z) &= u^2 + \left( \dfrac{\sqrt{3}y}{2} + \frac{z}{2\sqrt{3}} \right)^2-\dfrac{z^2}{12}+\dfrac{3z^2}{4} = u^2 + v^2+\dfrac{5}{6}z^2
\end{align*},$$
which is a required representation of $f.$
The case with $x_1, \ldots, x_p$ is just guessing a pattern and using induction (I am guessing).
</s>