TITLE: Exact result of a series using Euler-Maclaurin expansion.
QUESTION [8 upvotes]: This is a variant of Exercise 64 in Chapter 9 of concrete mathematics. 
Prove the following identity
\begin{equation}
\sum_{n = -\infty}^{\infty}' \frac{1 - \cos( 2\pi n k )}{n^2 }  = 2 \pi^2 ( k - k^2 ) \qquad k \in [0,1]
\end{equation}
I came across it in a different context and was surprised that it is exact. 
Let's use Euler-Maclaurin expansion to convert the sum into an integral. 
Take $f(x) = \frac{1 - \cos( 2\pi x k )}{x^2 } $
\begin{equation}
\sum_{n = -N+1}^{N}' f(n) = \int_{-N}^{N} f(x) dx - f(0) + \sum_{k=1}^{p} \frac{B_k}{k!}f^{(k-1)}(x)\Big|^N_{-N} + R_p 
\end{equation}
The first two terms are already the exact result, 
\begin{equation}
\int_{-\infty}^{\infty} f(x) dx = 2\pi k \int_{-\infty}^{\infty} \frac{1- \cos x}{x^2}dx = 2\pi^2 k \qquad f(0) = 2\pi^2 k^2 
\end{equation}
so one needs to prove the end point corrections(terms with $B_k$ in it) as well as the reminder terms are zero. 
At any order $p$, there are only finite number of end point correction terms which goes at most like $\mathcal{O}(\frac{1}{N^2})$, so they vanish when taking the $N\rightarrow \infty$ limit. But I don't know how to show the reminder term is zero(as $N\rightarrow \infty$),
\begin{equation}
R_p(N)  = (-1)^p \int_{-N}^{N} \frac{1}{p!} B_p( x - \lfloor x \rfloor ) f^{(p)}(x) dx 
\end{equation}
Maybe there are other methods to prove the identity, but I personally would appreciate the proof using Euler Maclaurin, since I'm going to use it for another series, and the reminder term has
\begin{equation}
f(x) = \frac{g(x) - g(0) }{ x^2} - \frac{g'(0)}{x}
\end{equation}
where $g(x ) = g(x + N)$ is a periodic function. So you can also go ahead and prove the general $g(x)$ case.
Thanks.
Edit:
The general case can also be worked out by robjohn 's method by summing over each individual the Fourier components. Though a direct proof of the vanishing Euler-Maclaurin reminder term is still absent, robjohn's method solved my problem.

REPLY [2 votes]: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\dsc}[1]{\displaystyle{\color{red}{#1}}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\Li}[1]{\,{\rm Li}_{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
$\ds{\left.\sum_{n=-\infty}^{\infty}\frac{1 - \cos\pars{2\pi nk}}{n^{2}}
    \right\vert_{\ n\ \not=\ 0}\  =\ 2\pi^{2}\pars{k - k^2}:\ {\large ?}.\qquad
    k \in \bracks{0,1}}$

\begin{align}&\color{#66f}{\large%
\left.\sum_{n=-\infty}^{\infty}\frac{1 - \cos\pars{2\pi nk}}{n^{2}}
\right\vert_{\ n\ \not=\ 0}}
=\sum_{n=0}^{\infty}\,{\rm f}\pars{n,k} - 4\pi^{2}k^{2}
\\[5mm]&\mbox{where}\quad
\,{\rm f}\pars{x,k}\equiv
\left\{\begin{array}{lcl}
2\,\dfrac{1 - \cos\pars{2\pi xk}}{x^{2}} & \mbox{if} & x \not= 0
\\[2mm]
4\pi^{2}k^{2} & \mbox{if} & x = 0
\end{array}\right.
\end{align}
A straightforward application of the Abel-Plana Formula yields:
\begin{align}&\color{#66f}{\large%
\left.\sum_{n=-\infty}^{\infty}\frac{1 - \cos\pars{2\pi nk}}{n^{2}}
\right\vert_{\ n\ \not=\ 0}}
=\overbrace{\int_{0}^{\infty}\,{\rm f}\pars{x,k}\,\dd x}
^{\dsc{2\pi^{2}k}}\ +\
\overbrace{\half\,{\rm f}\pars{0,k}}^{\dsc{2\pi^{2}k^{2}}}\ -\
4\pi^{2}k^{2}
\\[5mm]&=\color{#66f}{\large 2\pi^{2}\pars{k - k^2}}
\end{align}