Why doesn't L'Hopital's rule work in this case?

A precondition in l'Hospital's Rule is that in order for it to apply, the limit $$ \lim_{x\to\infty}\frac{f'(x)}{g'(x)} $$ must exist (but is allowed to be $\pm \infty$). In this case, the limit does not exist, so it does not apply.


Another condition, very often forgotten, is that in some neighbourhood of $a$ (here $a=+\infty$), except perhaps at $a$, $g'(x)\neq 0$. This is not the case here: $1-\cos x$ is $0$ infinitely many times.

This is a good illustration why L'Hospital's rule is dangerous. One of the first things I learnt when I was a student is: ‘Avoid it. When it works, Taylor's polynomial at order 1 works as well.’

Here, the simplest way is via equivalents: $\,x-\sin x\sim_\infty x$ since $\sin x$ is bounded, hence $$\frac x{x-\sin x}\sim_\infty \frac x{x}=1.$$


There is no contradiction; Hopital says that if $$\lim \frac {f'(x)}{g'(x)}$$ exists, then it is equal to $\lim \frac{f(x)}{g(x)}$.

In this case the limit does not exist, so nothing can be inferred.

Of course it also means that Hopital is useless in this case, but hopital is hardly the most important tool to solve limits anyway, and there are many other instances where it is useless :)