# Prove $f(x) = 0$ for all rational numbers implies $f(x)=0$ for all reals.

Let $F:\mathbb{R}\to\mathbb{R}$ be a continuous function such that $F(x)=0$, $\forall x\in \mathbb{Q}$.

Show that $F(x)=0$, $\forall x\in \mathbb{R}$.

I said: Let $k\in \mathbb{Q}$, $\varepsilon,\delta\in\mathbb{R}\setminus \mathbb{Q}$ such that $k-\varepsilon\le k \le k+\delta$ Since $F(k)=0$, then $F(k-\varepsilon)>0$, $F(k+\delta)<0$ (or $F(k-\varepsilon)<0$, $F(k+δ)>0$).

Then, I thought that before $k-\varepsilon$ there's another rational number and between them is another. If it's a rational, then there's another irrational between the two quotients etc. etc. and my mind explodes. Any hints?

From density of rationals in $\Bbb{R}$ we have that:

If $x \in \Bbb{R}$ then exists $q_n \in \Bbb{Q}$ such that $q_n \to x$.

Thus $$0=f(q_n) \to f(x)$$ from continuity.

From uniqueness of limit we have that $f(x)=0$

Thus $f(x)=0,\forall x\in \Bbb{R}$.

Let $x\in \mathbb{R}$. Fix an $\epsilon>0$, we can find a $\delta>0$ with $$|f(x)-f(y)|<\epsilon$$ for any $y$ with $|y-x|<\delta$. But density insures we can find a $q$ rational with $|x-q|<\delta$. Then we have $$|f(x)-f(q)|=|f(x)|<\epsilon$$ and so $f(x)=0$ on the reals as well.

Suppose $f(x)\ne0$ for some $x$; then either $f(x)>0$ or $f(x)<0$.

Let's do the case $f(x)>0$; by continuity there exists $\delta>0$ such that, for $|y-x|<\delta$, $$|f(y)-f(x)|<f(x)/2$$ (taking $\varepsilon=f(x)/2$ in the definition of continuity).

Can you see a contradiction? Hint: there's a rational number $y$ such that $x-\delta<y<x+\delta$.

Can you do the case $f(x)<0$?

Recall that $F:\mathbb{R}\to\mathbb{R}$ is continuous if for every sequence $(x_n)$ converges to $x,$ then the sequence $(f(x_n))$ will converge to $f(x).$

Fix $x\in\mathbb{R}\setminus\mathbb{Q}.$ Let $(x_n)$ be a sequence of rational numbers which converges to $x$ (the sequence $(x_n)$ can be obtained by taking $x_n$ to be truncated digit of $x$ up to $n$th digit. For example, if $x=\sqrt{2},$ then $x_1=1.4, x_2=1.41,x_3=1.414,$etc.)

By assumption, $f(x_n)=0$ for all natural number $n.$ By continuity of $f,$ we must have $f(x)=0.$

Since $x$ is arbitrary, therefore $f(x)=0$ for all real number $x.$

If $F(i) > 0$ for some irrational $i$ then, by continuity, there will be some neighbourhood of $i$, say $(i-\alpha,i+\alpha)$ in which $F(x)>0$ for every $x \in (i-\alpha,i+\alpha)$, but, every neighbourhood of $i$ contains rationals. Same if $F(i) < 0$.

Left to show:

$F(a) = 0$, $a \in \mathbb{R}$ \ $\mathbb{Q}.$

$\mathbb{Q}$ is dense in $\mathbb{R}:$

There exists sequence $x_n \in \mathbb{Q}$ with

$\lim_{n \rightarrow \infty} x_n =a.$

Since $F$ is continuous at $a$ this implies:

$\lim_{n \rightarrow \infty} F(x_n) =F(a).$

For $\epsilon\gt 0$ there exists a $n_0$ , such that for $n \ge n_0$, we have:

$|F(x_n) - F(a)| \lt \epsilon$,

and with $F(x_n)=0$:

$|F(a)| \lt \epsilon.$

Since $\epsilon$ can be chosen arbitrarily, this implies

$F(a) =0.$