Alternating sum of roots of unity $\sum_{k=0}^{n-1}(-1)^k\omega^k$ Consider the roots of unity of $z^n = 1$, say $1, \omega, \ldots, \omega^{n-1}$ where $\omega = e^{i\frac{2\pi}n}$.
It is a well known result that $\sum_{k=0}^{n-1}\omega^k = 0$, but what if we want to consider the alternating sum? I'm interested in

Finding the value of $S = 1 - \omega +\omega^2-\ldots +(-1)^{n-1}\omega^{n-1}$

Keeping in mind that $1, \omega, \ldots, \omega^{n-1}$ are the vertex of a regular $n$-gon in the plane, it is easy to see that when $n$ is even, $S =  0$
The problem arises when $n$ is odd. Here's what I've done so far: Take $x=\frac{2\pi}n$, then
$$S = \sum_{k=0}^{n-1}(-1)^k\omega^k = \sum_{k=0}^{n-1}(-1)^k(\cos kx +i \sin kx)$$
Dealing with the real part, we notice for $k=1,2,\ldots,n-1$ that
$$\cos (n-k)x = \cos (2\pi k -kx) = \cos kx$$ 
Since $n-k$ and $k$ have different parity (remember $n$ is odd), we can see that $$\sum_{k=0}^{n-1}(-1)^k(\cos kx) = 1 + \sum_{k=1}^{n-1}(-1)^k(\cos kx)=1$$
But I have no idea on how to deal with the imaginary part. Asking almighty Wolfram, I got that
$$\sum_{k=0}^{n-1}(-1)^k(\sin k\phi)=\sec(\frac \phi2) \sin(\frac {(n-1)(\phi+\pi)}2)\sin(\frac{n(\phi+\pi)}2)$$ 
Hence
$$\sum_{k=0}^{n-1}(-1)^k(\sin kx) = \sec(\frac\pi n)\sin(\frac{\pi(n-1)(2+n)}{2n})\sin(\frac{\pi(2+n)}2)$$
In summary, I've got two questions:
a) How do you deduce the $\sum_{k=0}^{n-1}(-1)^k(\sin k \phi )$ formula?
b) Is there an alternative way to solve the original question?
Thanks in advance
 A: As $(-1)^r\cdot w^r=(-w)^r,$
$$S_{n-1}=\sum_{r=0}^{n-1}(-w)^r=\dfrac{1-(-w)^n}{1-(-w)}$$
If $n$ is odd,
$$S_{n-1}=\dfrac{1-(-1)}{1+w}=\dfrac2{1+\cos\dfrac{2\pi}n+i\sin\dfrac{2\pi}n}=\dfrac{\cos\dfrac{\pi}n-i\sin\dfrac{\pi}n}{\cos\dfrac{\pi}n}$$
A: For a), I would rewrite $\sin$ using Euler formula and then use the sum of the terms of a geometric sequence, and then a lot of calculations... But :
For b), why not simply using the same tip for S directly ? $$S = \sum_{k=0}^{n-1}(-1)^k\omega^k = \sum_{k=0}^{n-1}(-1)^ke^{\frac {2ik\pi} n}=\frac {1-(-1)^{n}e^{2i \pi}}{1+e^{\frac{2i\pi} n}}=\frac {1-(-1)^n} {1+e^{\frac{2i\pi} n}} $$
We clearly see that $S=0$ for n even.
A: Starting from what you wrote :
$$S =\sum_{k=0}^{n-1}(-1)^k\, \big(\cos (kx) +i \sin (kx)\big)=\sum_{k=0}^{n-1}(-1)^k\,e^{ikx}=\frac{1-(-1)^n e^{i n x}}{1+e^{i x}}$$ Now,  manipulate the result to extract the real and imaginary parts; this leads, after using trigonometric identities, to $$S_1=\sum_{k=0}^{n-1}(-1)^k\, \cos (kx)=\sec \left(\frac{x}{2}\right) \sin \left(\frac{1}{2} n (x+\pi )\right) \cos
   \left(\frac{1}{2} (n-1) (x+\pi )\right) $$ $$S_2=\sum_{k=0}^{n-1}(-1)^k\, \sin(kx)=\sec \left(\frac{x}{2}\right)\sin
   \left(\frac{1}{2} n (x+\pi )\right) \sin \left(\frac{1}{2} (n-1) (x+\pi )\right) $$ Now, setting $x=\frac {2\pi} n$, we get $$S_1=\frac{1}{2} (1-\cos (\pi  n))$$ $$S_2=-\sin \left(\frac{\pi  n}{2}\right) \cos \left(\frac{\pi }{n}-\frac{\pi  n}{2}\right)
   \sec \left(\frac{\pi }{n}\right)$$
