Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Can there be two distinct, continuous functions that are equal at all rationals?

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} $

share|cite|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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
up vote 2 down vote accepted

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)$.

share|cite|improve this answer

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)$.

share|cite|improve this answer

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


share|cite|improve this answer

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