Find $\lim_{x\to0}\frac{(\tan(\frac{\pi}{4}+x))^{\frac{1}{x}}-e^2}{x^2}$ Find $\lim_{x\to0}\frac{(\tan(\frac{\pi}{4}+x))^{\frac{1}{x}}-e^2}{x^2}$

My attempt:
$\lim_{x\to0}(\tan(\frac{\pi}{4}+x))^{\frac{1}{x}}=e^2$
So the required limit is in $\frac{0}{0}$ form.
Then i used L hospital form.
$\lim_{x\to0}\frac{e^2(\frac{2}{x\cos 2x}-\frac{1}{x^2}\log(\frac{1+\tan x}{1-\tan x}))}{2x}$
I am stuck here.
 A: You may observe that, by the Taylor expansion, you get, as $x \to 0$,
$$
\begin{align}
\tan x&=x+\frac{x^3}3+O(x^5) \tag1
\\ \frac{1+\tan x}{1-\tan x}&=1+2 x+2 x^2+\frac{8 x^3}{3}+O(x^5) \tag2
\end{align}
$$ giving
$$
\begin{align}
\log\left(\frac{1+\tan x}{1-\tan x}\right)&=2 x+\frac{4 x^3}{3}+O(x^5) \tag3
\\\\\frac1x\log\left(\frac{1+\tan x}{1-\tan x}\right)&=2 +\frac{4 x^2}{3}+O(x^4) \tag4. 
\end{align}
$$ Then
$$
\left(\tan\left(\frac{\pi}{4}+x\right)\right)^{\large \frac1x}-e^2=e^{\large \frac1x\log\left(\frac{1+\tan x}{1-\tan x}\right)}-e^2 \tag5
$$ rewrites
$$
\left(\tan\left(\frac{\pi}{4}+x\right)\right)^{\large \frac1x}-e^2=e^2 \left(e^{\large \frac{4 x^2}{3}+O(x^4)}-1\right)=e^2 \left(\frac{4 x^2}{3}+O(x^4)\right)\tag6
$$
yielding, as $x \to 0$,

$$
\lim_{x\to 0}\frac{\left(\tan\left(\frac{\pi}4+x\right)\right)^{\large \frac1x}-e^2}{x^2}
= \frac{4e^2}3. \tag7
$$

A: Note that $$\tan\left(\frac{\pi}{4} + x\right) = \frac{1 + \tan x}{1 - \tan x}$$ and therefore
\begin{align}
L &= \lim_{x \to 0}\dfrac{\left(\tan\left(\dfrac{\pi}{4} + x\right)\right)^{1/x} - e^{2}}{x^{2}}\notag\\
&= \lim_{x \to 0}\dfrac{\left(\dfrac{1 + \tan x}{1 - \tan x}\right)^{1/x} - e^{2}}{x^{2}}\notag\\
&= \lim_{x \to 0}\dfrac{\exp\left(\dfrac{1}{x}\log\left(\dfrac{1 + \tan x}{1 - \tan x}\right)\right) - e^{2}}{x^{2}}\notag\\
&= e^{2}\lim_{x \to 0}\dfrac{\exp\left(\dfrac{1}{x}\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right) - 2\right) - 1}{x^{2}}\notag\\
&= e^{2}\lim_{x \to 0}\dfrac{\exp\left(\dfrac{1}{x}\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right) - 2\right) - 1}{\dfrac{1}{x}\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right) - 2}\cdot\dfrac{\dfrac{1}{x}\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right) - 2}{x^{2}}\notag\\
&= e^{2}\lim_{t \to 0}\dfrac{\exp(t) - 1}{t}\cdot\lim_{x \to 0}\dfrac{\dfrac{1}{x}\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right) - 2}{x^{2}}\notag\\
&= e^{2}\lim_{x \to 0}\dfrac{\dfrac{1}{x}\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right) - 2}{x^{2}}\notag\\
&= e^{2}\lim_{x \to 0}\dfrac{\log\left(\dfrac{1 + \tan x}{1 - \tan x}\right) - 2x}{x^{3}}\notag\\
&= e^{2}\lim_{x \to 0}\dfrac{\log\left(\dfrac{1 + \tan x}{1 - \tan x}\right) - 2\tan x + 2\tan x - 2x}{x^{3}}\notag\\
&= e^{2}\left(\lim_{x \to 0}\dfrac{\log\left(\dfrac{1 + \tan x}{1 - \tan x}\right) - 2\tan x}{x^{3}} + 2\lim_{x \to 0}\frac{\tan x - x}{x^{3}}\right)\notag\\
&= e^{2}\left(\lim_{x \to 0}\dfrac{\log\left(\dfrac{1 + \tan x}{1 - \tan x}\right) - 2\tan x}{\tan^{3}x}\cdot\frac{\tan^{3}x}{x^{3}} + 2\lim_{x \to 0}\frac{\sec^{2} x - 1}{3x^{2}}\right)\text{ (via LHR)}\notag\\
&= e^{2}\left(\lim_{u \to 0}\dfrac{\log\left(\dfrac{1 + u}{1 - u}\right) - 2u}{u^{3}}\cdot 1 + \frac{2}{3}\lim_{x \to 0}\frac{\tan^{2}x}{x^{2}}\right)\text{ (putting }u = \tan x)\notag\\
&= e^{2}\left(\lim_{u \to 0}\dfrac{2\left(u + \dfrac{u^{3}}{3} + o(u^{3})\right) - 2u}{u^{3}}\cdot 1 + \frac{2}{3}\right)\notag\\
&= e^{2}\left(\frac{2}{3} + \frac{2}{3}\right)\notag\\
&= \frac{4e^{2}}{3}\notag
\end{align}
The simplifications done above are obvious and are aimed to simplify the use of series expansions and L'Hospital Rule. Also note that the variable $$t = \frac{1}{x}\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right) - 2 = \dfrac{\log\left(1 + \dfrac{2\tan x}{1 - \tan x}\right)}{\dfrac{2\tan x}{1 - \tan x}}\cdot\dfrac{\tan x}{x}\cdot\frac{2}{1 - \tan x} - 2$$ tends to $1\cdot1\cdot 2 - 2 = 0$ as $x \to 0$ and this fact has been used in the solution provided.
As a rule I prefer to use series expansions only when they are available via memory (like binomial, exponential, logarithmic and sine/cosine series) and try to use algebraic simplification so as to limit the use of series expansion to these simple series. If I need to do complicated stuff with series (like multiplying/dividing series or finding series of composite functions) I show the evaluation of series coefficients.
A: In the same spirit as Olivier Oloa's answer.
By Taylor $$\tan(\frac{\pi}{4}+x))=1+2 x+2 x^2+\frac{8 x^3}{3}+\frac{10 x^4}{3}+\frac{64 x^5}{15}+O\left(x^6\right)$$ $$\log\Big(\tan(\frac{\pi}{4}+x)) \Big)=2 x+\frac{4 x^3}{3}+\frac{4 x^5}{3}+O\left(x^6\right)$$ $$\frac 1x\log\Big(\tan(\frac{\pi}{4}+x)) \Big)=2+\frac{4 x^2}{3}+\frac{4 x^4}{3}+O\left(x^5\right)$$ $$\exp\Big(\frac 1x\log\Big(\tan(\frac{\pi}{4}+x)) \Big)\Big)=\Big(\tan(\frac{\pi}{4}+x)) \Big)^{\frac 1x}=e^2+\frac{4 e^2 x^2}{3}+\frac{20 e^2 x^4}{9}+O\left(x^5\right)$$ $$\frac{(\tan(\frac{\pi}{4}+x))^{\frac{1}{x}}-e^2}{x^2}=\frac{4 e^2}{3}+\frac{20 e^2 x^2}{9}+O\left(x^3\right)$$ which shows the limit and how it is approached.
To show how good is the approximation : using $x=\frac 1{10}$, the expression is $\approx 10.0191$ while the approximation gives $\frac{61 e^2}{45}\approx 10.0163$ that is to say a relative error of less than $0.03$%.
