Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recall that the set $\mathbb{Q}$ of rational numbers is countable; thus we can put them all in a sequence ({ i.e.}~we can enumerate them). Let $(r_n)$ be such a sequence and let $f(x)=\begin{cases} \frac{1}{n} &\text{ if } x=r_n\in \mathbb{Q}\\ 0 &\text{ if }x\notin \mathbb{Q}\end{cases}$.\

(1) Is this function injective (one-to-one)? Why or why not?

(2) Is $f(\mathbb{R})$ (the image/range of $f$) compact? Justify your answer.

(3) Which of the following preimages are countable: $f^{-1}(\{1/2\})$, $f^{-1}([0,1/2])$, $f^{-1}([1/2,1])$? Justify your answers.

(4) Prove that $f$ is continuous at every $x\in \mathbb{R}-\mathbb{Q}$ and discontinuous at every $x\in \mathbb{Q}$.

Response: I haven't got any work to show for any of them.

share|cite|improve this question
Not even for (1)? Do you think that there might be more than one irratonal number? For (3), can you at least describe the first of the three preimages? – Brian M. Scott Nov 13 '12 at 4:18

For $(1)$ we have that since $f(e)=f(\pi)$, but $e \neq \pi$ we have that $f$ is not one-to-one.

For $(2)$, we have that since $f(\mathbb{R}) \subset [0,1]$ and by the Heine-Borel Theorem $[0,1]$ is compact (clearly, closed intervals are closed and bounded) we have that $f(\mathbb{R})$ is compact.

For $(3)$, we have that $f^{-1}(\{1/2\})=x \in \mathbb{Q}$ so clearly $f^{-1}(\{1/2\})$ is countable since it is equal to a single value. We have that $f^{-1}([0,1/2])$ is uncountable since there are uncountably many irrationals in $\mathbb{R}$. We also have that $f^{-1}([1/2,1])$ is countable since $\mathbb{Q}$ is countable.

For $(4)$, Clearly, f is discontinuous at all rational numbers: since the irrationals are dense in the reals, for any rational x, no matter what ε we select, there is an irrational a even nearer to our x where f(a) = 0 (while f(x) is positive). In other words, f can never get "close" and "stay close" to any positive number because its domain is dense with zeroes.

To show continuity at the irrationals, assume without loss of generality that our ε is rational (for any irrational ε, we can choose a smaller rational ε and the proof is transitive). Since ε is rational, it can be expressed in lowest terms as a/b. We want to show that f(x) is continuous when x is irrational.

Note that f takes a maximum value of 1 at each whole integer, so we may limit our examination to the space between $\lfloor x \rfloor$ and $\lceil x \rceil$. Since ε has a finite denominator of b, the only values for which f may return a value greater than ε are those with a reduced denominator no larger than b. There exist only a finite number of values between two integers with denominator no larger than b, so these can be exhaustively listed. Setting δ to be smaller than the nearest distance from x to one of these values guarantees every value within δ of x has f(x) < ε.

share|cite|improve this answer
Your argument for (2) is unfinished; there are noncompact subspaces of $[0,1]$. Your argument for continuity of $f$ at the irrationals says "f takes a maximum value of 1 at each whole integer" which (along with some other assumptions I think) is inconsistent with the definition in the question. – Jonas Meyer Nov 13 '12 at 5:23
There is no reason to choose rational $\varepsilon$. Given $x\in\mathbb R\setminus \mathbb Q$ and $\varepsilon>0$ there exists $N>\frac{1}{\varepsilon}$, and there exists $\delta>0$ such that $|x-r_n|\geq \delta$ when $n<N$, etc. – Jonas Meyer Nov 13 '12 at 5:30
@Jonas could I see how you would fully answer (2)? – Joakim Nov 14 '12 at 18:10
@Joakim: No, not necessarily. Do you know what $f(\mathbb R)$ is exactly? – Jonas Meyer Nov 15 '12 at 2:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.