1. ## continuous function

suppose that the function g:R->R is continuous and that g(x)=0 if x is rational. Prove that g(x)=0 for all x in R.

-- I am totally stuck on this one.

2. Originally Posted by chutiya
suppose that the function g:R->R is continuous and that g(x)=0 if x is rational. Prove that g(x)=0 for all x in R.

-- I am totally stuck on this one.
Since you have $g(x)=0$ when $x \in Q$, suppose that $x \in R-Q$. You should know that the rationals are dense in $R$, so there is a rational $x_n \in \left( x-\frac{1}{n}, x+\frac{1}{n}\right)$. so..

Can you try to complete?

3. Originally Posted by harish21
Since you have $g(x)=0$ when $x \in Q$, suppose that $x \in R-Q$. You should know that the rationals are dense in $R$, so there is a rational $x_n \in \left( x-\frac{1}{n}, x+\frac{1}{n}\right)$. so..

Can you try to complete?
Do I have to take the limit? I still cannot figure out. Thanks for your help

4. Originally Posted by chutiya
Do I have to take the limit? I still cannot figure out. Thanks for your help
$\lim_{n \to \infty} {x_n} = x$ since $|x-{x_n}| < \frac{1}{n}$.

By continuity $f(x) = \lim_{n \to \infty}f(x_n)= \lim_{n \to \infty}0 = 0$

5. Originally Posted by chutiya
suppose that the function g:R->R is continuous and that g(x)=0 if x is rational. Prove that g(x)=0 for all x in R.

-- I am totally stuck on this one.
Originally Posted by harish21
$\lim_{n \to \infty} {x_n} = x$ since $|x-{x_n}| < \frac{1}{n}$.

By continuity $f(x) = \lim_{n \to \infty}f(x_n)= \lim_{n \to \infty}0 = 0$
Maybe even more simply. We have by the continuity of $g$ that $g^{-1}(\{0\})$ is closed. Thus, $\mathbb{R}\supseteq g^{-1}(\{0\})=\overline{g^{-1}(\{0\})}\supseteq\overline{\mathbb{Q}}=\mathbb{R }$ so that $g^{-1}(\{0\})=\mathbb{R}$

6. For a beginner here is a different proof.
If a continuous function is not zero at a point then there is an open interval containing the point on which the function has the same sign (either positive or negative throughout the interval). But every interval contains a rational number.
So this function has to be zero everywhere.