Does there exist a function $f: \mathbb{R} \to \mathbb{R}$ that is differentiable only at $0$ and at $\frac{1}{n}$, $n \in \mathbb{N}$?

How to determine the existence of the function $f: \mathbb{R} \rightarrow \mathbb{R}$, which is differentiable only at $0$ and at $\frac{1}{n}$, $n \in \mathbb{N}$?

It's more than enough to give an example but I have some difficulties with it.

Or even if it doesn't exist: how to find a hint that may be useful?


Let $$g(x)=\cases {\exp\left(-\frac{1}{x(1-x)}\right) & if $0\le x \le 1$ , $x$ irrational \\ 0 & elsewhere}$$

Then, in the interval $[0,1]$, $g(x)$ is only continuous and differentiable at $x=0$ and $x=1$ (and all the derivatives are zero).

The copy and paste the $y$-scaled/$x$-scaled-translated copies of it: $$ f(x)=\sum_{n=1}^\infty \frac{g(x \, n (n+1) + 1/n)}{n^2}$$


Here is a hint to get started: define $$f(x) = \left\{ \begin{array}{ll} 1 & x \text{ irrational}, \\ 0 & x \text{ rational}. \end{array} \right.$$

Then $x^2 f(x)$ is differentiable at $0$ and nowhere else, $x^2(x-1)^2f(x)$ is differentiable at $0$ and $1$ and nowhere else, $x^2(x-1)^2(x-1/2)^2 f(x)$ is differentiable at $0$ and $1$ and $1/2$ and nowhere else, etc.

Can you pass from a finite number of points of differentiability to a sequence?