# Sum of cosines with a multiplicative factor in the angle and different interval

I have found the following formula for the sum of cosines in both here and here.

\begin{align} \sum^n_{l=1} \cos \left(\frac{2 \pi l}{n}\right) = 0 \end{align}

I would like to know what the sum would be if there is a multiplicative factor $k$ in the angle.

\begin{align} \sum^n_{l=1} \cos \left(\frac{2 \pi l k}{n}\right) = ? \end{align}

where, $k$ is a positive integer and $1 \le k \le (n-2)/2$.

Moreover, what if the interval for $l$ is changed from $[1, n]$ to $[0, l-1]$. So,

\begin{align} \sum^{n-1}_{l=0} \cos \left(\frac{2 \pi l k}{n}\right) = ? \end{align}

One may recall (see here) that \begin{align} \sum_{l=1}^{n} \cos (l\theta)=\frac{\sin(n\theta/2)}{\sin(\theta/2)}\cos ((n+1)\theta/2),\quad \sin(\theta/2)\neq0. \end{align} Then by putting $\theta=\dfrac{2 \pi k}{n}$ one gets
$$\sum^n_{l=1} \cos \left(\frac{2 \pi l k}{n}\right) =\frac{\color{red}{\sin(\pi k)}}{\sin(\pi l/n)}\cos ((n+1)\pi l/n)=\color{red}{0}$$
$$\sum^{n-1}_{l=0} \cos \left(\frac{2 \pi l k}{n}\right)=\cos (0)+\color{red}{0}-\cos(2\pi k)=0.$$
• The first result is a little surprising! I wouldn't have expected things to cancel out so nicely if all of the intervals didn't add up to $2\pi$.