Differentiability of a piecewise polynomial function which is continuous everywhere. Let $P(x)$ and $Q(x)$ be any two polynomials. Consider a function $f:\mathbb{R}\rightarrow\mathbb{R}$, where $\mathbb{R}$ is the set of real numbers, given by $f(x)=\begin{cases}P(x): x\le a\\Q(x):x> a\end{cases}$ such that $P(a)=Q(a)$, then $f$ is continuous on $\mathbb{R}$. Also $f$ is differentiable on the set $\mathbb{R}$ except posssibly at $a$. Further suppose that $\displaystyle\lim_{x\rightarrow{a}}f'(x)$ does not exist. Then can we make a conclusion that $f$ is not differentiable at $a$? If yes then I want a rigorous proof, otherwise a counter example.
My effort and understanding: I know,  that in general,  for a function which is continuous on $\mathbb{R}$ and differentiable everywhere except possibly at a certain point, $f$ may or may not be differentiable at that point even though limit of derivative at that point does not exists.
Consider a function $f(x)=\begin{cases} x^2\sin{\frac{1}{x}}:x\ne 0\\0:x=0\end{cases}$ .
This function is differentiable on $\mathbb{R}$,  however $\displaystyle\lim_{x\rightarrow{0}}f'(x)$ does not exist.
 A: If $f$ was differentiable at $a$, then $f'(a)=P'(a)=Q'(a)$. That's because, assuming that the derivative exists, $$f'(a)=\lim_{h\to0^-} \frac{f(a+h)-f(a)}{h}=\lim_{h\to0^-} \frac{P(a+h)-P(a)}{h}=P'(a)=\lim_{x\to a^-}P'(x)=\lim_{x\to a^-}f'(x)$$
and, since $P(a)=Q(a)=f(a)$,
$$f'(a)=\lim_{h\to0^-} \frac{f(a+h)-f(a)}{h}=\lim_{h\to0^+} \frac{Q(a+h)-Q(a)}{h}=Q'(a)=\lim_{x\to a^+}Q'(x)=\lim_{x\to a^+}f'(x)$$
and this implies that $\lim_{x\to a^-}f'(x)=\lim_{x\to a^+}f'(x)$.
Therefore if $\lim_{x\rightarrow{a}}f'(x)$ does not exist, then $f$ cannot be differentiable at $a$.
Observe that this is actually true whenever $P$ is continiously differentiable on $(a-\epsilon, a]$ and $Q$ is continiously differentiable on $[a,a+\epsilon)$, even without $P$ and $Q$ being polynomials
A: Since $P(x)$ and $Q(x)$ are polynomials, then they are continuously differentiable. Hence $f$ must be continuously differentiable on $\mathbb{R}\backslash\{a\}$ for sure. As a result, we immediately have that $\lim_{x\to a^-}f'(x)$ and $\lim_{x\to a^+}f'(x)$ must exist. Since the limit in both directions exist, then the only reason why $\lim_{x\to a}f'(x)$ does not exist is if we have a jump discontinuity at $a$. But the derivatives cannot have jump discontinuities or removable discontinuities. Hence $f'(a)$, $\lim_{x\to a^-}f'(x)$ and $\lim_{x\to a^+}f'(x)$ cannot all exist. We conclude that $f$ cannot be differentiable at $a$.
