Continuous functions mapping subgroups of R to subgroups of R My question is simple to state: Suppose that $f:\mathbb{R}\rightarrow\mathbb{R}$ is continuous and has the property that $f[G]$ (the image of $G$ under $f$) is a subgroup of $\mathbb{R}$ for every subgroup $G$ of $\mathbb{R}$. Must $f$ be an endomorphism of $(\mathbb{R},+)$? In other words, is it true that $f(x)=ax$ for some real number $a$ (recall that $f$ is assumed continuous)? 
 A: Not necessarily.
Consider a function of the form $f(x)=e(x)x+b(x)$ with $e(x)\in\mathbf{Q}$ for all $x$ and $b(x)\in\mathbf{Z}$ for all $x$, to be specified, with $b(0)=0$.
Clearly such a function satisfies $f(G)\subset \mathbf{Q}^*G+\mathbf{Q}$ for every subgroup $G$ of $\mathbf{R}$. Let's find $e$ and $b$ so that $f$ is continuous and satisfies $f(G)= \mathbf{Q}^*G+\mathbf{Q}$ for every subgroup $G$ not reduced to $\{0\}$.
Let $(J_i)_{i\in\mathbf{I}}$ be countably many nonzero segments contained in the set $\mathbf{R}^*$ of nonzero reals, whose union is all of $\mathbf{R}^*$. For each $i\mathbf{N}$ and each $(p,q)\in\mathbf{Q}\times\mathbf{Q}^*$, choose a positive integer $n(i,p,q)$, in such a way that, defining $K_{i,p,q}=n(i,p,q)J_i$, we have


*

*the $K_{i,p,q}$ are pairwise disjoint

*the $K_{i,p,q}$ form a locally finite family, in the sense that for each $R<\infty$ the number of triples $(i,p,q)$ such that $K_{i,p,q}$ has nonempty intersection with $[-R,R]$ is finite.


Now define $e$ to be equal to $q/n(i,p,q)$ on $K_{i,p}$ and we define $b$ to be equal to $p$ on $K_{i,p}$. We can extend this to get $f$ continuous with $f(0)=0$, and piecewise affine (with rational slopes and constants) as required.
Then for each nonzero $x$ and each $(p,q)\in\mathbf{Q}\times\mathbf{Q}^*$, if $x\in J_i$, then $f(n(i,p,q)x)=qx+p$; thus $(\mathbf{Q}^*G+\mathbf{Q})\smallsetminus\mathbf{Q}\subset f(G)$ for every subgroup $G$ of $\mathbf{R}$.
We are very close to the required conclusion, but to also get $\mathbf{Q}$, we need to also consider positive integers $n'(i,p)$, so that the $L_{i,p}=n'(i,p)K_{i,p}$ are pairwise disjoint and locally finite and also disjoint of the $n(i',p',q')$, and to require $f$ to be equal to $p$ on $L_{i,p}$. 
Thus with this construction, $f$ is continuous, $f(\{0\})=\{0\}$ and $f(G)=\mathbf{Q}^*G+\mathbf{Q}$ for any nonzero subgroup of $\mathbf{Q}$. Of course $f$ is not linear (for instance because $f^{-1}(\{1\})$ contains a nonzero segment).
