Continuous functions with a certain condition

What is the class of continuous functions $f\colon \mathbb{R}\to\mathbb{R}$ which satisfy

$f(x)-f(y)\in\mathbb{Q}$ if and only if $x-y\in \mathbb{Q}$?

-
No, $f(x) = x$ satisfies it too. – Karolis Juodelė Jan 31 '13 at 12:02
In fact, constant functions do not satisfy this condition. – Hagen von Eitzen Jan 31 '13 at 12:06
Sorry, I meant multiples of $x$... :) – user60253 Jan 31 '13 at 12:08
Note that $f(x)=\pi+\frac23x$ is ok, but $f(x)=\frac23+\pi x$ is not. – Hagen von Eitzen Jan 31 '13 at 12:11
@mrf With $f:x\mapsto|x|$, $x=\pi$ and $y=-\pi$, $f(x)-f(y)=0\in\mathbb Q$ but $x-y=2\pi\notin\mathbb Q$. – Sebastien B Jan 31 '13 at 13:03

1 Answer

Let $t$ be a rational number. Consider the function $g(x)=f(x+t)-f(x)$. Then $g$ is continuous also and takes values only in $\mathbb Q$, so $g$ is constant. It follows that $g(x)=g(0)=f(t)-f(0)=c(t)$.

So we have

$$f(x+t)=f(x)+c(t) \tag{1}$$

for any real $x$ and rational $t$. Then $c$ is certainly linear, so there is an $r\in {\mathbb Q}$ such that $c(t)=rt$ for any rational $t$. So $f(t)=f(0)+rt$ by taking $x=0$ in $1$.

The continuity of $f$ then implies that $f(t)=f(0)+rt$ for all $t$. Conversely, functions of this form are clearly solutions.

UPDATE (in answer to a comment) : here is a more detailed explanation of why $c$ is linear.

We have $c(t_1+t_2)=f(t_1+t_2)-f(0)$ (take $x=0$ in (1)), and $c(t_1)=f(t_1)-f(0)$ (take $x=0$ in (1)), $c(t_2)=f(t_1+t_2)-f(t_1)$ (take $x=t_1$ in (1)). So $c(t_1+t_2)=c(t_1)+c(t_2)$.

-
"Then $c$ is certainly linear." Is it obvious? – Sebastien B Jan 31 '13 at 13:08
@Sebastien B: Consider $f(x+t_1+t_2)$. – sdcvvc Jan 31 '13 at 13:11
What about $f:x\mapsto x$ if $x\leq 0$ and $x\mapsto 2x$ if $x\geq 0$ (in the spirit of the attempt of mrf). – Sebastien B Jan 31 '13 at 13:12
@SebastienB : please read my update. – Ewan Delanoy Jan 31 '13 at 13:19
My attempt also fails with $x=-\sqrt{2}$ and $y=2-\sqrt{2}$. So I take it back. – Sebastien B Jan 31 '13 at 13:21