<s>[INST] How to prove $2\sum_{k=1}^n{(-1)^{k-1} \cos\frac{k\pi}{2n+1}} = 1$ 
Prove $$2\sum_{k=1}^n{(-1)^{k-1} \cos\frac{k\pi}{2n+1}} = 1$$

I got this question when I was going through some basic trigonometric identities as follows
$2(\cos\frac{\pi}{5}-\cos\frac{2\pi}{5}) =1\tag1$
very much straightforward to recognise
$2(\cos\frac{\pi}{7}-\cos\frac{2\pi}{7} + \cos\frac{3\pi}{7})=1\tag2$
Following steps proves the identity
$8\cos\frac{\pi}{7}\cdot\cos\frac{2\pi}{7}\cdot\cos\frac{4\pi}{7} = -1$
$4\cos\frac{\pi}{7}[2\cos\frac{4\pi}{7}\cdot\cos\frac{2\pi}{7}] = -1$
$4\cos\frac{\pi}{7}[\cos\frac{6\pi}{7}+ \cos\frac{2\pi}{7}] =-1    $
$4\cos\frac{\pi}{7}[\cos\frac{2\pi}{7}-\cos\frac{\pi}{7}] =-1    $
$4\cos\frac{\pi}{7}\cdot\cos\frac{2\pi}{7} - 4\cos^{2}\frac{\pi}{7} = -1$
Further simplification will lead to equality 2
$2(\cos\frac{\pi}{9}-\cos\frac{\pi}{9} + \cos\frac{3\pi}{9}- \cos\frac{4\pi}{9}) = 1$
by using transformation formula we can prove above one also
But when it comes to following equalities
$2(\cos\frac{\pi}{11}-\cos\frac{2\pi}{11} + \cos\frac{3\pi}{11}- \cos\frac{4\pi}{11}+ \cos\frac{5\pi}{11} )= 1$
$2(\cos\frac{\pi}{13}-\cos\frac{2\pi}{13} + \cos\frac{3\pi}{13}- \cos\frac{4\pi}{13}+ \cos\frac{5\pi}{13} -\cos\frac{6\pi}{13} )= 1$
I was able to check the results with brute force in Wolfram|Alpha for above equalities, but not able to get the steps properly even though I tried manually
My question is how to generalise the summation formula and is there any method other than trigonometric approach?
$$2\sum_{k=1}^n{(-1)^{k-1} \cos\frac{k\pi}{2n+1}} = 1$$
 [/INST] Let's use the identity $(-1)^a\cos x=\cos(a\pi-x)$. Therefore,
$$\begin{align}&2\sum_{k=1}^n{(-1)^{k-1} \cos\frac{k\pi}{2n+1}} \\= &2\sum_{k=1}^n\cos\left((k-1)\pi-\frac{k\pi}{2n+1}\right)\\=&-2\sum_{k=1}^n\cos\frac{2nk\pi}{2n+1}\end{align}$$
Take a factor $\csc\left(\frac{n\pi}{2n+1}\right)$ and then use product to sum formula.
$$\begin{align}&-\csc\left(\frac{n\pi}{2n+1}\right)\sum_{k=1}^n2\cos\frac{2nk\pi}{2n+1}\sin\frac{n\pi}{2n+1}\\=&-\csc\frac{n\pi}{2n+1}\sum_{k=1}^n\left[\sin\left((2k+1)\frac{n\pi}{2n+1}\right)-\sin\left((2k-1)\frac{n\pi}{2n+1}\right)\right]\end{align}$$
This is a telescoping sum and we are left with, $$\csc\left(\frac{n\pi}{2n+1}\right)\left[\sin\left(\frac{n\pi}{2n+1}\right)-\sin(n\pi)\right]$$
which is clearly equal to $1$.
</s>