# Continuity On $\mathbb{Q}$

I need a continuous function $f:\mathbb{Q}\rightarrow \mathbb{R}$ and discontinuous $g:\mathbb{R}\rightarrow \mathbb{R}$ s.t $f(x)=g(x)$ for all rational $x$ s. So if I say $f(x)=0$ and $g(x)=0$ for $x \in \mathbb{R}\setminus\{\sqrt2\}$ and $g(x)=1$ at $x=\sqrt 2$ .would I be right?

-
yes,you are right – p.s Nov 3 '12 at 16:52

Yes, that will work.

More interesting examples would be

$$g(x) =\begin{cases} 1 & x\ge \sqrt 2 \\ 0 & x < \sqrt 2\end{cases}$$

or

$$g(x) = \begin{cases} 1 & x\notin\mathbb Q \\ 0 & x \in \mathbb Q \end{cases}$$

with $f$ in each case being the restriction of $g$ to $\mathbb Q$.

(Note, incidentally, the the first of these examples gives an example of a continuous function $\mathbb Q\to\mathbb R$ that cannot be extended to a continuous function $\mathbb R\to\mathbb R$).

-
@Pilot: What do you think is wrong about the second example (which is one minus the Dirichlet function)? The restriction of $g$ to $\mathbb Q$ is everywhere zero, which is perfectly continous, but $g$ itself is discontinuous everywhere. – Henning Makholm Nov 3 '12 at 17:00
Please define what is everywhere,everywhere in reals? – p.s Nov 3 '12 at 21:55
I don't see how the $f$ associated with the $g$ you provide in your first example can be continuous. I can take an $\varepsilon$ as small as I want such as $x_1 = \sqrt{2}-\varepsilon$ and $x_2=\sqrt{2}+\varepsilon$ are rational, and I will have $f(x_1)=0$ and $f(x_2)=1$, which will show that $f$ is not continuous. Am I missing something? – S4M Nov 4 '12 at 0:25
@S4M: When we say that $f:\mathbb Q\to\mathbb R$ is "continuous" we mean that it is continuous at every point in its domain. Since the domain is $\mathbb Q$, it is (more than) enough that you can take any $a\in\mathbb Q$ and find an $\delta$ such that $f$ is constant between $a-\delta$ and $a+\delta$ -- and you can always find such a $\delta$ just by choosing it less than $|a-\sqrt2|$. We know that $a\ne\sqrt2$ because by assumption $a$ must be something in the domain of $f$. – Henning Makholm Nov 4 '12 at 2:35
@Pilot: When I say that $f$ is zero everywhere, I mean that it $f(x)=0$ for every $x$ in the domain of $f$. By your own initial requirement, the domain of $f$ is to be $\mathbb Q$, so "everywhere" means everywhere on $\mathbb Q$. – Henning Makholm Nov 4 '12 at 2:37

You're right. But if that wasn't obvious to you, then a more interesting question is: why are you right? Can you prove it from the definition of continuity?

-
Was it addressed to me then? – p.s Nov 4 '12 at 0:35
$f$ is constant function thus it is continuous. We ll show that g is discontinuous on R if we show that it is discont.at one point of R: it is easy to see it's discontinuity at $\sqrt2$ if we consider $\epsilon=1/2$ neighborhood of it,then $(1/2,3/2)$ doesnt contain $0$,which is image of $g$ at all other points of R,so there is no $\delta$ neighborhood of $\sqrt2$ which could be mapped to above considered $\epsilon$ neighborhood. – p.s Nov 4 '12 at 0:56
Yup. Continuity is a topological property, so there's also a topological definition of continuity based on open sets that is equivalent to the $\delta$-$\epsilon$ definition you use, but applies to non-metrizable spaces. Basically: for $f:X\rightarrow Y$, $U\subseteq Y$ is open $\Rightarrow f^{-1}(U)$ is open. – Mike Nov 4 '12 at 1:12

This answer is unsalvageable wrong, I leave it so others could learn from my mistakes

Given $f : \mathbb Q \to \mathbb R$ we can extend it to a continuous function $\bar f : \mathbb R \to \mathbb R$ in the following way:

For every irrational $x$ having Cauchy sequence $(x_a)$ define $$\bar f(x) = (f(x_a)),$$ by continuity this is a Cauchy sequence hence a well defined real number. this is wrong you can not extend a continuous function $\mathbb Q \to \mathbb R$ to a continuous function $\mathbb R \to \mathbb R$, there is a counterexample above

In general metric spaces let $f : V \to X$ be a continuous function and $U$ a dense subset of $V$, then $f$ is defined by its restriction $f|_U : U \to X$. [For proof use the sequential definition of continuity]

That tells us that $\bar f$ is the unique continuous extension of $f$, so if $g : \mathbb R \setminus \mathbb Q \to \mathbb R$ is any function then the extension $$f_g(x) = \begin{cases} f(x), & x \in \mathbb Q \\ g(x), & x \not\in \mathbb Q \end{cases}$$ is discontinuous at $x \in \mathbb Q$ if there's a sequence $x_n \to x$ such that $g(x_n) \not \to f(x)$.

For example if we take $g(x) = \bar f(x) + 1$ then $f_g$ is discontinuous everywhere. If we take $g(x) = \bar f(x) + x$ then $f_g$ is discontinuous everywhere except $0$.

-