Consider the function \begin{align*} h(x) = \begin{cases} x & \text{if } x \in \mathbb{Q} \\ 0 & \text{if } x \in \mathbb{R} \setminus \mathbb{Q}. \end{cases} \end{align*} Prove it is not continuous on $\mathbb{R} \setminus \{0\}$.

My working to show that it is not continuous on $\mathbb{R} \setminus \{0\}$ is as follows. However, I am wondering, how can I show it is continuous at $0$? Let $(z_n)$ be any sequence such that $(z_n) \rightarrow 0$, I need to show that $h(z_n) \rightarrow 0$. But how? It is certainly obvious, but I can't seem to formally provide an argument.

First, we show that the above function is not continuous at any real number different from $0$. Let $r \neq 0 \in \mathbb{Q}$, since the set of irrationals is dense in $\mathbb{R}$, then there exists a sequence $(x_n)$ contained in the irrationals such that $\lim_{n \rightarrow \infty} x_n = r$. Note that $h(x_n) = 0$ for all $n \in \mathbb{N}$ so $\lim_{n \rightarrow \infty} h(x_n) = 0$ while $h(r) = r \neq 0$. So $\lim_{n \rightarrow \infty} h(x_n) \neq h(r)$, which shows that $h(x)$ is not continuous at any $r \neq 0 \in \mathbb{Q}$.

Now let $i \neq 0 \in \mathbb{R} \setminus \mathbb{Q}$. Since $\mathbb{Q}$ is dense in $\mathbb{R}$, there exists a sequence $(y_n)$ contained in $\mathbb{Q}$ such that $\lim_{n \rightarrow \infty} y_n = i$. Note that $h(y_n) = y_n$ for all $n \in \mathbb{N}$. Therefore, $\lim_{n \rightarrow \infty} h(y_n) = i \neq 0$ while $h(i) = 0$. So, $\lim_{n \rightarrow \infty} h(y_n) \neq h(i)$, which implies that $h(x)$ is not continuous at any $i \neq 0 \in \mathbb{R} \setminus \mathbb{Q}$.

  • $\begingroup$ Note that $|h(z_n)|\le z_n$, so if $z_n\to 0$, then... $\endgroup$
    – Mathmo123
    Jul 24, 2017 at 10:32
  • $\begingroup$ Let $\varepsilon >0$, then there exists a $N \in \mathbb{N}$ such that $|z_n|<\varepsilon$ for $n \ge N$. Note that $|h(z_n)| \le |z_n| < \varepsilon$ for $n \ge N$ so $\lim_{n \rightarrow \infty} h(z_n) = 0 = h(0)$. Right? $\endgroup$
    – Trts
    Jul 24, 2017 at 10:44
  • $\begingroup$ It should be noted that this is not the original definition of continuity (nor the equivalent Heine version, which should be: given any sequence $z_n\to 0$, not necessarily contained entirely in $\Bbb Q$ or $\Bbb R\setminus \Bbb Q$, we have $f(z_n)\to 0$). The implication from the below answer to the Heine version is trivial, though. $\endgroup$
    – Vim
    Jul 24, 2017 at 10:44

1 Answer 1


We will prove that $f$ is continuous at zero.

Let $\epsilon>0$.

We have that $f(0)=0$.

We must find $\delta>0$ such that $\forall x:|x|< \delta \Rightarrow |f(x)|< \epsilon$

Now for $0<\delta< \min\{\epsilon,1\}$ we see that if $x \in (-\delta,\delta) \cap \mathbb{Q}$ then $|f(x)|=|x|< \delta < \epsilon$

If $x \in (-\delta,\delta) \cap \mathbb{R}$ \ $\mathbb{Q}$ then $|f(x)|=0< \epsilon$

In either way $|f(x)|< \epsilon, \forall x \in (-\delta,\delta)$ for the chosen $\delta$, thus $f$ is continuous at $0$.

Now suppose that exists $x_0 \neq 0$, a point of continuity of $f$.

Then from the density of rationals and irrationals in the real line, exist $z_n \in \mathbb{Q}$ and $r_n \in \mathbb{R}$\ $\mathbb{Q}$ such that: $$z_n \rightarrow x_0$$ $$r_n \rightarrow x_0$$ From continuity we have that:

$$f(r_n)=0 \rightarrow f(x_0) \Rightarrow f(x_0)=0$$ $$z_n=f(z_n) \rightarrow f(x_0)$$

Thus $f(x_0)=x_0$ and $f(x_0)=0$ therefore $x_0=0$ a contradiction.

We conclude that $f$ is continuous only at $x_0=0$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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