# Can a function be continuous at one value of $x$ and discontinuous at all other $x\in\mathbb R$

I have:

$$f(x)=\begin{cases} x,&\text{if }x\in\Bbb Q\\ 0,&\text{if }x\notin\Bbb Q\;, \end{cases}$$

This function is continuous at $x=0$, but discontinuous everywhere else? (Between $f(0)=0$ there is an irrational number where $f(x)=0$ either side of $x=0$?)

How would I go about explaining or proving this? (I am fully stuck on trying to start this question off)

• to prove that $f$ is continuous at $0$ use the squeeze theorem, note that $|f(x)|\le|x|$ and $|x|$ is continuous at $0$. To prove that $f(x)$ is not continuous at $y\not=0$ note that if we approach $y$ with rational numbers then the limit of $f$ is $y$, but is we approach $y$ with irrationals then the limit of $f$ is $0$, so $f$ has different limits and cannot be continuous. – Mirko Mar 21 '15 at 19:37
• Assume that f is continuous at $x=a$. Take two sequences $x_n$ and $y_n$ in rationals and irrationals respectively that both converge to $a$. Use the continuity of f in $a$ and show that $a=0$. – Fermat Mar 21 '15 at 19:40
• The hard part in this whole problem is the part people always dismiss completely and that is to show for every irrational number $x$, there is a sequence of rational numbers that converges to $x$.Sure, this is pretty easy if you assume some facts about the decimal expansion of $x$, but these facts are hardly ever proved. – Git Gud Mar 21 '15 at 19:44

Let $\epsilon > 0$. Let $\delta = \epsilon$. Note that $f(0) = 0$.

Let $x \in \mathbb R$ be such that $|x - 0| < \delta$, i.e. $|x| < \delta$. Then, $|x| < \epsilon$.

If $x \in \mathbb Q$, then $|f(x) - f(0)| = |f(x)| = |x| < \epsilon$.

If $x \notin \mathbb Q$, then $|f(x) - f(0)| = |f(x)| = |0| = 0 < \epsilon$.

Therefore $f$ is continuous at $0$.

Let $a$ be irrational and suppose that $f$ is continuous at a.

Due to the denseness of $\mathbb Q$ in $\mathbb R$, there is a sequence $(x_n)_n$ of rationals converging to $a$.

Due to the continuity of $f$ at $a$, we have that $(f(x_n))_n$ converges to $f(a)$.

$a$ is irrational, so $f(a) = 0$. Then, $f(x_n) \rightarrow 0$.

For each $n \in \mathbb N$, $f(x_n) = x_n$ since all the terms of $(x_n)_n$ are rationals. Thus, $x_n \rightarrow 0$. The uniqueness of limits gives $a = 0$.

Now, let $a$ be rational and use the denseness of $\mathbb R - \mathbb Q$ to prove that $a = 0$.

This shows that $f$ can't be continuous at any point but $0$.

• I'm stuck on how to finish this off. Let $a$ be rational and suppose that $f$ is continuous at a. Due to the denseness of $\mathbb Q$-$\mathbb R$, there is a sequence $(y_n)_n$ of irrationals converging to $a$. Due to the continuity of $f$ at $a$, we have that $(f(y_n))_n$ converges to $f(a)$. $a$ is rational, so $f(a) = a$. Then, $f(y_n) \rightarrow a$. For each $n \in \mathbb N$, $f(y_n) = 0$ since all the terms of $(y_n)_n$ are irrationals. – se7en masta Mar 25 '15 at 22:17
• $\mathbb R$-$\mathbb Q$ I mean – se7en masta Mar 25 '15 at 22:56