# Continuous function differentiable on $[0,1]\setminus\mathbb{Q}$, but nondifferentiable on all of $\mathbb{Q}\cap[0,1]$?

I'm trying to work out an example of a continuous function which is differentiable at all irrationals but nondifferentiable at all rationals in $[0,1]$.

Since $\mathbb{Q}$ is countable, list it as $\mathbb{Q}=\{q_0,q_1,q_2,\dots\}$. Define a map $g\colon\mathbb{Q}\to\mathbb{R}$ by $q_n\mapsto 2^{-n}$. Since $\sum_{n=0}^\infty\frac{1}{2^n}$ is absolutely convergent, $\sum_{r\in\mathbb{Q}}g(r)$ is too. Then define $f\colon [0,1]\to\mathbb{R}$ by $$f(x)=\sum_{r\in\mathbb{Q};r<x}g(r)$$ which is well defined.

It is not hard to see that $f$ is monotonically increasing on $[0,1]$, and thus Riemann integrable on $[0,1]$. I've been able to show that $f$ is continuous at all irrationals, but discontinuous at all rationals. I can add this if needed.

By the fundamental theorem of calculus, the function $F\colon [0,1]\to\mathbb{R}$ defined by $$F(x)=\int_0^x f$$is continuous, and differentiable at all irrationals since $f$ is continuous at all irrationals.

The example on page 7 of these notes, Math 131AH Winter 2003, Prof. Terry Tao remarks that $F$ is actually nondifferentiable at every rational, by use of the mean value theorem.

I'm confused because I don't see how I can apply the mean value theorem. I don't think I'm intended to apply it to $f$, since $f$ is not differentiable on any nondegenerate interval. Also, although $F$ is continuous, I don't think I can apply the mean value theorem to it without assuming that $F$ is differentiable on all the rationals in some interval, which seems like a large assumption.

How can the mean value theorem (if necessary), show that $F$ is discontinuous at all rationals? Thanks.

• My guess is that they mean the mean value theorem for integrals. May 19, 2013 at 22:16
• Thanks, but I doubt it. The MVT for integrals isn't introduced in those notes. I dug around for the textbook based on those course notes, and the same remark specifically references the MVT for derivatives. May 19, 2013 at 22:19
• – 23rd
May 19, 2013 at 22:21
• Hmmmm. Wikipedia says the MVT for derivatives applies whenever the limit defining the derivative at each point exists in the extended reals (that is, either the derivative exists or the limit goes to $+\infty$ or $-\infty$. No, I don't know why. May 19, 2013 at 22:23
• Perhaps "by use of mean value theorem" can be understood in this way: since $f$ is strictly increasing, for any $a<b$, there exists $c\in (f(a^+),f(b^-))$, such that $F(b)-F(a)=c(b-a)$.
– 23rd
May 19, 2013 at 22:42

Your example of a function continuous at irrationals but discontinuous at rationals can be rephrased as follows: writing $\mathbb Q\cap[0,1] = \{q_0,q_1,q_2,\dots\}$ as before, define $$f_n(x) = \begin{cases} 0, &\text{if } x\le q_n, \\ 2^{-n}, &\text{if } x>q_n.\end{cases}$$ Then your example $f(x)$ is simply $f(x) = \sum_{n=0}^\infty f_n(x)$. In this formulation, it's easy to see where the discontinuity at some $q_k$ comes from: all the functions being added are continuous there except for $f_k$.
So to construct a function differentiable at irrationals but nondifferentiable at rationals, I suggest trying $F(x) = \sum_{n=0}^\infty F_n(x)$, where $$F_n(x) = \begin{cases} 0, &\text{if } x\le q_n, \\ 2^{-n}(x-q_n), &\text{if } x>q_n.\end{cases}$$ (And yes, this $F$ really is $\int f$, although it's not necessary to know that: one can deduce the differentiability properties of $F$ directly from the above definition.)
Suppose not i.e., $F$ is differentiable at some rational point $x_0 \in [0,1]$ and therefore $f$ is continuous at this $x_0$. Let $x_0 \in [0,x]$ with $0\le x\le 1$. Since $0\le x_0 \le x$ then $x-x_0\ge 0$ so by Archimedean property there exists a positive integer $n \ge 1$ such that $n(x-x_0)>1$ i.e., $x-x_0 > \frac{1}{n}$. Also, since $f$ is increasing we have $f(x-x_0)>f(\frac{1}{n})$ ...........(*).
Since $F$ is cts at arbitrary $x_0 \in [0,1]$ the for $\epsilon >0$ and choose a suitable $\delta = \frac{\epsilon}{M}$ with $M>0$ such that $|F(x)-F(x_0)| < \epsilon$, whenever $0<|x-x_0|<\delta$. \begin{align} \left| {F\left( x \right) - F\left( {x_0 } \right)} \right| &= \left| {\int_0^x {f\left( t \right)dt} - \int_0^{x_0 } {f\left( t \right)dt} } \right| \\ &= \left| {\int_0^x {f\left( t \right)dt} + \int_{x_0 }^0 {f\left( t \right)dt} } \right| = \left| {\int_{x_0 }^x {f\left( t \right)dt} } \right| \\ &\le \int_{x_0 }^x {\left| {f\left( t \right)} \right|dt} \le \frac{M}{{\delta \left( {x - x_0 } \right)}}\left( {x - x_0 } \right) = \epsilon .....(**) \end{align} (Similary, can be done by MVT). On the other hand, since $f$ increasing using (*) we have
which is a contradiction. Since $x_0$ is an arbitrary rational in $[0,1]$, so that $F$ is not cts on [0,1] therefore $F$ is not differentiable at any rational $x_0 \in [0,1]$.