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

analysisreal-analysis

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.

Best Answer

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

Related Question