Continuous function that is only differentiable on irrationals

Can you help me finding a function $f : \mathbb{R} \rightarrow \mathbb{R}$ that is continuous in $\mathbb{R}$ and differentiable at $x$ iff $x \notin \mathbb{Q}$ ?

Thank you very much !

Solutions Collecting From Web of "Continuous function that is only differentiable on irrationals"

Interpreting the question as asking for a continuous function that is differentiable only at the irrationals, we might perturb one of Weierstrass’s functions and look at

$$f(x) = \sum_n \frac{|\sin (n \pi x)|}{n^3}$$

It’s easy to see it’s continuous, but a bit more challenging to see about its derivative.

Following David Mitra’s comment :

Let’s define the following Lebesgue-Stieltjes measure $m$ defined such that $m(E)=\sum_{q_{j}}\frac{1}{2^{j}}I_{q_{j}}(E)$, where $I_{q_{j}} = 1$ iff $q_{j} \in E$. Moreover, let’s restrict $q_{j}$ to be the rationals that are in $E$ and are smaller than $\sup(E)$. We can see that the $g(x) = \sum_{q_{j}}\frac{1}{2^{j}}H(x-q_{j})$, where $H$ is the Heaviside function, is such that $m(]a,b]) = g(b) – g(a)$.
Therefore, we know that $g$ is continuous at $x$ iff $m(\lbrace x \rbrace)= 0$. Thus, we can conclude that $g$ is continuous in $\mathbb{R}$. Finally, it’s clear that $g$ is not differentiable on $\mathbb{Q}$, since the right and left limits of $g(x+h)-g(x)$ are not the same.

You think this is ok ?
BTW, thank you for all comments and for the beautiful answer regarding Weierstrass Function 🙂