# How may we prove this $\int_{-\infty}^{+\infty}\left({n-\sum_{k=1}^{n}\cos(kx)}\right)^2{\mathrm dx\over x^2}=\pi\sum_{k=1}^{n}k^2?$

Consider this integral

$$\int_{-\infty}^{+\infty}\left({n-\sum_{k=1}^{n}\cos(kx)}\right)^2{\mathrm dx\over x^2}=\pi\sum_{k=1}^{n}k^2\tag1$$

Note $\sum_{k=1}^{n}k^2={1\over 6}n(n+1)(2n+1)$

How can we prove $(1)?$

An attempt:

Recall $$\cos(x)+\cos(2x)+\cos(3x)+\cdots+\cos(nx)={\sin(n+1/2)x\over 2\sin(x/2)}-{1\over 2}$$

$(1)$ becomes

$$\int_{-\infty}^{+\infty}\left(n-{\sin[(n+1/2)x]\over 2\sin(x/2)}-{1\over 2}\right)^2{\mathrm dx\over x^2}\tag2$$

$$\int_{-\infty}^{+\infty}{\left([2n-1]\sin(x/2)-\sin[(n+1/2)x]\right)^2\over 4\sin^2(x/2)}{\mathrm dx\over x^2}\tag3$$

Or we can rewrite $(2)$ as

$$\int_{-\infty}^{+\infty}\left(n-{1\over 2}\sin(nx)\cot(x/2)+{1\over 2}\cos(nx)\tan(x/2)-{1\over 2}\right)^2{\mathrm dx\over x^2}\tag4$$

Maybe of useful: recall $$\tan(x/2)={\sin x\over 1+\cos x}={1-\cos x\over \sin x}$$

Shruggling to simplify $(4)$, how else can we tackle $(1)?$

• Have you tried Parseval's identity? – Alex R. Apr 5 '17 at 17:29

First, we have

$$n-\sum_{k=1}^n\cos(kx)=\sum_{k=1}^n(1-\cos(kx))=2\sum_{k=1}^n\sin^2(kx/2)$$

Then, we can write

\begin{align} \int_{-\infty}^\infty \left(n-\sum_{k=1}^n\cos(kx)\right)^2\frac1{x^2}\,dx&=4\sum_{\ell=1}^n\sum_{m=1}^n\int_{-\infty}^\infty \frac{\sin^2(\ell x/2)}{x}\frac{\sin^2(mx/2)}{x}\,dx\\\\ &\underbrace{=}_{\text{from Plancherel}}\frac{\pi}2\sum_{\ell=1}^n\sum_{m=1}^n\int_{-\min(m,\ell)}^{\min(m,\ell)} (1)\,dk\\\\ &=\pi\sum_{\ell=1}^n\sum_{m=1}^n\min(\ell,m)\\\\ &=\pi\sum_{\ell=1}^n \ell^2 \end{align}

as was to be shown!

Note that the Fourier Transform of $\frac{\sin^2(\ell x/2)}{x}$ is given by

$$\int_{-\infty}^\infty \frac{\sin^2(\ell x/2)}{x}e^{ikx}\,dx=\frac{\pi}{2i}\begin{cases}-1&,-\ell\le k<0\\\\1&,0<k\le \ell\end{cases}$$