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
Express all trigonometric terms as complex exponentials and use the fact that the sum of all nth roots of unity is zero.
That is, write
$\cos^2\left(\frac{2\pi n(l-q)}{N}\right) = \left(\frac{e^{i\frac{2\pi n(l-q)}{N}} + e^{-i\frac{2\pi n(l-q)}{N}}}{2}\right)^2$
and
$\cos\left(\frac{2\pi nq}{N}\right)\cos\left(\frac{2\pi nr}{N}\right) = \left(\frac{e^{i\frac{2\pi nq}{N}} + e^{-i\frac{2\pi nq}{N}}}{2}\right)\left(\frac{e^{i\frac{2\pi nr}{N}} + e^{-i\frac{2\pi nr}{N}}}{2}\right)$
You'll find yourself evaluating expressions of the form $\sum_{q=1}^{N-1} e^{i2\pi \alpha q/N}$, where $\alpha$ is an integer less than $N$. Using the fact that $e^{i2\pi} =1$, you'll have that $\left(e^{i2\pi \alpha/N}\right)^N = 1$. Therefore, using the fact that
$$ 1 + x + x^2 + \cdots + x^{N-1} = \frac{x^N - 1}{x - 1}, $$ for $x \ne 1$, you'll find that $$ \sum_{q = 0}^{N-1} e^{i2\pi \alpha q/N} = 0. $$
However, if $\alpha = N$, then $e^{i2\pi \alpha q/N} =1$ for all $q$, and thus $$ \sum_{q = 0}^{N-1} e^{i2\pi \alpha q/N} = N. $$