Evaluation of given limit when $f(x)=\sum^{n}_{k=1} \frac{1}{\sin 2^kx}$ and $g(x)=f(x)+\frac{1}{\tan 2^nx}$ 
Question Statement:-
If $\displaystyle f(x)=\sum^{n}_{k=1} \frac{1}{\sin 2^kx}$ and $g(x)=f(x)+\dfrac{1}{\tan 2^nx}$, then find the value of
$$\lim_{x\to 0} \bigg( (\cos x)^{g(x)}+\bigg(\frac{1}{\cos x} \bigg)^{\frac{1}{\sin x}} \bigg)$$

I am not able to find value of $g(x)$. Could someone help me as how to calculate value of $g(x)?$

Basically, what you have to show (lab bhattacharjee gave you the hint while I was typing) is that $$f(x)=\cot (x)-\cot \left(2^n x\right)$$ which makes $$g(x)=\cot (x)$$ Now consider $$A=\cos(x)^{\cot(x)}\qquad , \qquad B=\bigg(\frac{1}{\cos (x)} \bigg)^{\frac{1}{\sin (x)}} $$ So $$\log(A)=\cot(x) \log(\cos(x))\qquad , \qquad \log(B)=-\frac{1}{\sin (x)}\log(\cos(x))$$ and use Taylor series to get $$\log(A)=-\frac{x}{2}+\frac{x^3}{12}+O\left(x^4\right)$$ $$\log(B)=\frac{x}{2}+\frac{x^3}{6}+O\left(x^4\right)$$ Now, using $y=e^{\log(y)}$ and Taylor again $$A=1-\frac{x}{2}+\frac{x^2}{8}+\frac{x^3}{16}+O\left(x^4\right)$$ $$B=1+\frac{x}{2}+\frac{x^2}{8}+\frac{3 x^3}{16}+O\left(x^4\right)$$ $$A+B=2+\frac{x^2}{4}+\frac{x^3}{4}+O\left(x^4\right)$$ which shows the limit and how it is approached.
For illustration puroposes, let us compute the value of the expression for $x=\frac \pi 4$. The exact value is $$\frac{1}{\sqrt{2}}+2^{\frac{1}{\sqrt{2}}}\approx 2.33963$$ while the above formula gives $$2+\frac{\pi ^2}{64}+\frac{\pi ^3}{256}\approx 2.27533$$ and we are far away from $x=0$.
