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$$
 A: 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$.
A: Let $z=e^{\frac{\pi i}{2 n+1}}$ , then $$
\begin{aligned}
\sum_{k=1}^{n}(-1)^{k-1} z^{k} &=\frac{z\left[1-(-z)^{n}\right]}{1+z} \\
&=\frac{e^{\frac{\pi i}{2 n+1}}\left(1+(-1)^{n+1} e^{\frac{n \pi i}{2 n+1}}\right)}{1+e^{\frac{\pi i}{2 n+1}}}
\end{aligned}
$$
Multiplying both the numerator and denominator by $e^{-\frac{\pi i}{2(2 n+1)}}$ yields
$$
\begin{aligned}\sum_{k=1}^{n}(-1)^{k-1} z^{k}& = \frac{e^{\frac{\pi i}{2(2 n+1)}}+(-1) ^{n+1} e^{\left(\frac{\pi i}{2(2 n+1)}+\frac{n \pi i}{2 n+1}\right)}}{e^{\frac{\pi i}{2(2 n+1)}}+e^{-\frac{\pi i}{2(2 n+1)}}}\\ &= \frac{e^{\frac{\pi i}{2(2 n+1)}}+(-1)^{n+1} e^{\frac{\pi}{2} i}}{e^{\frac{\pi i}{2(2 n+1)}+} e^{-\frac{\pi i}{2(2 n+1)}}}\\&=  \frac{\cos \left(\frac{\pi}{2(2 n+1)}\right)+i \sin \left(\frac{\pi}{2(2 n+1)}\right)+(-1)^{n+1} i}{2 \cos \left(\frac{\pi}{2(2 n+1)}\right)} \qquad\qquad (*)
\end{aligned}  $$
Comparing the real parts of (*) yields
$$
\sum_{k=1}^{n}(-1)^{k-1} \cos \left(\frac{k \pi}{2 n+1}\right)=\frac{1}{2} $$
By the way, comparing the imaginary parts of (*) gives
$$
\sum_{k=1}^{n}(-1)^{k-1} \sin \left(\frac{k \pi}{2 n+1}\right)=\frac{1}{2}\left[\tan \left(\frac{\pi}{2(2 n+1)}\right)+(-1)^{n+1} \sec \left(\frac{\pi}{2(2 n+1)}\right)\right]
$$
