Assume f(x) / g(x) is an indeterminate form.

It is not often spoken of, but it is also required that and change sign only finitely many times in the neighborhood of the limit.

In your example, neither 1 - cos(x) nor 1 + cos(x) has this problem, but the next derivative certainly does.

It's also important to note that the repeated application of the rule must converge.