Can we apply L'Hospital's rule where the derivative is not continuous?

My doubt arises due to the following :

We know that the definition of the derivative of a function at a point $$x=a$$, if it is differentiable at $$a$$, is: $$f'(a) = \lim_{h \rightarrow 0} \frac {f(a+h) - f(a)}{h}$$

Suppose that the function $$f(x)$$ is differentiable in a finite interval $$[c,d]$$ and $$a \in (c,d)$$

So, we can apply L'Hospital's rule. On differentiating numerator and denominator with respect to $$h$$, we get: $$f'(a) = \lim_{h \rightarrow 0} \frac {f(a+h) - f(a)}{h} = \lim_{h \rightarrow 0} \frac {f'(a+h)}{1}$$ Which implies that $$f'(a) = \lim_{h \rightarrow 0} f'(a+h)$$ Which means that the function $$f'(x)$$ is continuous at $$x=a$$

But this not necessarily true. A function may have a derivative everywhere but its derivative may not be continuous at some point. One of many counterexamples is: $$f(x) = \begin{cases} 0 \text{ ; if x=0} \\ x^2 \sin \frac{1}{x} \text{; if x \neq 0 } \end{cases}$$ Whose derivative isn't continuous at $$0$$

So, is something wrong with what I have done ? Or is it necessary that for applying L'Hospital's rule, the function's derivative must be a continuous function?

If the latter is true, why does that condition appear in the proof for L'Hospital's rule ?

In this case - yes, you need derivative to be continuous. In general, you need $$\lim \frac{f'(x)}{g'(x)}$$ to exist to apply L'Hospital's rule. As in your case $$g'(x) = 1$$, you proved that if there is a limit of $$f'(a + h)$$, then the limit is equal to $$f'(a)$$.
L'Hospital's rule says under certain conditions: IF $$\lim_{h\to 0} \frac{f'(h)}{g'(h)}=c$$ exists, then also $$\lim_{h\to 0} \frac{f(h)}{g(h)}=c$$. It does not say anything about the existence of the former limit.
• @Dhvanit when $\lim_{h\to0}\frac{f'(h)}{g'(h)}$ is one of $\pm\infty$, which some people classify as not existing, the implication also holds. Apr 9 '19 at 14:18
• Basically, the condition mentioned in this answer means that applying L'Hospital's rule assumes that $\lim_{h\to 0}f'(a+h)$ exists. And if it exists, it can be shown that it must be $f'(a)$ (because derivatives need not be continuous, but still must fulfill the intermdiate value condition). Apr 9 '19 at 14:37
• So, is it correct to say that : "If a function is continuous and differentiable in an interval, and if it's derivative is not continuous at $a$, then $\lim_{h \rightarrow 0} f'(a+h)$ must not exist" ? i.e. Is it possible that in such a case, $\lim_{h \rightarrow 0} f'(a+h)$ exists but isn't equal to $f'(a)$ ? Apr 10 '19 at 5:21
• @Dhvanit: If $\lim_{h \to 0} f'(a+h)$ exists, then by L'Hopital's rule, it is equal to $f'(a)$ and $f'$ is continuous at the point $a$. Hence if it is not continuousat the point $a$, then the limit does not exists! Observe also that $f'$ satisfies the intermediate value property by Darboux's Theorem Apr 10 '19 at 6:18