# Non-differentiability in $\mathbb R\setminus\mathbb Q$ of the modification of the Thomae's function

Here is the problem I'm struggling with:

Where is the following function continuous, differentiable, continuously differentiable?

$$f(x) = \begin{cases} q^{-2} & \text{if x=\frac{p}{q} in lowest terms, q\in\mathbb N } \\ 0 & \text{if x is irrational or x=0} \\ \end{cases}$$

As you can see, it's a modification of the Thomae's function: $q^{-2}$ here instead of the original $q^{-1}$.

So far, I've proved that this function (unlike the Thomae's function) is differentiable in $x=0$. And I expect it to be non-differentiable in $\mathbb R\setminus\mathbb Q$ (my guess is largely based the Proposition 4.1, yet the general proof from the paper is too advanced for me).

I was very glad to find the proof for the case $q^{-1}$: it was very beneficial for me to work through it and to try it here, yet it doesn't seem to work in my case.

Any help is hugely appreciated.

Theorem. For any real number $\alpha$ and positive integer $m$ there are integers $p_m$ and $q_m$ with $1\le q_m\le m$ such that $$|q_m\alpha-p_m|<\frac1m\;.$$
Proof. This is clearly true if $\alpha$ is rational, so assume that $\alpha$ is irrational. For $x\in\Bbb R$ let $\{x\}=x-\lfloor x\rfloor$, the fractional part of $x$. By the pigeonhole principle there must be distinct $i,j\in\{1,\dots,m+1\}$ and $k\in\{0,\dots,m-1\}$ such that $$\frac{k}m\le\{i\alpha\},\{j\alpha\}<\frac{k+1}m\;,$$ so that $0<\{|i-j|\alpha\}<\frac1m$, and $1\le|i-j|\le m$. Let $q_m=|i-j|$, and let $p_m=\lfloor q_m\alpha\rfloor$; then $$0<\{q_m\alpha\}=q_m\alpha-p_m<\frac1m\;.\dashv$$
It follows that if $\alpha$ is irrational, the sequence $\left\langle\frac{p_m}{q_m}:m\in\Bbb Z^+\right\rangle$ converges to $\alpha$. Moreover, for each $m\in\Bbb Z^+$ we have $$\left|\alpha-\frac{p_m}{q_m}\right|<\frac1{mq_m}\le\frac1{q_m^2}$$ and hence
$$\frac{\left|f\left(\frac{p_m}{q_m}\right)-f(\alpha)\right|}{\left|\frac{p_m}{q_m}-\alpha\right|}=\frac{f\left(\frac{p_m}{q_m}\right)}{\left|\frac{p_m}{q_m}-\alpha\right|}>q_m^2f\left(\frac{p_m}{q_m}\right)\ge 1\;.$$
Thus, if $f\,'(\alpha)$ exists, it must satisfy $|f\,'(\alpha)|\ge 1$. On the other hand, a similar calculation using a sequence of irrational numbers converging to $\alpha$ shows that $f\,'(\alpha)$, if it exists, must be $0$. It follows that $f$ is not differentiable at $\alpha\in\Bbb R\setminus\Bbb Q$.