Following the scheme given by mercio in the answer to this question, one can construct a function $f: \mathbb Q \rightarrow \mathbb Q$, differentiable everywhere, with derivative function
$$ f'(x) = \begin{cases} 0, & (x \neq 0),\\ 1, & (x = 0). \end{cases}\tag{1}\label{one} $$ Such function cannot be uniformly continuous, because otherwise, in any closed interval containing $0$, $f$ could be extended to a continuous function on $\mathbb R$. Such extended function would give \begin{equation} \lim_{h \rightarrow 0} \frac{f(h)-f(0)}{h} = 1 \end{equation} and, at the same time, \begin{equation} \lim_{x\rightarrow 0}f'(x) = 0, \end{equation} which would contradict de l'Hôpital's rule.

My question is whether it is possible or not to demonstrate that $f$ is not uniformly continuous by using only condition \eqref{one} and the definition of uniform continuity, i.e. (for the sake of completeness) \begin{equation} \forall \epsilon,\ \exists \delta:\ \forall x,\ y \in \mathbb Q,\ |x-y|<\delta \Rightarrow |f(x)-f(y)|<\epsilon . \end{equation}

EDIT: Wojowu pointed out to me that the function may not be differentiable once extended on $\mathbb R$ (thus not contradicting de l'Hôpital's rule) . So either $f$ is not uniformly continuous or its extension to the reals fails to be differentiable. So the question now is whether this can be estabished only by means of \eqref{one} or not, and how.

  • $\begingroup$ This wouldn't contradict l'Hopital rule, because $f'(x)$ wouldn't be defined for all real numbers. $\endgroup$
    – Wojowu
    Dec 26, 2018 at 17:11
  • $\begingroup$ @Wojowu so you're implying that the function cannot be differentiable once extended over R? I can't see stright away why this must be the case. The question would still remain, however, would it not? I mean: is such a function not uniformly continuous? Why? $\endgroup$
    – dfnu
    Dec 26, 2018 at 17:22
  • 2
    $\begingroup$ We can deduce that either a function is not uniformly continuous, or the function it extends to is not differentiable. It is in fact possible that the function is uniformly continuous; I can outline a construction in an answer later, if nobody else does. $\endgroup$
    – Wojowu
    Dec 26, 2018 at 17:27
  • 1
    $\begingroup$ What is the definition of a differentiable function on $\mathbb Q?$ $\endgroup$
    – zhw.
    Dec 26, 2018 at 18:00
  • 1
    $\begingroup$ @zhw definition is the same as in R. In fact differentiability itself does not require completeness. Completeness is necessary for theorems such as Rolle's, Lagrange's (Intermediate Value), Cauchy's (Generalized Intermediate Value), de l'Hopital's. $\endgroup$
    – dfnu
    Dec 26, 2018 at 18:07

1 Answer 1


Actually $f$ can be uniformly continuous.

Edit: A hugely simplified and cleaned up version of what I posted earlier:

Oops: I just realized that what's below is not quite a counterexample to the assertion in the OP. We construct a uniformly continuous $f:\Bbb R\to\Bbb R$ such that $f'(0)=1$ and $f'(r)=0$ for every non-zero rational $r$, but there's no reason to think that $f(\Bbb Q)\subset\Bbb Q$. I'm leaving this here anyway because (i) the construction is quite simple, (ii) it does serve to show that the OP's argument purporting to show that $f$ cannot be uniformly continous is wrong, since that argument would work just as well for $f:\Bbb Q\to\Bbb R$, and (iii) come to think of it it's not hard to fix it to give a literal counterexample (see Fix below).

Say $r_1,r_2,\dots$ is an enumeration of the non-zero rationals. For each $n$ choose $\delta_n\in(0,|r_n|/2)$ in such a way that if $I_n=(r_n-\delta_n,r_n+\delta_n)$ and $$E=\Bbb R\setminus\bigcup I_n$$then $$\lim_{\rho\to0}\frac1\rho m(E\cap(0,\rho)) =\lim_{\rho\to0}\frac1\rho m(E\cap(-\rho,0)) =1.$$(It's clear that happens if $\delta_n\to0$ fast enough; Details below if it's not clear). Let $$f(x)=\int_0^x\chi_E(t)\,dt.$$Then $f:\Bbb R\to\Bbb R$ is Lipshitz, hence uniformly continuous, $f'(r_n)=0$ because $f$ is constant on $I_n$, and the condition on density of $E$ at the origin implies that $f'(0)=1$.

Details: We will show that if $\delta_n\to0$ fast enough then $f'(0)=1$ (that being what we care about - it's equivalent to the statement that $0$ is a point of density for $E$.) In fact

If $\sum\delta_n/|r_n|<\infty$ then $f'(0)=1$.

Note first that since $0<\delta_n<|r_n|/2$ that condition is equivalent to $\sum\frac{\delta_n}{|r_n|-\delta_n}<\infty$.

Let $$g(x)=x-f(x)$$ and $$G(x)=\sum g_n(x),$$ where $$g_n(x)=\int_0^x\chi_{I_n}.$$ We will avoid worrying about $\int_0^x$ for $x<0$ by showing only that the right-hand derivative of $g$ at the origin vanishes; of course the same applies to the left-hand derivative. Since $$0\le\frac{g(x)-g(0)}{x}\le\frac{G(x)}{x}\quad(x>0)$$it's enough to show that $$\lim_{x\to0^+}\frac{G(x)}{x}=0.$$Define $D_n(x)$ for $x\ge0$ by $$D_n(x)=\begin{cases}\frac{g_n(x)}{x},&(x>0), \\0,&(x=0).\end{cases}$$Since $g_n'(0)=0$ it follows that $D_n$ is continuous on $[0,\infty)$. It's clear that $$D_n(x)=0\quad(0\le x\le|r_n|-\delta_n)$$ and $$|D_n(x)|\le\frac{2\delta_n}{|r_n|-\delta_n}\quad(x>|r_n|-\delta_n).$$So the series $\sum D_n$ converges uniformly on $[0,\infty)$, and hence $$D=\sum D_n$$ is continuous on $[0,\infty)$. But $$D(x)=\begin{cases}\frac{G(x)}{x},&(x>0),\\0,&(x=0);\end{cases}$$hence $\lim_{x\to0^+}G(x)/x=0$.

Fix: A patch for the problem mentioned in Oops above:

Lemma. Suppose $(y_n)$ is a sequence of non-zero reals. There exists a uniformly continuous $\psi:\Bbb R\to\Bbb R$ such that $\psi(0)=0$, $\psi'(0)=1$, and $\psi(y_n)$ is rational for every $n$.

That seems quite clear, since we're not requiring more than continuity except at one point. Anyway:

Proof: Suppose $y_n\ne y_m$ for $n\ne m$. For each $n$ choose an open interval $I_n$ with $0\notin I_n$, $y_n\in I_n$ and $y_k\notin I_n$, $1\le k<n$. Let $\phi_n$ be a continuous function supported in $I_n$ with $\phi_n(y_n)\ne0$. We will let $$\phi=\sum c_n\phi_n$$for suitable constants $c_n$.

First, if $c_n\to0$ fast enough then the series converges uniformly, hence $\phi$ is uniformly continuous, since the partial sums are uniformly continuous.

Second, if $c_n\to0$ fast enough then $$|\phi(x)|\le x^2.$$(For example, if $c_n$ is small enough then $|c_n\phi_n(x)|\le x^2/2^n$ for all $x$.)

Finally, it's clear that we may choose the $c_n$ one by one, "small enough" as in the previous two paragraphs, so that $$y_n+\sum_{j=1}^n c_j\phi_j(y_n)\in\Bbb Q$$ for all $n$. Since $y_n\notin I_j$ for $j>n$ this implies that $$y_n+\phi(y_n)=y_n+\sum_{j=1}^n c_j\phi_j(y_n)\in\Bbb Q.$$

Now let $\psi(x)=x+\phi(x)$. QED.

Now to fix the construction above: Let $E$ and $f$ be as above. Say the connected components of $E$ are $J_1,J_2,\dots$. Note that $f$ is constant on each $J_n$; let $y_n$ be this constant. Choose $\psi$ as in the lemma and let $F=\psi\circ f$.

Then $F'(0)=1$. Also $F(0)=0\in\Bbb Q$, while if $r$ is a non-zero rational then there exists $n$ with $r\in J_n$; hence $F'(r)=0$, since $F$ is constant on $J_n$, and also $F(r)=\psi(y_n)\in\Bbb Q$.

  • $\begingroup$ Cool! So this function (on $\mathbb R$) will not be differentiable in any neighborhood of 0! $\endgroup$
    – dfnu
    Dec 26, 2018 at 20:07
  • $\begingroup$ Thanks for this new version! $\endgroup$
    – dfnu
    Dec 27, 2018 at 7:39
  • $\begingroup$ @Matteo Decided to add details for $f'(0)=1$, since that's the only subtle or tricky part.. $\endgroup$ Dec 27, 2018 at 14:06
  • $\begingroup$ Before receiving your notification I was exactly thinking to the same problem of your "Oops" and was wondering whether we could have a counterexample with $f(\mathbb Q) \subset \mathbb Q$! I'll need some time to get through it thouroughly. Thanks in advance! $\endgroup$
    – dfnu
    Dec 27, 2018 at 17:02
  • $\begingroup$ I'm not familiar with the notation $m(\cdot )$ and not sure about its meaning. Can you define it? $\endgroup$
    – dfnu
    Dec 28, 2018 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .