Find the derivative of $f(x)$ $f(x)=\begin{cases}1 & x\in\Bbb{Q}\\ \sin x& 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?
 A: 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}
& \lim_{h\to0} \frac{f(\pi/2+h) - f(\pi/2)} h \\[10pt]
= {} & \lim_{h\to0} \begin{cases} \frac{\sin(\pi/2+h)-1} h \\[8pt] \qquad \frac 0 h
\end{cases} \\[10pt]
= {} & \lim_{h\to0} \begin{cases} \frac{(\cos h)-1}h \\[6pt] \quad0 \end{cases} \qquad \text{ and so on}
\end{align}
A: Your reasoning is correct so far, but more can be said.  Are you familiar with the fact that $ \pi $ is an irrational number?  Since that is the case, such $ x $ as you described does not exist.  Hence your function is discontinuous, hence non-differentiable, at all real $ x $.
Edit: unfortunately, I overlooked the fact that the function is continuous at those points where $ \sin(x) = 1 $.  Downvote mine and accept Michael's answer please.
A: 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.
