# Inverse image of rational values

I am a postgraduate student of physics. While doing some research on Poincare's work on the integrability of the three body problem, I came up with the following problem (which I feel unable to handle, possibly due to my insufficient background in general topology):

Let $X$ be a topological space and consider a non-constant, continuous function $f:X\to\mathbb{R}$ ( where $\mathbb{R}$ is considered with its usual euclidean topology). Is the inverse image of the rational values $f^{-1}(\mathbb{Q})\subseteq X$, always a dense subset of the domain $X$?

I would appreciate any help. Sorry in advance if this is not really research level.

• Do you want to exclude examples like $f(x)=\pi$ and other constant valued irrational functions? These are trivially continuous and have $f^{-1}(\mathbb{Q})=\emptyset$ which isn't ever dense in $X$ unless $X=\emptyset$. – Alec Rhea Sep 20 '18 at 0:49
• yes you are right. i mean non-constant functions. I edited that. – olgchar Sep 20 '18 at 0:53
• Even if $f$ isn't globally constant, there could be an open subset of $X$ on which $f$ takes the value $\pi$ – Julian Rosen Sep 20 '18 at 1:19
• Maybe if the data is analytic (e.g., $X$ an analytic manifold and $f$ a real analytic function) there's more hope? – Todd Trimble Sep 20 '18 at 1:26

Here is a refinement of your question that has a positive answer. Suppose $X$ has a dense subset $U$ that admits a differentiable manifold structure, and that there is a dense subset $V$ of $U$ on which $f$ is differentiable with non-vanishing derivative. Then $f^{-1}(\mathbb{Q})$ is dense in $U$, hence it is dense in $X$.
• It's going to take a lot more patching than that even for nice spaces $X$ like manifolds. If $f$ is constant irrational just on an open set (and extended however you please to the rest of $X$), the inverse image of the rationals will miss that open. – Todd Trimble Sep 20 '18 at 1:21