<s>[INST] Answer to some trigonometry series I have  two series as bellow 
$$\frac{2}{N}\sum_{n=0}^{N-1}\cos^2(\frac{2\pi n(l-q)}{N})    \quad l\neq q \quad(1)$$ 
$$ \sum_{q=0}^{N-1}cos(\frac{2\pi nq}{N})cos(\frac{2\pi rq}{N}) \quad n\neq r \quad (2)$$
Where $l$, $q$, $r$, $n$ and $N$ are integers. I have computed the two series in MATLAB. The first one is equal to $1$ and the second one is zero. But I cannot prove this analytically. Can anyone help me understand why (1) equals $1$ and (2) equals zero?
Thanks in advance
 [/INST] For Reference, I am putting two formulas I've used in the solution of these questions : 
(Sum of sines and cosines with angle are in A.P.)

$\displaystyle \sum_{k=0}^{n} \sin(k\beta) = \dfrac{\sin \dfrac{n\beta}{2}}{\sin \dfrac{\beta}{2}} \cdot \sin \left [ (n+1)\dfrac{\beta}{2} \right]$
$\displaystyle \sum_{k=0}^{n} \cos(k\beta) = \dfrac{\sin \dfrac{n\beta}{2}}{\sin \dfrac{\beta}{2}} \cdot \cos \left [ (n+1)\dfrac{\beta}{2} \right]$

1st Question - Partial Solution::
$\displaystyle  \begin{aligned} \dfrac{2}{N}\sum_{n=0}^{N-1}\cos^2 \left (\dfrac{2\pi n(l-q)}{N} \right) &= \dfrac{2}{N} \sum_{n=0}^{N-1} \left [ \dfrac{1 + \cos \dfrac{4 \pi n(l-q)}{N}}{2}  \right] \\ \\  &= \dfrac{2}{N}  \left [\dfrac{N-1}{2} + \dfrac {\displaystyle \sum_{n=0}^{N-1} \cos \dfrac{4 \pi n(l-q)}{N}}{2}  \right] \\ \\ &= \dfrac{2}{N}  \left [\dfrac{N-1}{2} +  \dfrac{\sin \dfrac{2 \pi (l-q)(N-1)}{N}}{2\sin \dfrac{2 \pi (l-q)}{N}} \cdot \cos \dfrac{2 \pi (l-q)N}{N} \right] \\ \\ &= \dfrac{2}{N}  \left [\dfrac{N-1}{2} +  \dfrac{1}{2}  \right] =1 .\end{aligned} $ 
(try to understand the last step here. )
2nd Question -- Hint::
$\begin{aligned} \sum_{q=0}^{N-1}cos(\frac{2\pi nq}{N})cos(\frac{2\pi rq}{N}) &= \dfrac{1}{2}\sum_{q=0}^{N-1} 2cos(\frac{2\pi nq}{N})cos(\frac{2\pi rq}{N}) \\ &= \dfrac{1}{2}\sum_{q=0}^{N-1} \sin \left (\frac{2\pi (n+r)q}{N} \right) + \sin \left(\frac{2\pi (n-r)q}{N} \right)\end{aligned}$.
</s>