<s>[INST] Compute the trigonometric integrals How would you compute the following integrals?
$$ I_{n} = \int_0^\pi \frac{1-\cos nx}{1- \cos x} dx  $$
$$ J_{n,m} = \int_0^\pi \frac{x^m(1-\cos nx)}{1- \cos x} dx  $$
For instance, i noticed that the first integral is convergent for any value of $n$ since $\lim_{x\to0} \frac{1- \cos nx}{1 - \cos x}= n^2$. This fact may also be extended to the second integral, as well.
 [/INST] The exponential generating function of $J_{m,n}$ for fixed $n$ is
$$G_n(t) = \sum_{m=0}^\infty J_{m,n} t^m/m! = \int_0^\pi e^{tx} \dfrac{\sin(nx)^2}{\sin(x)^2}\ dx$$
We then have $(\sin(nx)/\sin(x))^2 = n +  2 \sum_{j=1}^{n-1} (n-j) \cos(2 j x)$
and $$G_n(t) =  (e^{\pi t} - 1) \left(\frac{n}{t}  + 2 \sum_{j=1}^{n-1} (n-j) \dfrac{t}{t^2 + 4 j^2}\right)$$
EDIT:
For example, $G_3(t) = (e^{\pi t} - 1) \left(\dfrac{3}{t} + \dfrac{4t}{t^2+4} + \dfrac{2t}{t^2+16}\right)$.  Now $$e^{\pi t} - 1 = \sum_{j=1}^\infty \pi^j \dfrac{t^j}{j!} = \pi t + \dfrac{\pi^2 t^2}{2} + \dfrac{\pi^3 t^3}{6} + \ldots$$
$$\dfrac{3}{t} + \dfrac{4t}{t^2+4} + \dfrac{2t}{t^2+16} = \dfrac{3}{t} + \sum_{j=0}^\infty (-1)^j(4^{-j}+ 16^{-j}/8) t^{2j+1} = \dfrac{3}{t} + \left(1+\dfrac{1}{8}\right) t - \left(\dfrac{1}{4} + \dfrac{1}{16 \times 8}\right) t^3 + \ldots$$
and so $J_{m,3}$ is $m!$ times the coefficient of $t^m$ in the product of these.
</s>