How to do the integral can anyone help with this integral?
I tried to expand the sin function, but after expansion it became a mess!

 A: Note that
$$\frac{\sin{[(N+1/2) \theta]}}{\sin{(\theta/2)}} = 1 +2 \sum_{m=1}^N \cos{m \theta}$$
The integral is then
$$\int_{-\pi}^{\pi} d\theta \left (  1 + 2\sum_{m=1}^N \cos{m \theta} \right)\left (  1 + 2 \sum_{n=1}^N \cos{n (\omega-\theta)} \right) $$
We expand out the product.  Note that the integrals over the single sums go to zero because the integral over a cosine over a complete period is zero.  We are then left with
$$2 \pi + 4\sum_{m=1}^N \sum_{n=1}^N \int_{-\pi}^{\pi} d\theta \, \cos{m \theta} \, \cos{n (\omega-\theta)}$$
Now, it is straightforward to show that each integral is
$$\int_{-\pi}^{\pi} d\theta \, \cos{m \theta} \, \cos{n (\omega-\theta)} = \begin{cases} 0 & m \ne n \\ \pi \cos{n \omega} & m=n \end{cases}$$
The integral is therefore
$$2 \pi +4  \pi \sum_{n=1}^N \cos{n \omega} = 2 \pi \frac{\sin{[(N+1/2) \omega]}}{\sin{(\omega/2)}}$$
NOTE
You should recognize that the result is very similar in structure to the following Fourier transform result:
$$\int_{-\infty}^{\infty} dx' \, \frac{\sin{x'}}{x'} \frac{\sin{(x-x')}}{x-x'}  = \frac{1}{2 \pi} \int_{-\infty}^{\infty} dk\, [\pi\, \text{rect}(k)]^2 \, e^{i k x} = \pi \frac{\sin{k}}{k}$$
This makes sense, as the "Fourier transform" of the ratio of the sines in the original problem is analogous to the rect function.  In other words, we have a special case of a convolution theorem for Fourier series.
