$\lim_{ x \to 0 } \frac{e-(1+\arctan x)^{\frac{1}{x}}}{x}$ I have to evaluate this limit:
$$\lim_{ x \to 0 }  \frac{e-(1+\arctan x)^{\frac{1}{x}}}{x}$$
I have an indeterminated form $[\frac{0}{0}]$.
So I applied the Hopital rule
$$\frac{e-(1+\arctan x)^{\frac{1}{x}}}{x} \sim $$
$$-e^{\frac{\log(1+\arctan x)}{x}} \cdot \frac{\frac{x}{(1+\arctan x)(1+x^2)}-\log(1+\arctan x)}{x^2} \sim$$
$$ -e \cdot \frac{1}{x^2} \cdot \left(\frac{x}{(1+x)(1+x^2)}-x\right)
\sim +e $$
According to my book and wolfram alpha the final result should be $\frac{e}{2}$ and I don't know where I made mistakes.
 A: You can avoid the exponentials by a simple trick using the standard limit $\lim_{y\to 0}\frac{e^y-1}y=1$.
\begin{eqnarray*}\frac{e-(1+\arctan x)^{\frac{1}{x}}}{x}
& = & e\cdot \frac{\left(1-e^{\frac{\ln(1+\arctan x)-x}{x}}\right)}{x}\\
& \stackrel{y=\frac{\ln(1+\arctan x)-x}{x}}{=} & e\cdot \underbrace{\frac{1-e^y}y}_{\stackrel{x\to 0}{\longrightarrow}-1}\cdot \frac{\ln(1+\arctan x)-x}{x^2}
\end{eqnarray*}
Here I use that $\lim_{x\to 0}\frac{\ln(1+\arctan x)-x}{x} =0$, which can quickly be shown by L'Hospital.
Now, we only have to deal with
\begin{eqnarray*}\frac{\ln(1+\arctan x)-x}{x^2}
& \stackrel{L'Hosp.}{\sim} & \underbrace{\frac 1{(1+x^2)(1+\arctan x)}}_{\stackrel{x\to 0}{\longrightarrow}1}\cdot \frac{1-(1+\arctan x)(1+x^2)}{2x}
\end{eqnarray*}
Finally,
\begin{eqnarray*}\frac{1-(1+\arctan x)(1+x^2)}{2x}
& \stackrel{L'Hosp.}{\sim} & \frac{-(1+\arctan x)2x-(1+x^2)\frac 1{1+x^2}}{2}\\
& \stackrel{x\to 0}{\longrightarrow} & -\frac 12\\
\end{eqnarray*}
All together
$$\frac{e-(1+\arctan x)^{\frac{1}{x}}}{x} \stackrel{x\to 0}{\longrightarrow} e\cdot (-1) \cdot \left(-\frac 12\right) = \frac e2 $$
A: We look at the expression :
$$
-e^{\frac{\log(1+\arctan x)}{x}} \cdot \left( \frac{1}{x(1+\arctan x)(1+x^2)} - \frac{\log(1+\arctan x)}{x^2}\right)
$$
which is correctly derived.
We focus on the first term's limit : consider the limit of the exponent $\lim_{x \to 0} \frac{\log(1+\arctan x)}{x}$, where we note that we can use L'Hopital to get that this is equal to the limit of $\frac{1}{(x^2+1)(1+\arctan x)}$ which equals $1$ at $x=0$. So $\lim_{x \to 0} -e^{\frac{\log(1+\arctan x)}{x}} =-e^1= -e$ by continuity of the exponential.
For the second part, we do what you did, and get a common denominator so we can use L'Hopital. That gives :
$$
\frac{\frac{x}{(1+\arctan x)(1+x^2)} - \log(1+\arctan x)}{x^2}
$$
Now, I think the issue with your working is what has happened on the next line i.e. on the list of $\sim$s, one is wrong. The one I think is wrong, is that $-x$ should be replaced with $-x \over 2$. Let me explain.
What you tried to do, is separate the bottom $x^2$ so we get $$
\frac 1{x^2}\left(\frac{x}{(1+x^2)(1+\arctan x)} - \log(1+\arctan x)\right)
$$
up till here, everything is fine.

What you did wrong
And then you said : $-\frac{\log(1+\arctan x)}{-x}$ goes to $1$ as $x \to 0$, so replacing $-\log(1+\arctan x)$ with $-x$ in this, will still give the same answer. Similarly, $\arctan x$ looks like $x$ as $x\to 0$ so I can again replace $\arctan x$ by $x$ in the first part of the bracket and that limit will be the same. That led to :
$$
\frac 1{x^2}\left(\frac{x}{(1+x^2)(1+x)} - x\right)
$$
Now there's a problem here , and J.G. pointed it out in his now deleted answer. It is a subtlety one has to be careful of.
If you have two separate functions $f(x)$ and $g(x)$, and you are studying $\lim_{x \to 0} f(x) - g(x)$. You notice that $f(x) \sim h(x)$ and $g(x) \sim j(x)$ as $x\to 0$, and then are tempted to write $\lim_{x \to 0} f(x) -g(x) = \lim_{x \to 0} h(x) - j(x)$. Not True.
The reason why this is not true, is actually in the "hidden" terms. I will say it roughly : a "dominating" term for $f(x)$ is the power of $x$ (with coefficient) that $f$ "behaves like" as $x \to 0$. So for example, $f(x) = \log(1+x)$ would behave like $x$ as $x \to 0$. Anything that kind of lies beneath the dominating term, we refer to as the "hidden" terms. For example, $\log(1+x) \sim x + \frac{x^2}{2} + \frac{x^3}{3} + \ldots$ (found by Taylor, only for illustrative purposes), and while $x$ is the dominating term, the rest are hidden terms.
The hidden terms will come into play when you take a limit by removing the dominating : for example, $\frac{\log(1+x)  - x}{x^2} = \frac 12$. (found from Taylor series, but can be done by L'Hopital too)
Now, $f(x) \sim h(x)$ means that $f(x)$ and $h(x)$ have the same dominating term as $x\to 0$, these kind of cancel each other out when we take a ratio and the "hidden terms" don't come into play because they get "divided out" (try this with some functions) so the limit becomes $1$.
Now, imagine I take $f(x) - g(x)$. This takes the dominating terms out of the equation, sure, but the hidden terms don't get canceled out. These guys remain in the whole equation, and the problem is (like the $\frac 1{x^2}$ sitting silently on the side in your answer) if there are other terms like a $\frac 1{x^2}$ or something, these hidden terms kind of contribute. For example, $\lim_{x \to 0} x = 0$, but if $x$ was part of a huge expression and there was also a $\frac 1x$ sitting somewhere on the side I did not see, then replacing $x$ with $0$ is wrong, since with the $\frac 1x$, we get $\lim_{x \to 0} x \times \frac 1x = 1$, so $x$ "contributes" to the limit.
That is the idea : taking the difference of functions exposes the "hidden" terms, and because asymptoticity doesn't say anything about the hidden terms, we can't really say anything about comparing $f(x)-g(x)$  and $h(x) - j(x)$.
In your question, replacing $x$ with $\arctan x$ in both the terms has the problem that $x$ and $\log(1+\arctan x)$ are asymptotic as $x \to 0$, but the latter has the hidden terms (found from Taylor series, only for illustration) $\log(1+\arctan x) = x - \color{blue}{\frac{x^2}{2}} + ...$ and this one hidden term comes into prominence because there's a $\frac 1{x^2}$ in the expression as well. So that cancels with the $x^2$ giving a $-\frac 12$, which is exactly the (additive for the inner bracket)
factor you are missing.

Back to Question
To solve the question, we can still do L'Hopital, and be cleverer about our choice of split ,so we can L'Hopital each part separately! The point is, I want to finish each part off with a separate L'Hopital and then combine the two answers.
For example, if we write :
$$
\left( \frac{1}{x(1+\arctan x)(1+x^2)} - \frac{\log(1+\arctan x)}{x^2}\right) \\= \left( \frac{1}{x(1+\arctan x)(1+x^2)} - \frac 1x - \frac{\log(1+\arctan x)}{x^2} + \frac 1x\right) \\ = \left( \frac{1}{x(1+\arctan x)(1+x^2)} - \frac 1x\right) -\left( \frac{\log(1+\arctan x) - x}{x^2} \right)
$$
where I deliberately added and subtracted $\frac 1x$ so that each of these brackets can be evaluated separately. Now each of these is L'Hospitable (?) but we still need to be very clever. Your problem is extremely hard, as you've already seen.
The first one first :
$$
\left( \frac{1}{x(1+\arctan x)(1+x^2)} - \frac 1x\right) = \frac {(1- (1+\arctan x)(1+x^2))}{x(1+\arctan x)(1+x^2)}
$$
Apply L'Hopital, and it turns out both derivative of top and bottom have non-zero limits ($-1$ for top and $1$ for bottom), which leads to $-1$ at the end of it. The expressions are messy, but simplified by the fact that we are looking at $x=0$ so things simplify. (I am leaving this for you)
As for the second term, indeed it is again L'Hopital twice.
Do it once :
$$
\frac{\log(1+\arctan x) - x}{x^2} \to \frac{\frac 1{(x^2+1)(1+\arctan x) } - 1}{2x} \\ \to \frac{1}{(x^2+1)(1+\arctan x)} \frac{1 - (x^2+1)(1+\arctan x)}{2x}
$$
The first one is $1$ at $x=0$. The second, well L'Hopital and substitute $x=0$, you get the non-zero answer $\frac 12$.
Combining everything, the answer is :
$$
-e(-1 + \frac 12) = \frac e2
$$
and so the missing factor was just the $\frac 12$ in the end.
A: $$(1+\arctan x)^{1/x}=\exp\left(\frac{1}{x}\log(1+\arctan x)\right)$$
And
$$\log(1+\arctan x)=\log(1+x+O(x^3))=x-\frac12x^2+O(x^3)$$
Therefore
$$\frac{e-(1+\arctan x)^{1/x}}x=\frac{e-\exp(1-\frac x2+O(x^2))}{x}=\frac{e-e(1-\frac x2+O(x^2))}{x}\\=\frac e2+O(x)\xrightarrow[x \to 0]{} \frac e2$$
A: In general you should avoid L'Hospital's Rule unless the differentiation of numerator and denominator is damn simple. If you need product/quotient/chain rule of derivatives then probably you are better off avoiding it.
Same is the case of Taylor series. If you need to multiply/divide/compose some Taylor series then avoid it.
A better approach is to use limit laws combined with standard limits to either evaluate the limit or to simplify it in a form which makes the application of L'Hospital's Rule or Taylor series easy.
Let's observe that $(1+\arctan x) ^{1/x}\to e$ (prove it if you are not convinced). Thus the numerator is of the form $a-b$ where both $a, b$ tend to $e$. Next we note that $$a-b=b\cdot \frac{\exp(\log a - \log b) - 1}{\log a - \log b}\cdot (\log a - \log b) $$ Since the first two factors tend to $e$ and $1$ we can replace numerator by $$e(\log a - \log b) $$ Thus we need to evaluate the limit of $$e\cdot\dfrac{1-\dfrac{\log(1+\arctan x)} {x}} {x} =e\cdot\frac{x-\log(1+\arctan x)} {x^2}$$ Next we can substitute $x=\tan t$ and the above expression is transformed into $$e\cdot \frac{\tan t-\log(1+t)}{t^2}\cdot\frac{t^2}{\tan^2t}$$ Since the last factor tends to $1$ the desired limit is equal to the limit of $$e\left(\frac{\tan t - t} {t^2}+\frac{t-\log(1+t)}{t^2}\right)$$ Using L'Hospital's Rule or Taylor series one deduces that the first fraction tends to $0$ and the second fraction tends to $-1/2$. Thus the desired limit is $-e/2$.
