Is there a function such that $f(\mathbb Q) \subseteq \mathbb Q$ but $\{x \in \mathbb Q: f'(x) \notin \mathbb Q\}$ isn't nowhere dense? I've recently asked a question
about functions such that $f(\mathbb Q) \subseteq \mathbb Q$ but $f'(\mathbb Q) \not \subseteq \mathbb Q$. It got some really clever and beautiful answers -- in particular, @GEdgar's example was very informative. However, all the constructions presented there were very local and relied on carefully setting up an irrational derivative in isolated points. So, is there some clever construction where $\{x \in \mathbb Q: f'(x) \notin \mathbb Q\}$ isn't nowhere dense? EDIT: of course, this is assuming that $f: \mathbb R \rightarrow \mathbb R$ is differentiable everywhere.
 A: I will construct $f: \mathbb R \to \mathbb R$ that is continuously differentiable everywhere, with $f(\mathbb Q) \subseteq \mathbb Q$ but $f'(\mathbb Q) \cap \mathbb Q = \emptyset$.
Let $\{r_n\}_{n \ge 1}$ be an enumeration of the rationals. I will construct $f' = \sum_{n=1}^\infty g_n$,
and take $f(x) = \int_{-\infty}^x f'(t)\; dt$.  These will be defined inductively so that

*

*$g_n$ is nonzero only on an interval $(a_n, b_n)$ containing $r_n$ but no $r_k$ for $k < n$, and with $a_b < b_n < a_n + 1$.

*$g_n$ is continuous with $|g_n| < 2^{-n}$ everywhere.

*$\int_{a_n}^{b_n} g_n(x)\; dx = 0$.

*$\sum_{j=1}^n g_j(r_n)$ is irrational.

*$\sum_{j \le n:\; a_j < r_n} \int_{a_j}^{r_n} g_j(x)\; dx$ is rational.

It is easy to see that we can always take $g_n$ of the form
$$ g_n(x) = \cases{(x-a_n)(x-b_n)(\alpha + \beta x + \gamma x^2) & for $a_n \le x \le b_n$\cr 0 & otherwise}$$
because the linear map
$$ (\alpha, \beta, \gamma) \to \left( g_n(r_n), \int_{a_n}^{r_n} g_n(x)\; dx, \int_{a_n}^{b_n} g_n(x)\; dx\right)$$
is invertible.
By (2.), the series $\sum_{n=1}^\infty g_n$ converges uniformly to a continuous function, and by (1.) and (2.) $\int_{-\infty}^\infty \sum_{n=1}^\infty |g_n(x)|\; dx < \infty$, so $f$ is well-defined and $C^1$.
By (1.), $f'(r_n) = \sum_{j=1}^n g_j(r_n)$, which is irrational by (4.).
By (1.), (3.) and (5.), $f(r_n) = \sum_{j \le n:\; a_j < r_n} \int_{a_j}^{r_n} g_j(x)\; dx$ is rational.
