5

Let $f: [a, b]\to \mathbb R$ be a continuous function such that for all $r\in\mathbb R$, $f(r)$ is rational iff $r$ is rational. Does it follow that $f$ is a rational function?

Nishant
  • 9,155

1 Answers1

3

EDIT: I missed the "iff" in the original question. As such, the answer below is not correct, it provides examples of functions where $f(r)$ is rational if $r$ is rational, but not necessarily only for rational $r$. Piecewise linear functions still work, though, for more complicated examples see this MathOverflow thread


It does not have to be, any continuous and piecewise rational function with rational coefficients will do this, too. And there are even weirder functions, using very non-explicit constructions. E.g., Cantor showed that any densely ordered countable set without endpoints has the order type of the rationals. So if you take any dense subset $S \subseteq \mathbb{Q}$, there is a strictly increasing homeomorphism $f:\mathbb{Q} \to S$ which extends by continuity to a homeomorphism of the real line to itself which maps rational numbers to rational numbers. By choosing $S$ in weird ways, you can make sure that $f$ is not a rational function on any interval.

Lukas Geyer
  • 18,259