Ratio of $\frac{\sin x_1 }{\sin x_2}$ where $f(x_1)=f(x_2)$ for a trigonometric sum $f(x)$ If $f(x) = \cos(x+a_1)+\frac12\cos(x+a_2)+\frac14\cos(x+a_3)+\cdots+\frac1{2^{n-1}}\cos(x+a_n)$, where $a_1, a_2, ... a_n$ are some constants and $f(x_1)-f(x_2)=0$, where $x_2 \neq m\pi$, find
$$\frac{\sin x_1}{\sin x_2}+\frac{\left|\sin x_1\right|}{\sin x_2}+\frac{\sin x_1}{\left|\sin x_2\right|}+\left|\frac{\sin x_1}{\sin x_2}\right|$$ 
A friend gave me this one and I tried using
$$0=f(x_1)-f(x_2) = 2\sin\left(\frac{x_2-x_1}2 \right)\left[\sin\left(\frac{x_1+x_2}2+a_1 \right)+\frac12\sin\left(\frac{x_1+x_2}2+a_2 \right) +\dots\right]$$
which gives one possibility $x_2=x_1+2k\pi$ so the desired value can be $0$ or $4$.  However I also see a possibility of $a_i=-\frac{x_1+x_2}2+2k_i\pi$ which leads to a lot of possibilities for the value.  Am I doing this incorrectly or is there something missing in the question (my friend swears no)?
 A: Unless you are considering complex numbers, you are probably trying too hard (a mistake I also made on this problem). Instead of fixing $\cos(a+b)-\cos(a-b)\not=2\sin(a)\cos(b)$ you might fix your attention on the final result, perhaps expanding $|\sin x_1|\in\pm\sin x_1$ and $|\sin x_2|\in\pm\sin x_2$
A: Use the addition formula for cosine 
$\cos(A+B) = \cos A \cos B - \sin A \sin B$
to write
$f(x) = \cos{x} \displaystyle\sum\limits_{i=1}^{n}{\dfrac{2}{2^{n-k}}\cos a_k} - \sin{x} \displaystyle\sum\limits_{i=1}^{n}{\dfrac{2}{2^{n-k}}\sin a_k}$
Regard the summations as fixed since you are given $a_1,a_2,\dots,a_n$
Let $\sigma_c = \displaystyle\sum\limits_{i=1}^{n}{\dfrac{2}{2^{n-k}}\cos a_k} \tag{1}$ and $\sigma_s = \displaystyle\sum\limits_{i=1}^{n}{\dfrac{2}{2^{n-k}}\sin a_k} \tag{2}$ 
Then you have:
$f(x) = \sigma_c \cos{x} - \sigma_s \sin{x} \tag{3}$
Since $f(x_1)-f(x_2)=0$, you must have
$\sigma_c \cos{x_1} - \sigma_s \sin{x_1} = \sigma_c \cos{x_2} - \sigma_s \sin{x_2} \tag{4}$
and so finding a $\theta$ such that $\tan\theta = \dfrac{\sigma_s}{\sigma_c} \tag{5}$, you can divide (4) through by $\sqrt{{\sigma_c}^2 + {\sigma_c}^2}$ and set $\sigma_s = \sin\theta, \sigma_c = \cos\theta$ to get
$\cos\theta \cos x_1 - \sin\theta \sin x_1 = \cos\theta \cos x_2 - \sin\theta \sin x_2$
which is really
$\cos(\theta + x_1) = \cos(\theta + x_2) \tag{6}$ 
and which has two sets of solutions.
The first is (as you had it)
$\boxed{x_2 = x_1 + 2\pi n, n\in\mathbb{Z}} \tag{a}$
Now from (5) without loss of generality, set
$\theta = \arctan\Big(\dfrac{\sigma_s}{\sigma_c}\Big) \tag{6}$ 
The other set of solutions is given by setting $\theta + x_2 = -(\theta + x_1)$ [from the identity $\cos(-\alpha) = \cos \alpha$] and then allowing for multiples of $2\pi$:
$x_2 = -x_1 - 2\theta + 2\pi n, n\in\mathbb{Z}$ 
so finally by (6):
$\boxed{x_2 = -x_1 - 2\arctan\Big(\dfrac{\sigma_s}{\sigma_c}\Big) + 2\pi n, n\in\mathbb{Z}} \tag{b}$
with ${\sigma_c},{\sigma_s}$ given by (1) and (2)
