# 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.

-
If you can solve $\int_0^\pi x^m \cos^k x$ for all $k$, you can use Chebyshev polynomals, $T_n$, defined so that $T_n(\cos x) = \cos nx$, and then compute the polynomial $\frac{T_n(y)-1}{y-1}$. – Thomas Andrews Jul 20 '12 at 20:03
You can compute $I_n$ quickly with the residue theorem – Cocopuffs Jul 20 '12 at 20:23
@ Cocopuffs: i'd like so much to solve them elementarily by only using high school knowledge (if that is possible). Residue theorem could be a way you may post it if you're willing. – I'm an artist Jul 20 '12 at 20:24
I'm with @Thomas; judicious use of Chebyshev will likely crack this with minimum fuss. – J. M. Jul 20 '12 at 22:47
I think the first integral may be elegantly solved by using $I_{n}=\frac{I_{n-1}+I_{n+1}}{2}$ – I'm an artist Jul 24 '12 at 20:51

Here's a way to find $I_n$ with the residue theorem: first, by symmetry, $I_n = \frac{1}{2} \int_0^{2\pi} \frac{1 - \cos(nx)}{1- \cos(x)}dx$. Consider $z = e^{ix}$ such that the integral with now be on the edge of the unit circle $C$, and use the fact that $$\cos(nx) = \frac{e^{inx} + e^{-inx}}{2}.$$ as well as $\frac{dz}{dx} = i e^{ix}$. So $dx = \frac{1}{iz} dz$ and

$$\int_0^{2\pi} \frac{1 - \cos(nx)}{1 - \cos(x)} dx = \int_C \frac{1}{iz} \frac{1 - \frac{1}{2}(z^{n} + z^{-n})}{1 - \frac{1}{2}(z + z^{-1})}dz$$ $$= \frac{1}{i}\int_C \frac{1}{z^{n}} \left(\frac{z^n - 1}{z - 1}\right)^2 dz$$ $$= \frac{2\pi i}{i} \mathrm{Res}_{z = 0} \frac{1}{z^{n}} (1 + ... + z^{n-1})^2 = 2\pi n$$

and so $I_n = \pi n$.

-

As for the first integral $$I_n=\int\limits_{0}^\pi\frac{1-\cos nx}{1-\cos x}dx= \int\limits_{0}^\pi\frac{\sin^2 (nx/2)}{\sin^2(x/2)}dx= 2\int\limits_{0}^{\pi/2}\frac{\sin^2 (nx)}{\sin^2(x)}dx= 2\int\limits_{0}^{\pi/2}\left(\frac{\sin (nx)}{\sin(x)}\right)^2dx=$$ $$2\int\limits_{0}^{\pi/2}\left(\frac{e^{inx}-e^{-inx}}{e^{ix}-e^{-ix}}\right)^2dx= 2\int\limits_{0}^{\pi/2}\left(\sum\limits_{k=0}^{n-1}(e^{ix})^k (e^{-ix})^{n-k-1}\right)^2dx=$$ $$2\int\limits_{0}^{\pi/2}\left(\sum\limits_{k=0}^{n-1}(e^{ix})^{2k+1-n} \right)^2dx= 2\int\limits_{0}^{\pi/2}\left(\sum\limits_{k=0}^{n-1}(e^{ix})^{2k+1-n} \right)\left(\sum\limits_{l=0}^{n-1}(e^{ix})^{2l+1-n} \right)dx=$$ $$2\int\limits_{0}^{\pi/2}\sum\limits_{k=0}^{n-1}\sum\limits_{l=0}^{n-1}(e^{ix})^{2k+1-n+2l+1-n}dx= 2\sum\limits_{k=0}^{n-1}\sum\limits_{l=0}^{n-1}\int\limits_{0}^{\pi/2}(e^{ix})^{2k+2l+2-2n}dx=$$ $$2\sum\limits_{k=0}^{n-1}\sum\limits_{l=0}^{n-1}\frac{\pi}{2}\delta_{2k+2l+2-2n}= \pi\sum\limits_{k=0}^{n-1}\sum\limits_{l=0}^{n-1}\delta_{2k+2l+2-2n}=\pi n$$ As for the second... I'll think about it.

-
nice your way! (+1) – I'm an artist Jul 20 '12 at 20:27

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.

-
So it is remains to take a limits $t\to+0$? – Norbert Jul 20 '12 at 21:15
@Norbert: no, the limit as $t \to 0$ is just $G_n(0) = J_{0,n}$. – Robert Israel Jul 20 '12 at 21:17
Agree, that was my stupid comment – Norbert Jul 20 '12 at 21:17

Another generating function approach is to set $z=e^{ix}$ in \begin{align} &\sum_{k=0}^\infty\frac{(it)^m}{m!}\int_0^{\pi}x^m\frac{1-\cos(nx)}{1-\cos(x)}\,\mathrm{d}x\\ &=\int_0^{\pi}z^t\left(\frac{z^n-1}{z-1}\right)^2\frac{\mathrm{d}z}{iz^n}\\ &=\frac1i\int_0^{\pi}\left(\sum_{k=1-n}^{n-1}(n-|k|)z^{k+t-1}\right)\mathrm{d}z\\ &=\frac1i\sum_{k=1-n}^{n-1}(n-|k|)\frac{(-1)^ke^{\pi it}-1}{k+t}\\ &=in\frac{1-e^{\pi it}}{t}-2it\sum_{k=1}^{n-1}\frac{n-k}{k^2-t^2}\left(1-(-1)^ke^{\pi it}\right)\tag{1} \end{align} As $t\to0$, it is easy to see that we get $\pi n$.

-