Construct a function on a bounded interval on $\Bbb{R}$ which is continuous everywhere but differentiable only at irrationals. Initially, I constructed a function with the help of famous Thomae's function, but later I found it to be wrong. Firstly, I did-

Let $f:[0,1]\to\Bbb{R}$ be the Thomae's function defied by 
  $$f(x)=\begin{cases}0& \text{if $x$ is irrational} \\{1 \over q}
 &\text{if $x$ is rational, $x={p \over q}$ with $p\in\Bbb{Z}$,
 $q\in\Bbb{N}$ are coprime}\end{cases}$$   This function is Riemann
  Integrable on $[0,1]$. Now, define $F:[0,1]\to\Bbb{R}$ by
  $F(x)=\int_{[0,x]} f\:\forall x\in[0,1]$ But here $\int_{[0,x]}
 f=0\:\forall x\in[0,1]\implies F(x)=0\:\forall x\in[0,1]\implies F$ is
  differentiable everywhere on $[0,1]$.


But, as per the question $F$ is not the required function.
Can anybody give me an example of such a function with some proper arguments?
Thanks for your assistance in advance!
 A: I provide here an explicit construction (in a more general case).
Consider $D = (a_n)_{n \ge 1}$ a countable subset of $[0,1]$. Then the following function is differentiable exactly on $[0,1] \backslash D$ : $$ f : x \in [0,1] \mapsto \sum\limits_{n=1}^{+\infty} \frac{|x-a_n|}{2^n}.$$
In the rest of the proof, $[a,]$ will denote the points between $a$ and $b$ regardless of which is greater (even if $a > b$, $[a,]$ is not empty ; $[a,b]=[b,a]$). Take any $x \in [0,1]$. Note that if $a > \max(x,y)$ then $|y-a|-|x-a|=x-y$, if $a < \min(x,y)$ then $|y-a|-|x-a|=y-x$, and if $a$ is between $x$ and $y$, $||y-a|-|x-a||\le 2|y-x|$.
Case 1: $x \notin D$. Let $n_0 \in \mathbb{N}$. For $y$ in some neighborhood of $x$, $[x,y]$ does not contain $a_1,...,a_{n_0}$. Then $\frac{f(y)-f(x)}{y-x} = \sum\limits_{a_n > \max(x,y)} \frac{1}{2^n} + \sum\limits_{a_n < \min(x,y)} \frac{-1}{2^n} + \sum\limits_{a_n \in [x,y]} \frac{|y-a_n|-|x-a_n|}{2^n}$. And $\big| \sum\limits_{a_n \in [x,y]} \frac{|y-a_n|-|x-a_n|}{2^n|y-x|}\big| \le \sum\limits_{n>n_0} \frac{2}{2^n}=\frac{1}{2^{n_0-1}}$. Hence $f$ is differentiable at $x$ and $f'(x) = \sum\limits_{a_n > x} \frac{1}{2^n}-\sum\limits_{a_n < x} \frac{1}{2^n}$.
Case 2: $x = a_m \in D$. Let $n_0 \in \mathbb{N}$. For $y$ in some neighborhood of $x$, $]x,y]$ does not contain$a_1,...,a_{n_0}$. Then as before, we have $\frac{f(y)-f(x)}{y-x}=\sum\limits_{a_n > \max(x,y)} \frac{1}{2^n} - \sum\limits_{a_n < \min(x,y)} \frac{1}{2^n} + \frac{|y-a_m|}{2^m (y-a_m)} + C(y)$ where $|C(y)| \le \frac{1}{2^{n_0-1}}$. Denoting $K = \sum\limits_{a_n>x}\frac{1}{2^n}-\sum\limits_{a_n<x}\frac{1}{2^n}$, we find that the left limit is $\frac{f(y)-f(x)}{y-x} \underset{y\to x^-}{\longrightarrow} K - \frac{1}{2^m}$, while the right limit is $\frac{f(y)-f(x)}{y-x} \underset{y \to x^+}{\longrightarrow} K - \frac{1}{2^m}$. Hence $f$ is not differentiable at $x$.
$ $
Conclusion given $D = \{a_n \ |\ n \ge 1\}$ a countable subset of $[0,1]$, $f : x \mapsto \sum\limits_{n=1}^{+\infty}\frac{|x-a_n|}{2^n}$ is differentiable exactly at $[0,1]\backslash D$.
A: Yes, such a function exists. In fact, Zahorski [1] (see also p. 103 here) proved that if $E$ can be written as $E = G \cup Z,$ where $G$ is a $\mathcal{G}_{\delta}$ set and $Z$ is a $\mathcal{G}_{\delta \sigma}$ Lebesgue measure zero set, then there exists a continuous function $f: {\mathbb R} \rightarrow {\mathbb R}$ such that the set of points at which $f$ does not have a finite two-sided derivative is equal to $E.$ (Zahorski’s proof was simplified in [2].) Choosing $G$ to be the set of irrational numbers and $Z$ to be the empty set gives the result you want.
Off-hand, I don’t know of a simple explicit description of such a function for the set of irrational numbers (I've probably never previously looked for one or thought much about it), but I believe Lemma 3 on p. 151 of Zahorski’s paper gives the closest special case in his paper for what you want --- the construction of a continuous function whose non-differentiability set is any specified $\mathcal{G}_{\delta}$ set that contains no intervals. If I happen to come across such a function (continuous, with irrationals as its non-differentiability set) at some later time, I'll try to remember to come back here and mention it.
I’ve posted several answers/essays that give more details, references, and related results pertaining to this topic --- some of those are listed below (in chronological order).
[1] Zygmunt Zahorski, Sur l'ensemble des points de non-dérivabilité d'une fonction continue [On the set of points of non-differentiability of a continuous function], Bulletin de la Société Mathématique de France 74 (1946), 147-178. paper at EUDML and paper at NUMDAM
[2] George Piranian, The set of nondifferentiability of a continuous function, American Mathematical Monthly 73 #4 (April 1966) [Part II: Papers in Analysis, Herbert Ellsworth Slaught Memorial Papers #11], 57-61.
Differentiability of the Ruler Function (13 December 2006 sci.math post)
Continuous functions are differentiable on a measurable set?
Set of zeroes of the derivative of a pathological function
Characterization of sets of differentiability
Points of differentiability of $f(x) = \sum\limits_{n : q_n < x} c_n$
Monotone Function, Derivative Limit Bounded, Differentiable – 2
