TITLE: Why does the sum of these trigonometric expressions give such a simple result?
QUESTION [8 upvotes]: During calculations I came across the following identity:
$$M+2(1-m) = \sum_{l=1}^{M-1} \frac{\cos\left(2\pi\frac{(2-m)\,l}{M}\right) - \cos\left(2\pi\frac{m\,l}{M}\right)}{2(1-\cos\left(2\pi\frac{l}{M}\right)}, \quad \forall m\in \{2,\dots, M\}, M\in \mathbb{N}$$
I cannot see why this rather complicated sum should give such a simple expression.
Does anyone know trig-tricks to simplify the sum? Can one already see intuitively that the result is linear in $m$ ?

REPLY [6 votes]: I don't believe any simple substitutions work directly.  To get both the $M$ and $m-1$, I made a substitution which brings in another sum over a different variable, and then change the orders. Here is my proof of the identity: 
Proof: Assume $m\in\mathbb{Z}$, and that $m\neq 1$.  First, we begin with the addition and subtraction identities for cosine, and attempt to exploit the numerators symmetry around $m-1$.  Upon subtracting 
$$\cos\left(2\pi\frac{\left(2-m\right)}{M}l\right)=\cos\left(2\pi\frac{(m-1)l}{M}\right)\cos\left(\frac{2\pi l}{M}\right)+\sin\left(2\pi\frac{(m-1)l}{M}\right)\sin\left(\frac{2\pi l}{M}\right) $$
and
$$\cos\left(2\pi\frac{m}{M}l\right)=\cos\left(2\pi\frac{(m-1)l}{M}\right)\cos\left(\frac{2\pi l}{M}\right)-\sin\left(2\pi\frac{(m-1)l}{M}\right)\sin\left(\frac{2\pi l}{M}\right) $$ we have
$$\sum_{l=1}^{M-1}\frac{\cos\left(2\pi\frac{\left(2-m\right)}{M}l\right)-\cos\left(2\pi\frac{m}{M}l\right)}{2\left(1-\cos\frac{2\pi l}{M}\right)}= \sum_{l=1}^{M-1}\frac{\sin\left(2\pi\frac{(m-1)l}{M}\right)\sin\left(\frac{2\pi l}{M}\right)}{\left(1-\cos\frac{2\pi l}{M}\right)}.$$  
Recall that $$\frac{\sin(x)}{1-\cos\left(x\right)}=\cot\left(\frac{x}{2}\right)$$ so our series becomes  $$\sum_{l=1}^{M-1}\frac{\sin\left(2\pi\frac{(m-1)l}{M}\right)\cos\left(\frac{\pi l}{M}\right)}{\sin\left(\frac{\pi l}{M}\right)}.$$ Since $$\frac{\sin\left(2kx\right)}{\sin(x)}=2\left(\cos(x)+\cos(3x)+\cdots+\cos((2k-1)x)\right)=2\sum_{n=1}^{k}\cos\left((2n-1)x\right)$$ we may substitute in and rearrange orders to obtain  $$2\sum_{l=1}^{M-1}\cos\left(\frac{\pi l}{M}\right)\sum_{n=1}^{m-1}\cos\left((2n-1)\frac{\pi l}{M}\right)$$ 
$$=2\sum_{n=1}^{m-1}\sum_{l=1}^{M-1}\cos\left(\frac{\pi l}{M}\right)\cos\left((2n-1)\frac{\pi l}{M}\right).$$ Upon using the identity $$\cos(nx)\cos(x)=\frac{1}{2}\cos\left((n-1)x\right)+\frac{1}{2}\cos\left((n+1)x\right),$$ we have $$\sum_{n=1}^{m-1}\sum_{l=1}^{M-1}\left(\cos\left(2\pi\frac{nl}{M}\right)+\cos\left(2\pi\frac{(n-1)l}{M}\right)\right).$$  Lets shift $n$ by $1$ for the right hand term, so both terms in the sum line up.  Doing so introduces $\sum_{l=1}^{M-1} \cos(0)=M-1$, and since we have to cut off the sum at $m-2$, we must also add in $\sum_{l=1}^{M-1}\left(\cos\left(2\pi\frac{(m-1)l}{M}\right)\right)$ so we get  $$=M-1+\sum_{l=1}^{M-1}\left(\cos\left(2\pi\frac{(m-1)l}{M}\right)\right)+2\sum_{n=1}^{m-2}\sum_{l=1}^{M-1}\cos\left(2\pi\frac{nl}{M}\right).$$  Using the fact that the roots of unity sum to zero, and we are only missing the root $1$, we see that $\sum_{l=1}^{M-1}\cos\left(2\pi\frac{nl}{M}\right)=-1$, for $n\neq 0$ and hence our sum is
$$=M-2+2\left(2-m\right)=M+2(1-m).$$