TITLE: show this nice trigonometric identiy
QUESTION [6 upvotes]: I was working on a book, which was asking me to prove that some product is equal to nn. I had reduced the problem to proving a trigonometric identity, but I couldn't prove it although I spent much time on it. Then, I checked the solution, and it solves the problem with a quite different approach that doesn't even enter to trigonometric expressions at all. But, still, this nice identity that I hadn't encountered before must be true then! I was wondering if people can think of a direct proof for that?
Show this following identity: $$\sum_{i=1}^{n-1}\left\{\left(\cos{\frac{2\pi}{n}}-\cos{\dfrac{2\pi i}{n}}\right)\left[\left(\sum_{j=1}^{n}x_{j}\cos{\dfrac{2ij\pi}{n}}\right)^2+\left(\sum_{j=1}^{n}x_{j}\sin{\dfrac{2ij\pi}{n}}\right)^2\right]\right\}
$$$$=\left(1-\cos{\dfrac{2\pi}{n}}\right)\left(\sum_{i=1}^{n}x_{j}\right)^2+n\cos{\dfrac{2\pi}{n}}\sum_{i=1}^{n}x^2_{i}-n\sum_{i=1}^{n}x_{i}x_{i+1},$$
where $x_{i}\in \Bbb R$ and $x_{n+1}=x_{1}.$

REPLY [2 votes]: It is easy to check that moving the first summand from the right hand side of the equality to its left hand side, we simplify it to $X=Y$, where  
$$X=\sum_{i=1}^{n}\left(\cos{\dfrac{2\pi}{n}}-\cos{\dfrac{2\pi i}{n}}\right)
\left[\left(\sum_{j=1}^{n}x_{j}\cos{\dfrac{2ij\pi}{n}}\right)^2+\left(\sum_{j=1}^{n}x_{j}\sin{\dfrac{2ij\pi}{n}}\right)^2\right]$$
and $$Y=n\cos{\dfrac{2\pi}{n}}\sum_{i=1}^{n}x^2_{i}-n\sum_{i=1}^{n}x_{i}x_{i+1}.$$
We have $$\left(\sum_{j=1}^{n}x_{j}\cos{\dfrac{2ij\pi}{n}}\right)^2+\left(\sum_{j=1}^{n}x_{j}\sin{\dfrac{2ij\pi}{n}}\right)^2=$$ $$\sum_{j=1}^{n}\sum_{k=1}^{n} x_jx_k\left(\cos{\dfrac{2ij\pi}{n}}\cos{\dfrac{2ik\pi}{n}}+\sin{\dfrac{2ij\pi}{n}}\sin{\dfrac{2ik\pi}{n}}\right)=$$ $$\sum_{j=1}^{n}\sum_{k=1}^{n} x_jx_k\cos \dfrac{2i(j-k)\pi}{n}.$$
Thus   
$$X=\sum_{i=1}^{n}\left(\cos{\frac{2\pi}{n}}-\cos{\dfrac{2\pi i}{n}}\right)\sum_{j=1}^{n}\sum_{k=1}^{n} x_jx_k\cos \dfrac{2i(j-k)\pi}{n}=$$
$$\sum_{j=1}^{n}\sum_{k=1}^{n} x_jx_k \sum_{i=1}^{n}\left(\cos{\frac{2\pi}{n}}-\cos{\dfrac{2\pi i}{n}}\right) \cos \dfrac{2i(j-k)\pi}{n}.$$
Put $S_1=\sum_{i=1}^{n}\cos \dfrac{2i(j-k)\pi}{n}$. That is,  $S_1$ is the $x$-coordinate of the sum $S_1’$ of an indexed family $\mathcal S=\left\{\left(\cos \dfrac{2i(j-k)\pi}{n}, \sin\dfrac{2i(j-k)\pi}{n}\right): i:=1\dots n\right\}$ of unit vectors. If $j=k$ then $\cos \dfrac{2i(j-k)\pi}{n}=1$ for each $i$, so $S_1=n$. Otherwise it is easy to that rotation of the plane $\Bbb C$ by $\dfrac{2(j-k)\pi}{n}$ with the center at the origin induces a permutation of the vectors of the family $\mathcal S$. Thus $S’=S’\cdot \left(\cos \dfrac{2(j-k)\pi}{n},\sin\dfrac{2(j-k)\pi}{n}\right) $, which is possible only if $S_1’=0$.  
We have $$\sum_{i=1}^{n}\cos \dfrac{2\pi i}{n}\cos \dfrac{2i(j-k)\pi}{n}=S’_2+S’’_2,$$ 
where $$S_2’=\sum_{i=1}^{n}\frac 12\cos \dfrac{2i(j+1-k)\pi}{n}$$ and 
$$S_2’’=\sum_{i=1}^{n}\frac 12\cos \dfrac{2i(j-k-1)\pi}{n} .$$
Similarly to the above, we have $S_2’=n/2$, if $j+1-k=0\pmod n$ and $S_2’=0$, otherwise. Also $S_2’’=n/2$, if $j-1-k=0\pmod n$ and $S_2’’=0$, otherwise.
Taking the above into account, we obtain 
$$X=\sum_{j=1}^{n} n\cos{\frac{2\pi}{n}}x_j^2-n\sum_{j=1}^{n} x_jx_{j+1}=Y.$$