Verify my formula for $\sum_{n=0}^x\cos(n)=\dots$ I was wondering if I could use permutation to find the formula for $\sum_{n=0}^x\cos(n)$, and this is my work.
$$\sum_{n=0}^x\cos(n)+\cos(x+1)=\cos(0)+\sum_{n=1}^{x+1}\cos(n)$$
$$\sum_{n=0}^x\cos(n)+\cos(x+1)=1+\sum_{n=0}^x\cos(n+1)$$
$$=1+\sum_{n=0}^x\cos(n)\cos(1)-\sin(n)\sin(1)$$
$$\sum_{n=0}^x\cos(n)+\cos(x+1)=1+\cos(1)\sum_{n=0}^x\cos(n)-\sin(1)\sum_{n=0}^x\sin(n)$$
Similarly, I tried to solve for $\sum_{n=0}^x\sin(n)$ with permutation.
$$\sum_{n=0}^x\sin(n)+\sin(x+1)=\sin(0)+\sum_{n=1}^{x+1}\sin(n)$$
$$\sum_{n=0}^x\sin(n)+\sin(x+1)=\sum_{n=0}^x\sin(n+1)$$
$$=\sum_{n=0}^x\sin(n)\cos(1)+\cos(n)\sin(1)$$
$$\sum_{n=0}^x\sin(n)+\sin(x+1)=\cos(1)\sum_{n=0}^x\sin(n)+\sin(1)\sum_{n=0}^x\cos(n)$$
This leaves me with two equations, which I will use $\sum_{n=0}^x\sin(n)=S$ and $\sum_{n=0}^x\cos(n)=C$ for simplification.
$$C+\cos(x+1)=1+\cos(1)C-\sin(1)S$$
$$S+\sin(x+1)=\cos(1)S+\sin(1)C$$
Solving for $S$ in the second equation gives me
$$S=\frac{\sin(1)C-\sin(x+1)}{1-\cos(1)}$$
Substituting into the first equation
$$C+\cos(x+1)=1+\cos(1)C-\sin(1)\left(\frac{\sin(1)C-\sin(x+1)}{1-\cos(1)}\right)$$
$$C+\cos(x+1)=1+\cos(1)C+\frac{\sin(x)\sin(x+1)-\sin^2(1)C}{1-\cos(1)}$$
$$C+\cos(x+1)=1+\frac{\sin(x)\sin(x+1)}{1-\cos(1)}+\cos(1)C-\frac{\sin^2(1)C}{1-\cos(1)}$$
I simplify with $\frac{\sin^2(x)}{1-\cos(x)}=1+\cos(x)$
$$C=1-\cos(x+1)+\frac{\sin(x)\sin(x+1)}{1-\cos(1)}+\cos(1)C-(1+\cos(1))C$$
$$2C=1-\cos(x+1)+\frac{\sin(x)\sin(x+1)}{1-\cos(1)}$$
$$2C=\frac{1-\cos(1)-\cos(x+1)+\cos(1)\cos(x+1)+\sin(x)\sin(x+1)}{1-\cos(1)}$$
$$C=\frac{1-\cos(1)-\cos(x+1)+\cos(1)\cos(x+1)+\sin(x)\sin(x+1)}{2(1-\cos(1))}$$
I'm unsure if this works:

$$\sum_{n=0}^{x}\cos(n)=\frac{1-\cos(1)-\cos(x+1)+\cos(1)\cos(x+1)+\sin(x)\sin(x+1)}{2(1-\cos(1))}$$

And I was wondering someone could verify this.
I actually know that this is wrong, but I want to know where I went wrong.
 A: You can verify that your formula is incorrect by plugging in $x=0$.
Here is a much simpler approach. I'm assuming that $x$ is a nonnegative integer.
Multiply the desired sum by $\sin(1/2)$ and use the trig identity $\cos(a)\sin(b) = \frac{1}{2}(\sin(a+b) - \sin(a-b))$. This gives us a telescoping sum:
$$\begin{aligned}
\sin(1/2)\sum_{n=0}^{x}\cos(n) &= \frac{1}{2}\sum_{n=0}^{x}\left(\sin(n+1/2) - \sin(n-1/2)\right) \\
&= \frac{1}{2}(\sin(x+1/2) - \sin(-1/2))\\ 
&= \frac{1}{2}(\sin(x+1/2) + \sin(1/2))
\end{aligned}$$
Now divide both sides by $\sin(1/2)$ to obtain
$$\sum_{n=0}^{x}\cos(n) = \frac{\sin(x+1/2) + \sin(1/2)}{2\sin(1/2)}$$
A: $$\sum_{n=0}^x e^{in}=\frac{1-e^{i(x+1)}}{1-e^i}=\frac{(1-e^{i(x+1)})(1-e^{-i})}{(1-e^i)(1-e^{-i})}.$$
Taking the real part,
$$\sum_{n=0}^x \cos(n)=\frac{(1-\cos(x+1))(1-\cos(1))+\sin(x+1)\sin(1)}{1-2\cos(1)+1}=\frac{1-\cos(1)-\cos(x+1)+\cos(x+1)\cos(x)+\sin(x+1)\sin(1)}{2(1-\cos(1))}=\frac{1-\cos(1)+\cos(x)-\cos(x+1)}{2(1-\cos(1))}.$$
A: We can use a complex version of $\cos(x)=\frac{e^{ix}+e^{-ix}}2$ and the formula for the sum of a geometric series.
$$
\begin{align}
\sum_{k=0}^n\cos(k)
&=\frac12\sum_{k=0}^n\left(e^{ik}+e^{-ik}\right)\\
&=\frac12\left(\frac{e^{i(n+1)}-1}{e^i-1}+\frac{e^{-i(n+1)}-1}{e^{-i}-1}\right)\\
&=\frac12\left(\frac{e^{i\left(n+\frac12\right)}-e^{-i/2}}{e^{i/2}-e^{-i/2}}+\frac{e^{i/2}-e^{-i\left(n+\frac12\right)}}{e^{i/2}-e^{-i/2}}\right)\\
&=\frac12\left(\frac{\sin\left(n+\frac12\right)}{\sin\left(\frac12\right)}+1\right)
\end{align}
$$
