Evaluate $ \int_0^\pi \left( \frac{2 + 2\cos (x) - \cos((k-1)x) - 2\cos (kx) - \cos((k+1)x)}{1-\cos (2x)}\right) \mathrm{d}x $ Evaluate the following definite integral: 
$$ \int_0^\pi  \left( \frac{2 + 2\cos (x) - \cos((k-1)x) - 2\cos (kx) - \cos((k+1)x)}{1-\cos(2x)}\right) \mathrm{d}x, $$ where $k \in \mathbb{N}_{>0}$.
 A: I think we can get the answer into a relatively elementary form.  Observe that
$$\cos{(k-1) x} + 2 \cos{k x} + \cos{(k+1) x} = 2 \cos{k x} (1+ \cos{x})$$
Thus the integrand simplifies into
$$4 \int_0^{\pi} dx \cos^2{\frac{x}{2}} \frac{\sin^2{k \frac{x}{2}}}{\sin^2{x}} $$
which is equal to
$$\frac12 \int_0^{2 \pi} du \left (\frac{\sin{k u}}{\sin{u}} \right )^2 $$
This integral may be evaluated using the residue theorem by converting it to a complex integral:
$$-\frac{i}{2} \oint_{|z|=1} \frac{dz}{z^{2 k-1}} \left (\frac{z^{2 k}-1}{z^2-1} \right )^2$$
The only (non-removable) pole is at $z=0$, but this pole has multiplicity $2 k-1$.  Thus, by the residue theorem, the integral is equal to
$$\frac{\pi}{(2 k-2)!} \left [\frac{d^{2 k-2}}{dz^{2 k-2}} \left (\frac{z^{2 k}-1}{z^2-1} \right )^2 \right ]_{z=0} = \frac{\pi}{(2 k-2)!} \left [\frac{d^{2 k-2}}{dz^{2 k-2}} \left (1+z^2+z^4+\cdots z^{2 k-2} \right )^2 \right ]_{z=0}$$
Now, this may be evaluated as follows.  The derivative term is equal to
$$2 \frac{d^{2 k-3}}{dz^{2 k-3}} \left (1+z^2+z^4+\cdots z^{2 k-2} \right )^2 \left (2 z+4 z^3+\cdots+(2 k-2) z^{2 k-3} \right )$$
This is obviously a polynomial, and at $z=0$, the only surviving term will be the $z^{2 k-3}$ term.  The coefficient of that term is
$$2+4+6+\cdots+(2 k-2) = k (k-1)$$
Therefore, the integral is
$$\frac{2 \pi}{(2 k-2)!} k (k-1) (2 k-3)! = \pi k$$
ADDENDUM
In response to @Igor's challenge, I can at least show that the value of the integral for half-integer values of $k$ is a rational number.  (Note that the above analysis is only valid for integer $k$.)  For these values of $k$, the above contour integration does not work because the extension of the integration interval to $[0,2 \pi]$ does not apply.  Thus, the recurrence approach of @Nico is better here.  If we define 
$$J_m = I_{m+\frac12}$$
Then the recurrence relation we seek is
$$J_{m+1}-2 J_m + J_{m-1} = 4 \frac{(-1)^m}{2 m+1}$$
Thus, to show that $J_m \in \mathbb{Q}$, we need only show that $J_0 \in \mathbb{Q}$ and $J_1 \in \mathbb{Q}$.  So we evaluate the integrals.
$$\begin{align}J_0 &= 2 \int_0^{\pi/2} du \frac{\sin^2{(u/2)}}{\sin^2{u}} \\ &= \frac12 \int_0^{\pi/2} du \, \sec^2{\frac{u}{2}} \\ &= \left [ \tan{\frac{u}{2}}\right ]_0^{\pi/2} = 1 \end{align}$$
$$\begin{align}J_1 &= 2 \int_0^{\pi/2} du \frac{\sin^2{(3 u/2)}}{\sin^2{u}} \\ &= \frac12 \int_0^{\pi/2} du \, \sec^2{\frac{u}{2}} (1+2 \cos{u})^2 \\ &= \left [ \tan{\frac{u}{2}} + 4 \sin{u}\right ]_0^{\pi/2} = 5 \end{align}$$
Thus, the $J_m \in \mathbb{Q}$ as asserted.
A: Let 
$$I_k = \int_0^\pi  \left( \frac{2 + 2\cos x - \cos(k-1)x - 2\cos kx - \cos(k+1)x}{1 - \cos2x}\right) \mathrm dx.$$
Then, we have:


*

*$I_0 = 0$;

*$I_1 = \pi$.
For any  $ k \in \mathbb{N}^*$, we have:
$$ \begin{align} 
I_{k+1} - 2I_k + I_{k-1} 
&=  \int_0^\pi  \left(  \frac{\cos(-2+k)x - 2\cos kx + \cos (2 + k)x}{-1 + \cos 2x}\right) \mathrm dx \\
&= \int_0^\pi  \left(  \frac{2\cos kx(-1 + \cos^2x)}{-1 + \cos 2x}\right) \mathrm dx =0
\end{align}$$
Since $ I_{k+1} - I_k = I_k - I_{k-1} $, $(I_k)$ is an arithmetic progression. Hence $ I_k  = k\pi $.
A: Mathematica says:
$$
-\frac{1}{2} i e^{-i \pi  k} \left(2 \pi  e^{i \pi  k} k \cot (\pi  k)+k \psi
   ^{(0)}\left(\frac{1}{2}-\frac{k}{2}\right)-k \psi
   ^{(0)}\left(-\frac{k}{2}\right)+e^{2 i \pi  k} \left(k \psi
   ^{(0)}\left(\frac{k}{2}\right)-k \psi
   ^{(0)}\left(\frac{k+1}{2}\right)+1\right)+1\right)
$$
