Let's take function given by a condition:

$\displaystyle f(x) = \begin{cases} \frac{1}{q^2} \leftrightarrow \ x \in \mathbb{Q} \wedge x = \frac{p}{q},\\ 0 \leftrightarrow \ x \notin \mathbb{Q} \end{cases}$

Prove the existence of the derivative of $\displaystyle f$ in all points $\displaystyle x \notin \mathbb{Q}$.

So, I am aware that if there was $\displaystyle q$ standing in the formula instead of $\displaystyle q^2$, the derivative wouldn't exist (that would simply be the Thomae's function). The thing I couldn't figure out is, why would the replacement change anything and where should I start the proof?