If $f(x)=\int_{0}^{x}\cos\frac{1}{t}\ {dt}$, then caculate $f'(0)$ 
If $f(x)=\int_{0}^{x}\cos\frac{1}{t}\ {dt}$, then calculate $f'(0) $.

I found the answer there and understood its solution. But when I solve it myself, I first tried to solve it directly:

$$f'(0)=\frac{\int_{0}^{x}\cos\frac{1}{x}dx}{x},$$
And use the L'Hospital, I get $$f'(0)=\frac{\cos\frac{1}{x}}{1}$$ and get the conclusion that $f'(0)$ does not exist!

I do not know where is wrong, Could you point it out? Thank you!
 A: Let $f(x)$ be given by the integral
$$f(x)=\int_0^x \cos(1/t)\,dt$$
For $x\ne 0$, we see that $f'(x)=\cos(1/x)$.  Hence, $\lim_{x\to0}f'(x)$ fails to exist.

But the fact that $\lim_{x\to0}f'(x)$ does not exist, does not imply that $f'(0)$ does not exist.  In fact, we have
$$\begin{align}
f'(0)&=\lim_{x\to 0}\frac{f(x)-f(0)}{x}\\\\
&=\lim_{x\to0}\frac{\int_0^x \cos(1/t)\,dt}x\\\\
&=\lim_{x\to 0}\left(-x\sin(1/x)+\frac1x\int_0^x 2t\sin(1/t)\,dt\right)\\\\
&=\lim_{x\to 0}\left(-x\sin(1/x)+O(x)\right)\\\\
&=0
\end{align}$$
Hence, we see that $f(x)$ is differentiable for all $x$, but its derivative, $f'(x)$, is discontinuous at $0$.

The conditions to apply L'Hospital's Rule apply.  We have $f(x)=\int_0^x \cos(1/t)\,dt$ and $g(x)=x$ are differentiable on open interval's containing $0$.  But the limit
$$\lim_{x\to 0}\frac{f'(x)}{g'(x)}=\lim_{x\to0}\frac{\cos(1/x)}{1}$$
does not exist.  Therefore, L'Hospital's Rule is a useless tool to determine $f'(0)$.
And that is all that is going on here.
