Is there any function $$f:\mathbb R \rightarrow \mathbb R$$ such that it is only continuous at rational numbers?
-
https://en.wikipedia.org/wiki/Thomae%27s_function this does the opposite of what you want – Asinomás Jul 10 '15 at 14:57
-
No , this is impossible. This can be found in the wikipedia article on the Thomae's function here – Asinomás Jul 10 '15 at 15:00
-
Older posts about the same question: No function that is continuous at all rational points and discontinuous at irrational points. and Does it exist a function that is continuous at every rational point and discontinuous at every irrational point?And vice versa? – Martin Sleziak Jul 10 '15 at 15:40
3 Answers
No. The reason is that the points of continuity of a function form a $G_\delta$ set, i.e. the intersection of a countable collection of open sets. This can be seen by writing it as the intersection of $U_m$ for all positive integers $m$, where x is in $U_m$ if there is some $\epsilon > 0$ such that for all $y$ and $z$ in the interval $(x-\epsilon,x+\epsilon)$, $|f(y)-f(z)| < 1/m$. $U_m$ is an open set. As a consequence of the Baire Category Theorem, the rational numbers are not a $G_\delta$.
- 470,583
You ask if there is a function that is only continuous at rational numbers. The function
$$
f(x) = \begin{cases}x & \text{if } x \text{ is rational} \\
-x & \text{if } x \text{ is irrational}
\end{cases}
$$
is only continuous at $0$. So it is only continuous at rational numbers.
Now, if you meant to ask whether there is a function with domain the real numbers that is continuous at exactly all the rational numbers and discontinuous anywhere else, then no such function exists. The other answers give you reasons for this.
- 44,491
No, there is no function $f:\mathbb{R} \rightarrow \mathbb{R}$ that is only continuous at the rational numbers. The set of discontinuities must be an $F_{\sigma}$ set, which the irrationals are not.
If you change the question and ask about a function that is only continuous at the irrational numbers, then the answer is yes. Consider Thomae's function $f(x)=\begin{cases}
\frac{1}{q} &\text{if }x\text{ is rational, }x=\tfrac{p}{q}\text{ in lowest terms and } q > 0\\
0 &\text{if }x\text{ is irrational.}
\end{cases}$
- 2,352
- 1
- 13
- 19