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)?$
 A: HINT:
$$\dfrac1{\sin2y}+\dfrac1{\tan2y}=\dfrac{2\cos^2y-1+1}{2\sin y\cos y}=\dfrac1{\tan y}$$
Put $2y=2^nx$ and recognize the pattern to find $$\dfrac1{\tan2^nx}+\sum_{k=1}^n\dfrac1{\sin2^kx}=\dfrac1{\tan x}$$
A: 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$.
A: Here, we present a quick way forward that circumvents simplifying $g(x)$ in closed form by simply using equivalents.  First, we note that for $x\to0$
$$\begin{align}
g(x)&=\sum_{k=1}^n \csc(2^k x)+\cot(2^nx)\\\\ &\sim \frac1x\sum_{k=1}^n 2^{-k}+\frac{1}{2^n x} \\\\
&=\frac1x\left(\frac{(1/2)-(1/2)^{n+1}}{1-(1/2)}\right) +\frac{1}{2^n x}\\\\
&=\frac{1}{x}
\end{align}$$
In addition, for $x\to 0$, $\cos(x) \sim 1-\frac12x^2$ and $\sec(x)\sim 1+\frac12 x^2$.  Therefore, we can write
$$\cos^{g(x)}(x)+\sec^{\csc(x)}(x)\sim \left(1-\frac12x^2\right)^{1/x}+\left(1+\frac12x^2\right)^{1/x} \tag 1$$
Taking the limit of both sides of $(1)$ yields the expected result
$$\begin{align}
\lim_{x\to 0}\left(\cos^{g(x)}(x)+\sec^{\csc(x)}(x)\right)&=\lim_{x\to 0}\left(\left(1-\frac12x^2\right)^{1/x}+\left(1+\frac12x^2\right)^{1/x}\right)\\\\
&=\lim_{x\to 0}\left(e^{-x/2}+e^{x/2}\right)\\\\
&=2
\end{align}$$
A: Instead of trying to calculate $g(x)$, you should do the following: Since you are working in a vicinity of $x=0$ then you should make a Taylor expansion of the trigonometric functions around $0$. Also, notice that when $x$ is small, $f(x)\simeq \frac{1}{\sin(2x)}$, and you can forget about the remaining $n-1$ terms in the sum.
When you do this, you should be arriving to something like this:
\begin{equation}
\lim_{x\rightarrow 0} \left( \left(1-\frac{x^2}{2} \right)^{\left(2x \right)^{-1} + \left(2^n x \right)^{-1}}+ \left(1+\frac{x^2}{2} \right)^{x^{-1}} \right)
\end{equation}
Then make a Taylor expansion again around zero (up to first order is enough), and then apply the limit.
Finally check your answer on Mathematica or something similar.
A: The following holds:
$$g(x)=\sum^{n}_{k=1} \frac{1}{\sin 2^kx}+\dfrac{1}{\tan 2^nx},$$
$$g(x)=\sum^{n-1}_{k=1} \frac{1}{\sin 2^kx}+(\frac{1}{\sin 2^nx}+\dfrac{1}{\tan 2^nx}),$$
$$g(x)=\sum^{n-1}_{k=1} \frac{1}{\sin 2^kx}+\dfrac{1}{\tan 2^{n-1}x},$$
$$g(x)=\sum^{n-2}_{k=1} \frac{1}{\sin 2^kx}+(\dfrac{1}{\sin{2^{n-1}x}}+\dfrac{1}{\tan 2^{n-1}x}),$$
$$g(x)=\sum^{n-2}_{k=1} \frac{1}{\sin 2^kx}+\dfrac{1}{\tan 2^{n-2}x},$$
$$\vdots$$
$$g(x)=\frac{1}{\sin{2x}}+\frac{1}{\tan{2x}}=\tan{x}.$$
Therefore, we need to calculate $$\lim_{x\to 0} \bigg( (\cos x)^{\tan{x}}+\bigg(\frac{1}{\cos x} \bigg)^{\frac{1}{\sin x}} \bigg).$$
Since
$$(\cos x)^{\tan{x}}+\bigg(\frac{1}{\cos x} \bigg)^{\frac{1}{\sin x}}=e^{\tan{x}\ln{\cos{x}}}+e^{-\frac{1}{\sin{x}}\ln{\cos{x}}}$$
$$(\cos x)^{\tan{x}}+\bigg(\frac{1}{\cos x} \bigg)^{\frac{1}{\sin x}}=e^{\tan{x}\ln{(1+2\sin^2{\frac{x}{2}}})}+e^{-\frac{1}{\sin{x}}\ln{(1+2\sin^2{\frac{x}{2}}})}$$ 
and $$\ln{(1+2\sin^2{\frac{x}{2}}})\sim 2\sin^2{\frac{x}{2}},$$
we have
$$\lim_{x\to 0} \bigg( (\cos x)^{\tan{x}}+\bigg(\frac{1}{\cos x} \bigg)^{\frac{1}{\sin x}} \bigg)=\lim_{x\to 0} \bigg ( e^{\tan{x} *2\sin^2{\frac{x}{2}}} + e^{-\frac{1}{\sin{x}}*2\sin^2{\frac{x}{2}}} \bigg)$$
$$\lim_{x\to 0} \bigg( (\cos x)^{\tan{x}}+\bigg(\frac{1}{\cos x} \bigg)^{\frac{1}{\sin x}} \bigg)=\lim_{x\to 0} \bigg ( e^{\tan{x} *2\sin^2{\frac{x}{2}}} + e^{-\tan{\frac{x}{2}}} \bigg)=e^0+e^0=2$$
