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?

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

