1

Does there exist a continuous function $f:\mathbb{R}\to\mathbb{R}$ such that $$x\in\mathbb{R}\setminus\mathbb{Q}\implies f(x)\in\mathbb{Q}$$ and $$x\in\mathbb{Q}\implies f(x)\in\mathbb{R}\setminus\mathbb{Q}\;\;\;?$$

user829347
  • 3,606
  • 10
  • 32

1 Answers1

9

The function $g(x):= xf(x)$ assumes only irrational values, or $0$. If $g(x)$ assumes more than one value, by the intermediate value theorem it assumes all values on an interval (since $g$ is continuous as the product of two continuous functions). This interval necessarily contains a nonzero rational number, a contradiction. So $g(x)\equiv c$ must be constant.

If $c=0$, then $f(x)=0$ on the nonzero rationals, a contradiction. If $c\neq 0$, then $f(x)=c/x$, which is not defined (and thus not continuous) at $x=0$, a contradiction.

So no such $f$ exists.

Rod Laver
  • 260
  • 1
    A very nice proof! – Paul Frost Jan 22 '22 at 00:25
  • 2
    Yeah this proof is incomplete, as a caveat needs to be introduced both for $f(x)=0$ as @MartinR mentions as well as for $x=0$. – Dustan Levenstein Jan 22 '22 at 00:47
  • Yeah OK, thanks for pointing that out. It's fixed. I didn't need a caveat for both, just to consider $g=0$. – Rod Laver Jan 22 '22 at 00:57
  • 2
    Nicely done, Rod, and glad to have you in the community. – Dustan Levenstein Jan 22 '22 at 01:11
  • Nice, but not new: https://math.stackexchange.com/a/2441084/42969 – Martin R Jan 22 '22 at 05:03
  • @MartinR OK, I didn't see that. What do you propose should be done? I thought if this question were a duplicate, a moderator would have taken it down long before I wrote an answer... It's inconvenient for new users to lose upvotes post facto. – Rod Laver Jan 22 '22 at 05:20
  • 1
    @RodLaver: Here are my personal thoughts. First, and most important: The question does not match the standards of this site and so should not be answered in the first place. Instead, encourage new users to improve their posts. As you can see, the question has been closed for that reason. – Martin R Jan 22 '22 at 08:38
  • (Cont.) I don't know what you mean by “taken down long before I answer” – you answered the question shortly after it was posted. Anyway, searching for duplicates is expected from all users and not a special task for moderators. In this case it took me a while to find an exact duplicate, so one cannot blame you on that. – Martin R Jan 22 '22 at 08:38
  • (Cont.) Whether you delete your answer or not is up to you. I would do it because the identical answer has been posted before. But of course I am in a different position (rep wise :-) – Martin R Jan 22 '22 at 08:38
  • As I recall, the problem had around 20 views when I answered it, and other moderators had already commented above. That's why I assumed it would've been taken down long before I posted my answer, but I wasn't aware the question had just been posted. – Rod Laver Jan 22 '22 at 08:55
  • (Cont.) I was aware of the T&C around question format, but again, the fact that the moderators were discussing it and it had no downvotes made me think it was OK to post an answer. I'm happy to comment rather than answer next time though, if this is preferred. – Rod Laver Jan 22 '22 at 08:56
  • (Cont.) I'll also do a preliminary search for duplicates before I answer next time, but spending too much time on that does in my opinion detract from the appeal of the site to new users, and should (I think) fall more to the moderators. – Rod Laver Jan 22 '22 at 08:56
  • (Cont.) I'm going to leave my answer up because I think it's phrased a bit more concisely than the one you pointed out to me, and also (as you alluded to), gaining reputation at this level is tedious (I've tried to flag to moderators where I was a victim of upvote syphoning by more experienced contributors duplicating my solutions on the same post). – Rod Laver Jan 22 '22 at 08:56