Find the derivative of $f(x)$ $f(x)=\begin{cases}1 &amp; x\in\Bbb{Q}\\ \sin x&amp; x\notin\Bbb{Q}\end{cases}$
I know
when $x=2\pi(n-1)+\frac{\pi}{2},\space f(x)=1$
when $x=2\pi(n-1)-\frac{\pi}{2},\space f(x)=-1$
when $x=n\pi,\space f(x)=0$
Is $f(x)$ then differentiable? I assume it is only differentiable when $x\in\Bbb{Q} $ and $x=2\pi(n-1)+\frac{\pi}{2}$.
Am I correct?
Differentiable functions are continuous. This function is continuous nowhere except at points where the sine is $1,$ i.e. at $x=\frac\pi2+2\pi n$ for $n\in\mathbb Z.$ And it is differentiable at those points:
\begin{align}
&amp; \lim_{h\to0} \frac{f(\pi/2+h) - f(\pi/2)} h \\[10pt]
= {} &amp; \lim_{h\to0} \begin{cases} \frac{\sin(\pi/2+h)-1} h \\[8pt] \qquad \frac 0 h
\end{cases} \\[10pt]
= {} &amp; \lim_{h\to0} \begin{cases} \frac{(\cos h)-1}h \\[6pt] \quad0 \end{cases} \qquad \text{ and so on}
\end{align}
No $f(x)$ is not differentiable for $x$ in $\mathbb{R}$. There might be some special value of $x$ that is differentiable, I can not be sure. But for almost all values of $x$, $f(x)$ is not differentiable.
For example, $f(x)$ is not differentiable at $0$, Because $\left(f(x)-f(0)\right)/x$ does not converge no matter how small $x$ is.