Sum of Cosine/Exponential I try to simplify to get rid of sum
$$ \sum_{k=0}^{n-1}\cos(2 \pi fk)$$
I discover I shall use euler equation to form:
$$ \sum_{k=0}^{n-1}\frac{1}{2}(e^{2 \pi fki}+e^{-2 \pi fki})$$
but how to sum exponentials?
 A: You could proceed using the fact that $\cos(k \theta) = \dfrac{\exp(i k \theta) + \exp(-i k \theta)}{2}$, where $\theta = 2 \pi f$, as others have suggested.
Here is another method. Let $I_n = \displaystyle \sum_{k=0}^{n-1} \cos(k \theta)$. Now multiply by $\sin \left( \dfrac{\theta}{2}\right)$. Hence,
\begin{align}
\sin \left( \dfrac{\theta}{2}\right) I_n & = \sin \left( \dfrac{\theta}{2}\right) \displaystyle \sum_{k=0}^{n-1} \cos(k \theta) = \displaystyle \sum_{k=0}^{n-1} \cos(k \theta) \sin \left( \dfrac{\theta}{2}\right)\\
& = \dfrac12 \left(\displaystyle \sum_{k=0}^{n-1} \left( \sin \left( \left(k+\dfrac12 \right) \theta \right) - \sin \left( \left(k- \dfrac12 \right) \theta \right) \right) \right)
\end{align}
Now telescopic cancellation gives us
$$\sin \left( \dfrac{\theta}{2}\right) I_n = \dfrac12 \left( \sin \left( \left( n - \dfrac12\right) \theta \right)  + \sin \left( \dfrac{\theta}{2}\right)\right) = \sin \left( \left(\dfrac{n}{2} \right) \theta \right) \cos \left( \left(\dfrac{n-1}{2}  \right)\theta\right)$$
Hence, $$I_n = \dfrac{\sin \left( \left(\dfrac{n}{2} \right) \theta \right) \cos \left( \left(\dfrac{n-1}{2}  \right)\theta\right)}{\sin \left( \dfrac{\theta}{2}\right)}$$
The same idea works for $J_n = \displaystyle \sum_{k=0}^{n-1} \sin(k \theta)$ as well. Multiply by $\sin \left( \dfrac{\theta}{2}\right)$ and write each term as a difference of cosines to get
$$J_n = \dfrac{\sin \left( \left(\dfrac{n}{2} \right) \theta \right) \sin \left( \left(\dfrac{n-1}{2}  \right)\theta\right)}{\sin \left( \dfrac{\theta}{2}\right)}$$
A: It's just the sum of two geometric sequences $\frac{1}{2}\sum_{k=0}^{n-1} (e^{2\pi fi})^k$ and $\frac{1}{2}\sum_{k=0}^{n-1} (e^{-2\pi f i})^k$.
Evaluate it using the identity $\sum_{k=0}^{n-1} x^k = \frac{x^n-1}{x-1}$.
A: Since $\cos(2\pi fk)+i\sin(2\pi fk)=e^{2\pi ifk}$, we get
$$
\begin{align}
\sum_{k=0}^{n-1}\cos(2\pi fk)+i\sin(2\pi fk)
&=\sum_{k=0}^{n-1}e^{2\pi ifk}\\
&=\frac{e^{2\pi ifn}-1}{e^{2\pi if}-1}\\
&=e^{\pi if(n-1)}\frac{e^{\pi ifn}-e^{-\pi ifn}}{e^{\pi if}-e^{-\pi if}}\\
&=(\cos(\pi f(n-1))+i\sin(\pi f(n-1)))\frac{\sin(\pi fn)}{\sin(\pi f)}
\end{align}
$$
Equating real and imaginary parts we get
$$
\sum_{k=0}^{n-1}\cos(2\pi fk)=\frac{\cos(\pi f(n-1))\sin(\pi fn)}{\sin(\pi f)}
$$
and
$$
\sum_{k=0}^{n-1}\sin(2\pi fk)=\frac{\sin(\pi f(n-1))\sin(\pi fn)}{\sin(\pi f)}
$$
