Is there a differentiable function $f:\mathbb R \rightarrow \mathbb R$ such that $f(\mathbb Q) \subseteq \mathbb Q$, but $f'(\mathbb Q) \not \subseteq \mathbb Q$? A friend of mine asserted this without giving any examples. I seriously doubt it, but I had hard time trying to disprove it since analysis isn't really my thing. I can't even think of any class of differentiable functions with $f(\mathbb Q) \subseteq \mathbb Q$ other than the rational functions.

  • $\begingroup$ Just an observation :- If $f'(x)$ could be made a constant irrational , then $f(x) $ maps rationals to irrationals $\endgroup$ Aug 12, 2020 at 12:18
  • $\begingroup$ Yeah, but that can only happen if $f(x)$ is linear, no? $\endgroup$ Aug 12, 2020 at 12:20
  • 4
    $\begingroup$ Yes, if $f'(x)$ is constant irrational then $f$ is of the form $f(x) =ax+b$ with $a \in \Bbb{R}\setminus \Bbb{Q}$ $\endgroup$ Aug 12, 2020 at 12:21
  • $\begingroup$ $g(t)=\int_a^{ta} m(x)dx\quad \text{where}\quad a\in \mathbb R/\mathbb Q$ Functions of this figure may be realized $\endgroup$ Aug 12, 2020 at 12:43
  • $\begingroup$ Pretty much any non-rational analytic function that maps rationals to rationals would do that, see Functions that take rationals to rationals $\endgroup$
    – Conifold
    Aug 12, 2020 at 12:46

3 Answers 3


Nice question.

Here is my solution. It would be nice to know if there is a simpler example.

This is basically a "spline" example. First, if $A,B,C,D,r,s$ are all rational numbers, and $r < s$, then there exist rational numbers $a,b,c,d$ so that the cubic polynomial $f(x) = ax^3+bx^2+cx+d$ satisfies $f(r)=A,f'(r)=B, f(s)=C, f'(s)=D$. The proof is: write down the system of equations and solve for $a,b,c,d$. As long as $r \ne s$ the solution is rational in $A,B,C,D,r,s$.

Remark 1. Computation shows that if $B=D=0$, then the graph of $f$ on $[r,s]$ lies inside the rectangle with opposite corners $(r,A)$ and $(s,C)$. [Differentiate the cubic, then factor to find that the derivative vanishes at the two endpoints $r,s$.]

The construction First, choose your favorite irrational number, let's say $\pi$. Consider the two curves $\phi_1(x)=\pi x$ and $\phi_2(x) = \pi x + x^3$.


Of course, any function $f$ with graph between these two has $f'(0)=\pi$. Define such a function by using a sequence of rational "knots" $r_n \searrow 0$ and $A_n$ so that $$ \phi_1(r_n) < A_n < \phi_2(r_n) $$ Then fill in with the splines as explained, to get a function $f$ with $f(r_n) = A_n$ and $f'(r_n) = 0$ for all $n$. Do the same thing on the negative side. Finallly let $f(0)=0$.

This gives us $f : \mathbb R \to \mathbb R$ such that $f(\mathbb Q) \subseteq \mathbb Q$, $f$ is differentiable except possibly at $0$, and $$ \lim_n \frac{f(r_n)-f(0)}{r_n-0} = \pi $$ is irrational.

What remains: we need to choose the sequences $r_n$ and $A_n$ so that the rectangles with opposite vertices $(r_n,A_n)$ and $(r_{n+1},A_{n+1})$ lie entirely between $\phi_1$ and $\phi_2$. Then by Remark 1, $f$ remains between $\phi_1$ and $\phi_2$, so $f'(0)=\pi$.

  • 1
    $\begingroup$ as you say, there is probably a shorter argument. But yours is the only one among those proposed that I understand, and a nice idea. Nice job. $\endgroup$
    – Jake Mirra
    Aug 12, 2020 at 12:51
  • $\begingroup$ I wish I could upvote that several times. Very nice answer! $\endgroup$
    – Aphelli
    Aug 12, 2020 at 13:16
  • $\begingroup$ @GEdgar Please clarify one question . Why is $f(\mathbb{Q}) \subseteq \mathbb{Q}$ true? Is it because $f(r_n)=A_n$ ? But then, are all the positive rationals included in the decreasing sequence $\{r_n\}$ ?Thanks, sir. $\endgroup$ Aug 12, 2020 at 15:08
  • $\begingroup$ @user710290 ... The function $f$ is made up piecewise of segments where it is a cubic spline polynomial with rational coefficients. This is explained at the beginning. Not all rationals are included, the sequence $r_n$ converges to $0$. $\endgroup$
    – GEdgar
    Aug 12, 2020 at 16:05
  • $\begingroup$ @GEdgar Ok , got it. Since the coeffiecients are rationals , $f$ cannot map rationals to irrationals. Thanks ! $\endgroup$ Aug 12, 2020 at 16:26

This answer shares the use of cubic splines with that of GEdgar. Consider the following polynomial function: $$ p(x)=2(x-1)^3-3(x-1)^2+1$$ $p$ satisfies $p'(1)=p'(2)=0$. Studying $p$ in the interval $[1,2]$ we see that in this interval $p$ is non negative and strictly decreasing, with $p(1)=1$ its maximum and $p(2)=0$ its minimum. Therefore the function: $$ h(x)= \begin{cases} 1& |x|\leq 1\\ p(|x|)& 1<|x| \leq 2\\ 0 &|x|>2 \end{cases} $$ is in $C^1(\mathbb{R})$. Now set: $$ g_n(x)=h(nx)/n!$$ and consider $g(x):=\sum_{n=0}^{+\infty} g_n(x)$.

What we are going to prove is that $f(x):=xg(x)$ is a differentiable function and satisfies $f(\mathbb{Q})\subseteq \mathbb{Q}$ and $f'(0)=e$.

Let's first discuss the values taken by $f$ on the rationals. The function $g_n$ takes only rational values in every rational point and for $n>0$ we have $g_n$ is zero outside $[-2/n,2/n]$. This means that for every $q \in \mathbb{Q}-\{0\}$ the sequence $(g_n(q))$ is eventually zero, so that $g(q)$ is in fact a finite sum of rationals and $f(q)=qg(q)$ is also rational. We also have $g(0)=e$ but clearly $f(0)=0\cdot e=0 \in \mathbb{Q}$.

To show $f$ is differentiable, it is enough to show $g$ is. Since $g'_n(x)= h'(nx)/(n-1)!$ for $n>1$, we have $\sum g'_n$ converges uniformly on $\mathbb{R}$ and since $\sum g_n(0)$ converges we deduce that also $g$ is differentiable, with $g'=\sum g_n'$.

Finally, $f'(0)= g(0)=e$. This concludes the proof.

  • $\begingroup$ +1 I like it... $\endgroup$
    – GEdgar
    Aug 12, 2020 at 16:12
  • 1
    $\begingroup$ @GEdgar Thank you! Also, we get $f \in C^1(\mathbb{R})$ (even if not required,though) $\endgroup$ Aug 12, 2020 at 17:01

Here is another answer. Define $h:[0,+\infty)\to \mathbb{R}$ as follows: $$h(x):= \frac{1}{(n+1)!}(n+1-n(x-n)) \quad \text{for } x\in [n,n+1)$$ The function $h$ is continuous and satisfies $h(k)=1/k!$ for every $k$ integer in its domain. Moreover: $$ \int _0^{q}h(t)dt \in \mathbb{Q} \quad \forall q \in \mathbb{Q}$$ since on every interval of the type $[n,n+1)$ the function $h$ is an affine function with rational coefficients. A direct computation shows: $$ \int _0^{\infty}h(t)dt = \sum_{k=0}^{+\infty} \frac{1}{2}\big( \frac{1}{k!} + \frac{1}{(k+1)!}\big) = e - \frac{1}{2}$$ Define now $f:\mathbb{R}\to \mathbb{R}$ as follows: $$f(x):= \begin{cases} 0 & x=0\\ x \int _0^{1/|x|}h(t)dt & x\neq 0 \end{cases} $$ Then $f$ satisfies $f(\mathbb{Q})\subseteq \mathbb{Q}$ and it is differentiable in $x\neq 0$ for the fundamental theorem of integral calculus. What about $x=0$? We have: $$\lim_{x\to 0}\frac{f(x)-f(0)}{x-0} = \lim_{x\to 0}\frac{x \int _0^{1/|x|}h(t)dt}{x}= \int _0^{+\infty}h(t)dt = e - \frac{1}{2}$$ Hence $f$ is differentiable on the whole real line and $f'(0)= e-1/2 \notin \mathbb{Q}$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.