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!

• I feel there is no such curve. But since Weierstrass discovered a function having the property of being continuous everywhere but differentiable nowhere the geometric intuition lost a good role in the analysis. May 16, 2018 at 22:42
• To be clear: you want it to be differentiable at every irrational, and nowhere else? May 16, 2018 at 23:45
• @RobertIsrael, this is a problem from the book of Terence Tao Analysis 1 May 17, 2018 at 4:43

2 Answers

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$.

• +1 I haven't checked the details, but I'm pretty sure this works, and I'm surprised I'd forgotten its history. Schwarz gave an example of such a function in 1873, using roughly the same method (which is basically an application of Hankel's 1870 method of "condensation of singularities"). My next 3 comments quote from my answer to Is Kline right that Cauchy believed that continuous functions must be differentiable? (middle of Note for [3]). May 17, 2018 at 14:20
• Gilbert's approach was based on Lamarle's methods and was intended to conclusively prove that a continuous function is differentiable except for an isolated set of points (see Gilbert's final theorem at the bottom of p. 31). However, after Gilbert learned of the results in Hermann Amandus Schwarz's 1873 paper Neues beispiel einer stetigen nicht differentiirbaren function [New example of a continuous non-differentiable function] French version, (continued) May 17, 2018 at 14:21
• which gives a particularly simple example of a strictly increasing continuous function that is not differentiable at each nonzero dyadic rational number (in fact, at each such number the right derivative is $+\infty$ and the left derivative is positive and finite), Gilbert came to realize that Hankel's examples were possible. (Schwarz presented his example on 19 August 1873, but since Gilbert's Rectification was presented in a session dated 7 June 1873, Gilbert obviously knew about it before Schwarz's presentation. (continued) May 17, 2018 at 14:21
• Incidentally, although Weierstrass' presentation of an everywhere non-differentiable continuous function was on 18 July 1872, I can find no mention of Weierstrass in Gilbert's Rectification.) May 17, 2018 at 14:22

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