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?
 A: The matrix $M$ of this quadratic form has the form
$$
M=\frac12(I_n+J_n),
$$
where $J_n$ is the $n\times n$ matrix with all ones.
The eigenvalues of $J_n$ are obviously $\lambda_1=n$ (multiplicity one) and 
$\lambda_2=\lambda_3=\cdots=\lambda_n=0$ (multiplicity $n-1$). Therefore the eigenvalues of $M$ are $(n+1)/2$ (multiplicity one) and $1/2$ (multiplicity $n-1$). Implying that there exists an orthogonal coordinate transformation $(x_1,x_2,\ldots,x_n)\mapsto (x_1',x_2',\ldots,x_n')$ such that in the primed coordinates the quadratic form takes the form
$$
Q(x_1',x_2',\ldots,x_n')=\frac12\left((n+1)x_1'^2+x_2'^2+x_3'^2+\cdots+x_n'^2\right).
$$
An orthonormal basis corresponding to the primed coordinates can be found by orthonormalizing any basis of the $(n-1)$-dimensional subspace 
$$V=\{(x_1,x_2,\ldots,x_n)\in\Bbb{R}^n\mid x_1+x_2+\ldots+x_n=0\}$$
which is equal to the eigenspace of $J_n$ belonging to the eigenvalue zero. The missing basis vector is the unit vector $\dfrac1{\sqrt n}(1,1,\ldots,1)$ spanning the orthogonal complement of $V$.

It is (very likely) possible to describe an orthonormal basis of $V$ with a lot of symmetries. I'm not sure I want to go there, though. I would start with a complex basis consisting of roots of unity of order $n$, and go from there.
A: 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).
