Sum of a trigonometric series involving sin and tan I'm trying to prove that the following expression is true:
$$\sum_{k=1}^{N-1} \frac{\sin\left(\frac{\pi k n}{N}\right)}{\tan\left(\frac{\pi k}{2N}\right)} = N-n$$
I think that substituting $\tan\left(\frac{\pi k}{2N}\right)=\frac{\sin\left(\frac{\pi k}{N}\right)}{1+\cos\left(\frac{\pi k}{N}\right)}$ might simplify the problem, but I still end up with a series with trigonometric term in the denominator, which I'm not sure how to solve. 
Many thanks,
Calum
 A: Use $e^{i\theta}=\cos(\theta)+i\sin(\theta)$, $\theta\in\textbf{R}$ to write 
$$
\cos\left(\theta\right)=\frac{e^{i\theta}+e^{-i\theta}}{2}\textbf{, }\theta\in\textbf{R}.
$$
Hence
$$
\cos\left(\frac{\pi k}{N}\right)\cos\left(\frac{n\pi k}{N}\right)=
$$
$$
=\frac{1}{4}e^{-ik\pi/N-ikn\pi/N}+\frac{1}{4}e^{ik\pi/N+ikn\pi/N}+\frac{1}{4}e^{-ik\pi/N+ikn\pi/N}
$$
$$
+\frac{1}{4}e^{ik\pi/N-ikn\pi/N}.\tag{id}
$$
If we set
$$
A(n):=\sum^{N-1}_{k=0}\cos\left(\frac{\pi k}{N}\right)\cos\left(\frac{n\pi k}{N}\right)\textrm{, }n=0,1,2,\ldots,
$$
then from (id) we have (for $n$ nonnegative integer), (we collect the conjugates to find the real parts):
$$
A(n)=\frac{N}{2}\textrm{ if }n=1;1\textrm{ if }n=even;0\textrm{ if }n=odd\neq 1.
$$
Using $\cos^2(\theta)=\frac{1+\cos(2\theta)}{2}$, we get
$$
\sum^{N-1}_{k=0}\cos^2\left(\frac{\pi k}{2N}\right)\cos\left(\frac{n\pi k}{N}\right)=
$$
$$
=\frac{N+1}{2}\textrm{ if }n=0;\frac{N+2}{4}\textrm{ if }n=1;\frac{1}{2}\textrm{ if }n=2,3,4,\ldots\tag{1}
$$
But 
$$
\frac{\sin\left(\frac{\pi k n}{N}\right)}{\tan\left(\frac{\pi k}{2N}\right)}=\frac{\left(1+e^{i k\pi/N}\right)\left(e^{-nik\pi/N}-e^{nik\pi/N}\right)}{2\left(1-e^{ik\pi/N}\right)}
$$
and if $\zeta=e^{-\pi i/N}$, then
$$
e^{-nik\pi/N}-e^{nik\pi/N}=\zeta^{nk}-\zeta^{-nk}=\zeta^{-nk}\left(\zeta^{2nk}-1\right)=
$$
$$
=\zeta^{-nk}(\zeta^{2k}-1)\left(1+\zeta^{2k}+\zeta^{4k}+\ldots+\zeta^{2(n-1)k}\right).\tag{2}
$$
Hence
$$
\frac{\sin\left(\frac{\pi k n}{N}\right)}{\tan\left(\frac{\pi k}{2N}\right)}=\frac{1}{2}\left(\zeta^k+1\right)^2\zeta^{-nk}\left(1+\zeta^{2k}+\zeta^{4k}+\ldots+\zeta^{2(n-1)k}\right).\tag{3}
$$ 
i) If $n$ is odd, then easily we have
$$
\sum^{n-1}_{j=0}\zeta^{2kj}=\zeta^{(n-1)k}\left(1+2\sum^{\frac{n-1}{2}}_{j=1}\cos\left(\frac{2jk\pi}{N}\right)\right)\tag{4}
$$
and 
$$
\frac{1}{2}(\zeta^k+1)^2 \zeta^{-nk}\zeta^{(n-1)k}=1+\cos\left(\frac{k\pi}{N}\right)=2\cos^2\left(\frac{k\pi}{2N}\right)\tag{5}
$$
Hence relation (3) becomes
$$
\frac{\sin\left(\frac{\pi k n}{N}\right)}{\tan\left(\frac{\pi k}{2N}\right)}
=2\cos^2\left(\frac{\pi k}{2N}\right)\left(1+2\sum^{\frac{n-1}{2}}_{j=1}\cos\left(\frac{2jk\pi}{N}\right)\right)\tag{6}
$$
Summing (6) and using (1), we get
$$
\sum^{N-1}_{k=0}\frac{\sin\left(\frac{\pi k n}{N}\right)}{\tan\left(\frac{\pi k}{2N}\right)}=
\sum^{N-1}_{k=0}2\cos^2\left(\frac{k\pi}{2N}\right)\left(1+2\sum^{\frac{n-1}{2}}_{j=1}\cos\left(\frac{2jk\pi}{N}\right)\right)=
$$
$$
=2\left(\frac{N+1}{2}+2\frac{n-1}{2}\cdot\frac{1}{2}\right)=N+n\tag{7}
$$
ii) If $n$ is even, then
$$
\sum^{n-1}_{j=0}\zeta^{2kj}=2\zeta^{(n-1)k}\sum^{\frac{n}{2}}_{j=1}\cos\left(\frac{(2j-1)k\pi}{N}\right)\tag{8}
$$
Hence using (3),(8) and (1) again we get
$$
\sum^{N-1}_{k=0}\frac{\sin\left(\frac{\pi k n}{N}\right)}{\tan\left(\frac{\pi k}{2N}\right)}=\sum^{N-1}_{k=0}4\cos\left(\frac{k\pi}{2N}\right)^2\left(\sum^{\frac{n}{2}}_{j=1}\cos\left(\frac{(2j-1)k\pi}{N}\right)\right)=
$$
$$
=4\left(\frac{N+2}{4}+\frac{1}{2}\left(\frac{n}{2}-1\right)\right)=N+n\tag{9}
$$
Also it is (easily) 
$$
\lim_{k\rightarrow 0}\frac{\sin\left(\pi k n/N\right)}{\tan\left(\pi k/(2N)\right)}=2n.\tag{10}
$$
From (7),(9) and (10), we get the result.
