Studying the derivative of the integral function $\frac{1}{x}\int_0^x\arctan(e^t)\mathrm{d}t$ I was trying to calculate the derivative of the function
$$
F(x) =\frac{1}{x}\int_0^x\arctan(e^t)\mathrm{d}t
$$
I thought the fastest way was to use the Leibniz's rule for the derivative of a product,
$$
(f\cdot g)' = f'g + g'f
$$
and, choosing as $f(x) = \frac{1}{x}$ and as $g(x) = \int_0^x\arctan(e^t)\mathrm{d}t$, applying for the second one's derivative the fundamental theorem of calculus, I obtained
$$
-\frac{1}{x^2}\int_0^x\arctan(e^t)\mathrm{d}t + \frac{1}{x}\left[\arctan(e^t)\right]\Bigg|_{t = 0}^{t = x} = -\frac{1}{x^2}\int_0^x\arctan(e^t)\mathrm{d}t + \frac{1}{x}\left[\arctan(e^x)-\frac{\pi}{4}\right]
$$
Now there come the problems, since I don't know how to evaluate the limit as $x\rightarrow0$ for the first term of the expression, while the second one, as $x\rightarrow0$, $g'(x)f(x)\rightarrow\frac{1}{2}$.
So I plotted the whole thing and I saw something very strange:

The blue one is the function (which is right), the red one it's the derivative as calculated before. As you can notice looks like the derivative have a discontinuity in the point 0, while looking at the graph of the function $F(x)$ one would say that there's not such a discontinuity. I tried to evaluate the whole thing with Mathematica, but I did not solve the problem:
there are strange things happening at the origin. 
Now, there are two possibilities:


*

*The derivative is wrong, but I wonder where, as it's so simple and linear

*Grapher app from Mac OS X cannot handle with such functions in a proper way


Can you find out the bug?
 A: With your notation
$$
g(x)=\int_0^x\arctan(e^t)\,dt
$$
we have
$$
F'(x)=\frac{xg'(x) - g(x)}{x^2}=\frac{x\arctan(e^x)-g(x)}{x^2}
$$
for $x\ne0$. On the other hand, the function $F$ can be extended by continuity at $0$ as
$$
\lim_{x\to0}F(x)=\frac{\pi}{4}
$$
and
$$
\lim_{x\to0}F'(x)=
\lim_{x\to0}\frac{1}{2x}\frac{xe^x}{1+e^{2x}}=\frac{1}{4}
$$
so $F$ (extended) is also differentiable at $0$.
I used l’Hôpital for both limits.
The bug in your argument is that you wrongly do
$$
\frac{d}{dx} g(x) = \Bigl[ \arctan(e^t)\Bigr]_{t=0}^{t=x}
$$
instead of
$$
\frac{d}{dx}g (x) =\arctan(e^x)
$$
according to the fundamental theorem of calculus.
A: So the "bug" was in the application of the foundamental theorem of calculus in which does not appear the derivative calculated at the starting point, so that the right derivative is
$$
-\frac{1}{x^2}\int_0^x\arctan(e^t)\mathrm{d}t + \frac{1}{x}\left[\arctan(e^t)\right]\Bigg|_{t = 0}^{t = x} = -\frac{1}{x^2}\int_0^x\arctan(e^t)\mathrm{d}t + \frac{1}{x}\left[\arctan(e^x)\right]
$$
which is the red function in the graph below

