I have the solution for $\sum_{k=1}^n \cos(kx)$:
\begin{align} \sum_{k=1}^n \cos(kx) & = \Re\left(\sum_{k=1}^n e^{ikx}\right)\\ & = \Re\left(e^{ix} {e^{inx}-1 \over e^{ix}-1}\right) \\ & = \Re\left({e^{ix} e^{inx \over 2} \over e^{ix \over 2}} {e^{inx \over 2} - e^{-inx \over 2} \over e^{ix \over 2} - e^{-ix\over2}}\right)\\ & = \Re\left( e^{i(n+1)x \over 2} {\sin{nx\over2} \over \sin{x \over 2}}\right)\\ & = {\sin{nx\over2} \over \sin{x \over 2}} \cos\left({(n+1)x\over2}\right) \end{align}
but if $e^{ix}=1$ i am dividing trough 0 in line 2. So i know that in this case $e^{ix} \neq 1$. So my question is: What is the $\sum_{k=1}^n \cos(kx)$ if $e^{ix}=1$.
$e^{ix}=1$ means $x =2m\pi$ with $m \in \mathbb N$. And in that case the sum you’re looking for is equal to $n$.