Proof check , Derivability piecewise function Question : Check derivability at point x=0 $$f(x) = \begin{cases} x & \text{if $x \in Q$} \\ \sin x & \text{if $x \notin Q$} \end{cases}$$
Here's my solution:
if $x \in Q$
$$\underset{x\to 0 }{\mathop{\lim }}  \frac{f(x)-f(0)}{x-0}=\underset{x\to 0 }{\mathop{\lim }} \frac{x-0}{x-0}=1$$
if $x \notin Q$
$$\underset{x\to 0 }{\mathop{\lim }} \frac{f(x)-f(0)}{x-0}=\underset{x\to 0 }{\mathop{\lim }} \frac{\sin x}{x}=1$$
we conclude that $f'(0) = 1.$
Why do sometime we need to check the continuity at $0$ first before proving that is derivable at $0$?
 A: Note that (by definition) the derivative of this function is given by
$$
f'(0) = \lim_{x \to 0} \frac{f(x) - f(0)}{x}
$$
so to show that $f'(0) = 1$, it suffices to show that for any sequence $x_n \to 0$, we have
$$
\lim_{n \to \infty} \frac{f(x_n) - f(0)}{x_n} = 1
$$
What you can show with the steps you describe is that for any sequence $(x_n)_{n \in \Bbb N} \subset \Bbb Q$ or $(x_n)_{n \in \Bbb N} \subset (\Bbb R \setminus \Bbb Q)$, we have the desired equality.  What you have failed to address, however, is the general case in which the sequence $(x_n)$ consists of both rational and irrational elements.
As for continuity: saying that $f$ is continuous at zero is equivalent to proving that 
$$
\lim_{x \to 0} \;[f(x) - f(0)] = 0
$$
that is, the limit of our limit's numerator is zero.  This is a necessary condition for differentiability.  That is, it is impossible for $f$ to be differentiable at $x = 0$ without also being continuous at $x = 0$.  It is not clear to me, however, that proving continuity should necessarily be the first step of this proof.
