Why is $\lim_{x \to 0} (1+f(x))^\frac{1}{g(x)} = e^l$ where $l=\lim_{x \to 0} \frac{f(x)}{g(x)}$? My textbook states that if $f(x) \to 0$ as $x \to 0$ $$\lim_{x \to 0} (1+f(x))^\frac{1}{g(x)} = e^l$$ where $$l=\lim_{x \to 0} \frac{f(x)}{g(x)}$$
I try to do this as follows and I get a different result
$$\lim_{x \to 0} (1+f(x))^\frac{1}{g(x)}= \lim_{x \to 0} ((1+f(x))^\frac{1}{f(x)})^\frac{f(x)}{g(x)}$$
And now we take the exponent out of the limit to get
$$[\lim_{x \to 0} (1+f(x))^\frac{1}{f(x)}]^\frac{f(x)}{g(x)}=e^l$$
Where $$l=\frac{f(x)}{g(x)}$$
Am I doing something wrong here because of which my $l$ is different?
 A: You are taking the limit with respect to $x$, so the RHS should not depend on $x$. Then you arrive at $\lim_{x \to 0} ((1+f(x))^\frac{1}{f(x)})^\frac{f(x)}{g(x)}$ and took the limit inside the bracket, which is not correct, since the limit will only act on the function inside the bracket. Note you can only write the limit inside a function if it exists and the function is continuous.
For example we know that $\lim_{n\rightarrow\infty}\left(1+\frac{1}{n}\right)^{n}=e,$ but $\left(\lim_{n\rightarrow\infty}\left(1+\frac{1}{n}\right)\right)^{n}=1^{n}$ since the limit acts only inside the brackets.

Let
$$L=\lim_{x \to 0} (1+f(x))^\frac{1}{g(x)}$$
then $$\ln L = \lim_{x\rightarrow 0}\ln\left((1+f(x))^{\frac{1}{g(x)}}\right) \quad(1)$$
$$\ln L = \lim_{x\rightarrow 0}\frac{\ln(1+f(x))}{g(x)}$$
$$\ln L = \lim_{x\rightarrow 0}\frac{\ln(1+f(x))}{f(x)}\frac{f(x)}{g(x)}=\lim_{x\rightarrow 0}\frac{f(x)}{g(x)}$$
$$\implies L=e^{\lim_{x\rightarrow 0}\frac{f(x)}{g(x)}}$$
provided $\lim_{x\rightarrow 0}\frac{f(x)}{g(x)}$ exist, and where I used the fact that $\lim_{x\rightarrow 0}\frac{\ln(1+f(x))}{f(x)}=1$, which can be shown by expanding in power series. Indeed $\lim_{t\rightarrow 0}\frac{\ln(1+t)}{t}=1$. Also in $(1)$ the continuity of $\ln$ and the fact that the limit inside this function exists have been used.
A: Note: we must have $f(x)>-1$ for every $x\in\text{dom}[f]$ for $(1+f(x))^\frac{1}{g(x)}$ to be well defined.
If $f$ is nonzero in a sufficiently small interval $I$ around $0$, we can write
\begin{align}
(1+f(x))^\frac{1}{g(x)} &= e^{\frac{1}{g(x)}\ln\left(1+f(x)\right)}\\
&= e^{\frac{1}{g(x)}\ln\left(1+f(x)\right)}\\
&= e^{\frac{1}{g(x)}\left[\ln\left(1+f(x)\right)-\ln(1)\right]}\\
&= e^{\frac{f(x)}{g(x)}\cdot\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)}}\\
\end{align}
Note the similarity between the expression
$$\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)}$$
and the difference quotient
$$\frac{\ln\left(1+h\right)-\ln(1)}{h}$$
In fact, since $f(x)\to 0$ as $x\to 0$, it makes sense that we should have
\begin{align}
\lim_{x\to 0}\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)} &= \left[\frac{d}{dx}\ln(x)\right]_{x=1}\\
&= 1
\end{align}
This is proven at the bottom of my answer. Taking it as a given here, we can combine it with $\lim_{x\to 0}f(x)/g(x)=l$ to get
$$\lim_{x\to 0}\left(\frac{f(x)}{g(x)}\cdot\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)}\right)=l$$
It follows from the continuity of the exponential function that
$$\lim_{x\to 0}e^{\frac{f(x)}{g(x)}\cdot\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)}}=e^l$$
Proof of the limit: Fix an arbitrary $\varepsilon>0$. We want to show that there's a $\delta>0$ such that for every real $x$ where our expression is well-defined,
$$0<|x-0|<\delta\implies\left|\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)}\right|<\varepsilon$$
We know that $\ln$ is differentiable at $1$, so there's a $\delta_1>0$ such that for every sufficiently small $h$,
$$0<|h-0|<\delta_1\implies\left|\frac{\ln\left(1+h\right)-\ln(1)}{h}\right|<\varepsilon$$
We know that $f(x)\to 0$ as $x\to 0$. If we assume further that $f$ is nonzero in a neighborhood around $0$, then there's a $\delta>0$ such that
$$0<|x-0|<\delta\implies 0<\left|f(x)-0\right|<\delta_1$$
Thus, if $0<|x-0|<\delta$, then $0<\left|f(x)-0\right|<\delta_1$, so
$$\left|\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)}\right|<\varepsilon$$
This argument applies to every positive $\varepsilon$, so we've proven that
$$\lim_{x\to 0}\frac{\ln\left(1+f(x)\right)-\ln(1)}{f(x)}=1$$
