# One-sided limits of $f'(x)$ at a point vs. one-sided limits of the difference quotient at that point

I know that if a function is piecewise, then when differentiating it one needs to deal separately with the points of intersection of the pieces, because the derivative may not be defined there.

Also, if a one-sided limit of $f'(x)$ at these "crucial points" is infinite or doesn't exist, it doesn't preclude the limit of the difference quotient from existing and being finite. For example, take $f(x)=x^2\sin\frac1x, f(0)=0$: $f'(x)= 2x\sin\frac1x-\sin\frac1x$ has no limit as $x\to0$ but $\lim\limits_{h\to0}\frac{f(h)-f(0)}{h}=0=f'(0)$.

On the contrary, looking at $f(x)=\sin x +\lvert \sin x\rvert$ on $[0,2\pi]$ one has $f'(x)=2\cos x$ on $(0,\pi)$ and $f'(x)=0$ on $(\pi,2\pi)$ so $\lim\limits_{h\to0^+}f'(\pi+h)\ne\lim\limits_{h\to0^-}f'(\pi+h)$, but they are both finite. And in this case it's easy to find that they agree with the one-sided limits of the difference quotient. Why? Does the finiteness of the former imply that they agree with the latter? Is this also true if the one-sided limits of $f'$ at the crucial points agree with each other?

Yes, if a one-sided limit of $f'(x)$ exists at a point $a$, then the limit of the one-sided difference quotients exists at that point, and coincides with the one-sided limit of the derivative. That is a consequence of the mean value theorem. Consider the right limits, then by the mean value theorem we have

$$\frac{f(x)- f(a)}{x - a} = f'(y)$$

for some $y \in (a,x)$. Thus if $L = \lim\limits_{x \to a^+} f'(x)$ and

$$\lvert f'(y) - L\rvert < \varepsilon$$

for $y \in (a, a+\delta)$, it follows that

$$\Biggl\lvert \frac{f(x) - f(a)}{x-a} - L\Biggr\rvert < \varepsilon$$

for $x \in (a,a+\delta]$, i.e.

$$\lim_{x \to a^+} \frac{f(x) - f(a)}{x-a}$$

exists and equals $L$.

The same argument holds for the left limit of course. And hence the existence of $\lim\limits_{x\to a} f'(x)$ implies the differentiability of $f$ at $a$ and the continuity of $f'$ at $a$. As you are aware, this is a sufficient, but not a necessary condition for differentiability at $a$.