Computing the trigonometric sum $ \sum_{j=1}^{n} \cos(j) $ I have a task to compute such a sum:
$$ \sum_{j=1}^{n} \cos(j) $$
Of course I know that the answer is $$ \frac{1}{2} (\cos(n)+\cot(\frac{1}{2}) \sin(n)-1) = \frac{\cos(n)}{2}+\frac{1}{2} \cot(\frac{1}{2}) \sin(n)-\frac{1}{2} $$
but I don't have any idea how to start proving it.
 A: You could also use $\sin(n+\frac{1}{2})-\sin(n-\frac{1}{2})=2\cos n\sin\frac{1}{2}$; $\;\;$ so if we let $a=2\sin\frac{1}{2}$,
$\cos n =\frac{1}{a}\left[\sin(n+\frac{1}{2})-\sin(n-\frac{1}{2})\right]\implies$
$\cos 1+\cos2+\cos 3+\cdots+\cos(n-1)+\cos n=$
$\frac{1}{a}\left[(\sin\frac{3}{2}-\sin\frac{1}{2})+(\sin\frac{5}{2}-\sin\frac{3}{2})+(\sin\frac{7}{2}-\sin\frac{5}{2})+\cdots+(\sin(n+\frac{1}{2})-\sin(n-\frac{1}{2}))\right]=$
$\frac{1}{a}\left[\sin(n+\frac{1}{2})-\sin\frac{1}{2}\right]=\frac{1}{2\sin\frac{1}{2}}\left[\sin n\cos\frac{1}{2}+\cos n\sin\frac{1}{2}-\sin\frac{1}{2}\right]$
$=\frac{1}{2}\left[\sin n\cot\frac{1}{2}+\cos n-1\right]$
A: Using the formula for a geometric series:
$$\sum_{k=1}^Ne^{ik}=\frac{e^{i(N+1)}-1}{e^{i}-1}-1=\frac{e^{i(N+1)}-1}{e^{i}-1}\frac{e^{-i}-1}{e^{-i}-1}-1$$
Taking real parts :
\begin{align}
\sum_{k=1}^N\cos(k)&=\Re\left[\frac{\left(e^{i(N+1)}-1\right)\left(e^{-i}-1\right)}{2-2\cos(1)}\right]-1\\
&=\Re\left[\frac{e^{iN}-e^{i(N+1)}-e^{-i}+1}{2-2\cos(1)}\right]-1\\
&=\frac{\cos(N)-\cos(N+1)-\cos(1)+1}{2-2\cos(1)}-1\\
&=\frac{\cos(N)-\cos(N+1)}{2-2\cos(1)}-\frac{1}{2}\\
&=\frac{\cos(N)-\cos(N)\cos(1)+\sin(N)\sin(1)}{2-2\cos(1)}-\frac{1}{2}\\
&=\frac{\sin(N)\sin(1)}{2-2\cos(1)}-\frac{1}{2}+\frac{1}{2}\cos(N)\\
&=\frac{2\sin(N)\sin\left(\frac{1}{2}\right)\cos\left(\frac{1}{2}\right)}{4\sin^2\left(\frac{1}{2}\right)}-\frac{1}{2}+\frac{1}{2}\cos(N)\\
&=\frac{1}{2}\cot\left(\frac{1}{2}\right)\sin(N)-\frac{1}{2}+\frac{1}{2}\cos(N)\\
\end{align}
A: Let $$S_n = \sum_{j=1}^{n}\cos j.$$
Then:
$$S_n\cdot \sin\frac{1}{2}=\frac{1}{2}\sum_{j=1}^{n}\left(\sin(j+1/2)-\sin(j-1/2)\right)=\frac{1}{2}\left(\sin(n+1/2)-\sin(1/2)\right).$$
