# f, g continuous for all rationals follow by continuous on all reals? [duplicate]

Let $f, g:\Bbb{R}\to\Bbb{R}$ to be continuous functions such that $f(x)=g(x)\text{ for all rational numbers}\,x\in\Bbb{Q}$. Does it follow that $f(x)=g(x)$ for all real numbers $x$?

Here is what I think: f continuous when $\lim\limits_{x\to x_0}f(x)=f(x_0)$ and $\lim\limits_{x\to x_0}g(x)=g(x_0)$

So it does not neccesarily mean that $f(x)=g(x)$ when x is irrational. So I can pick a function f so that

$f(x) = \begin{cases} g(x) & \text{if$x\in\Bbb{Q}$} \\ x & \text{if$x\in\Bbb{R}\setminus \Bbb{Q}$} \\ \end{cases}$

-

## marked as duplicate by Martin Sleziak, martini, Jason DeVito, Thomas, rschwiebNov 8 '12 at 15:27

What you're doing is constructing a function on $\mathbb{R}$ that is continuous at every rational point. why must it be continuous? – ronno Nov 8 '12 at 7:06
because it was given that f, g is continuous? I'm sorry, not quite sure what your question is there – Akaichan Nov 8 '12 at 7:08
@user45593 Continuity can also be thought of as sequentially continuity. It is easier using sequential continuity to see that $f=g$ for all $x$. – user17762 Nov 8 '12 at 7:09
@user45593 Yes. Since every continuous function is sequentially continuous, pick a sequence of rationals $\{x_n \}_{n=1}^{\infty}$ converging to an irrational $x$. Then what can you say about $f(x)$ and $g(x)$? – user17762 Nov 8 '12 at 7:51
– Martin Sleziak Nov 8 '12 at 10:40

Let $h = f-g : \mathbb R \to \mathbb R$. Since $f$ and $g$ are continuous, so is $h$. Now $h^{-1}(0)$ must be closed and $\mathbb Q \subset h^{-1}(0)$.

-

HINT: Assume $f(x_0)\ne g(x_0)$ for some $x_0\in\mathbb R$. Then there is a $\delta>0$ such that $f(x)\ne g(x)$ for all $x\in(x_0-\delta,x_0+\delta)$.

-

Hint: prove that if $\,h\,$ is a real continuous function s.t. $\,h(q)=0\,\,,\,\,\forall\,q\in\Bbb Q\,$ , then $\,h(x)=0\,\,,\,\,\forall\,x\in\Bbb R\,$

Further hint: For any $\,x\in\Bbb R\,$ , let $\,\{q_n\}\subset\Bbb Q\,$ be s.t. $\,q_n\xrightarrow [n\to\infty]{} x\,$ . What happens with

$$\lim_{n\to\infty}f(q_n)\,\,\,?$$

-