TITLE: How I can calculate the derivative of a piecewise function like this?
QUESTION [6 upvotes]: How I can calculate the derivative of $$f(x) = \left\{ \begin{gathered}
  {x^2}\quad,\quad{\text{if}}\quad x \in \mathbb{Q}  \\
  {x^3}\quad,\quad{\text{if}}\quad x \notin \mathbb{Q}  \\ 
\end{gathered}  \right.$$ at some $x\in \mathbb{R}$?

REPLY [5 votes]: HINT:
The derivative exists if $\lim _{y \to x} \dfrac{f(y) - f(x)}{y - x}$ exists. Of course, a limit must be the same along any Cauchy sequence. So at what points does the derivative even exist? (it does exist somewhere)

REPLY [5 votes]: The first helpful information to look for is if your function is continuous at any $x$.  After all, a function does not have a well-defined derivative where it isn't continuous.
Then, analyze those points where it is continuous.  Does it have a derivative there?  A hint is that there is always a rational point in between two real numbers (that aren't equal) and that there's always an irrational point in between two real numbers (again, nonequal).