<s>[INST] Evaluating $\sum_{r=1}^n \frac{\tan(x/2^r)}{2^{r-1}\cos(x/2^{r-1})}$ 
I was asked to find the sum of
  $$\sum_{r=1}^n  \dfrac{\tan \dfrac{x}{2^r}}{2^{r-1}\cos\dfrac{x}{2^{r-1}}}$$

I proceeded by breaking $\tan x$ into $\sin x$ and $\cos x$ and writing numerator as follows
$$\sin\left(\frac{x}{2^{r-1}}-\frac{x}{2^r} \right)$$
then by opening brackets and simplifying I got
$$\frac{1}{2^{r-1}}\left(\tan\frac{x}{2^{r-1}}-\tan\frac{x}{2^r}\right)$$
But I couldn't proceed from here. 
Any help will be appreciated
 [/INST] $$\sum^{n}_{k=1}\frac{\tan(x/2^k)}{2^{k-1} \cos(x/2^{k-1})} = \sum^{n}_{k=1}\frac{\sin^2(x/2^k)}{2^{k-1}\sin (x/2^k)\cos(x/2^k)\cos(x/2^{k-1})}$$
$$=2\sum^{n}_{k=1}\frac{1-\cos(x/2^{k-1})}{2^{k-1}\sin(x/2^{k-1})\cos(x/2^{k-1})}$$
$$= 2\sum^{n}_{k=1}\bigg[\frac{1}{2^{k-2}\sin(x/2^{k-2})}-\frac{1}{2^{k-1}\sin(x/2^{k-1})}\bigg]$$
$$ = \bigg[\frac{2}{\sin x}-\frac{2}{2^n \sin (2x/2^n)}\bigg].$$
</s>