For example:
$$\cos\frac{\pi}{7} + \cos\frac{3\pi}{7} + \cos\frac{9\pi}{7}$$
In this example, there are only a few terms, and we can use things like $\cos(9\pi/7) = -\cos(2\pi/7)$ and complex numbers to solve it. I am trying to find if there is a closed formula to a generic case
$$\cos(x) + \cos(x\cdot q) + \cos (x\cdot q^2) + \cdots + \cos(x\cdot q^n)$$