Let $f:\mathbb{R}\to\mathbb{R}$, where $ f(x) = \begin{cases} 2x+1, & \text{if $x$ is rational} \\ \sqrt2 x+3, & \text{if $x$ is irrational} \end{cases} $

The injectivity:

I worked out the injectivity of the function by finding a rational number $x_1$ and an irrational number $x_2$ such that $f(x_1)=f(x_2)$, but $x_1!=x_2$, which are $x_1=2, f(2)=2\cdot 2+1=5$ and $x_2=\sqrt{2}$, $f(\sqrt{2})=\sqrt{2\cdot 2}+3=5,f(2)=f(\sqrt{2})$ and $2!=\sqrt{2}$ which means that it's not injective.

The surjectivity:

If $x$ is rational $\implies y=2x+1\implies x=\frac{y-1}{2}$, and if $x$ is irrational $x=\frac{y-3}{\sqrt{2}}$;

I don't really know how to show that the function is surjective, but I know that when $y=2x+1$(the first equation), it will touch all the rational numbers, but I'm not sure about the second equation if there's an y it doesn't touch and if it doens't then it means that it's not surjective...

I was wondering if there is a general way to study the injectivity and surjectivity of these types of functions. Thanks for the help.


1 Answer 1


Your proof that $f$ is not injective is correct.

The given function $f$ is not surjective. Consider the irrational number $\sqrt{2}+3$. Since $2x+1$ is rational for any rational number $x$, we should find an irrational number $x$ such that $$\sqrt2 x+3=\sqrt{2}+3$$ which holds only if $x=1$ which is rational. Contradiction.

More generally, in the same way, we show that $f(\mathbb{R})$ does not include all irrational numbers of the form $\sqrt{2}q+3$ where $q$ is any rational number different from zero. As you already noted $f(\mathbb{R})\supset \mathbb{Q}$.

  • 1
    $\begingroup$ Minor nitpick (very, very minor). You assume to solve $f(x) = \sqrt 2 +3$ that the solutions $x$ must be irrational. What if the solution $x$ is rational? (The answer is, of course ludicrously easy, that that could only occur if $x = \frac{\sqrt 2+2}2$ is rational, which it isn't). $\endgroup$
    – fleablood
    Dec 21, 2021 at 15:27
  • 1
    $\begingroup$ @fleablood Thanks, for your comment. I edited my answer. Is it better now? $\endgroup$
    – Robert Z
    Dec 21, 2021 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .