Motivation:
I was initially asked to compute the sum
$$
\sum_{k=1}^n \cos(k)
$$
I was able to find a closed-form expression for it. This led me to a more general question: is it possible to find a closed form for
$$
\sum_{k=1}^n \cos^r(k)
$$ where $r,n \in \mathbb{N}$?
My attempt:
I attempted to derive a closed-form expression for the case where $r$ is even. I suspect that the odd case to be solvable using a similar method (if it worked for the evens), but I haven’t worked it out yet. Here's what I did for the even case, assuming $r$ is even and that $r/2=m$:
$$\sum\limits_{k=1}^n\cos^{2m}(k)$$ $$=2^{-2m}\sum\limits_{k=1}^n\left(e^{ik}+e^{ik}\right)^{2m}$$ $$=2^{-2m}\sum\limits_{k=1}^n\sum_{j=0}^{2m}\dbinom{2m}{j}e^{i(2m-2j)k}$$ $$=2^{-2m}\sum\limits_{k=1}^n\left(\dbinom{2m}{m}+2\sum_{j=0}^{m-1}\dbinom{2m}{j}\cos((2m-2j)k)\right)$$ $$=\frac{\dbinom{2m}{m}}{2^m}n+2^{-{2m-1}}\sum_{j=0}^{m-1}\dbinom{2m}{j}\sum\limits_{k=1}^n\cos((2m-2j)k)$$ $$=\frac{\dbinom{2m}{m}}{2^{2m}}n+ 2^{-2m}\sum_{j=0}^{m-1}\dbinom{2m}{j}\left(1+\frac{\sin((2n+1)(m-j)}{\sin(m-j)}\right)$$ $$= \frac{\dbinom{2m}{m}}{2^{2m}}n+2^{-2m} \left(\frac{2^m-\binom{2m}{m}}{2}\right)+ 2^{-2m}\sum_{j=0}^{m-1}\dbinom{2m}{j}\left(\frac{\sin((2n+1)(m-j))}{\sin(m-j)}\right)$$ $$=\frac{1}{2}+\frac{\dbinom{2m}{m}}{2^{2m}}(n-1/2)+2^{-2m}\sum_{j=0}^{m-1}\dbinom{2m}{j}\left(\frac{\sin((2n+1)(m-j))}{\sin(m-j)}\right)$$
I couldn't find a closed form for the last sum $$ \sum_{j=0}^{m-1} \binom{2m}{j} \cdot \frac{\sin\left((2n+1)(m-j)\right)}{\sin(m-j)} $$