Take the 2-minute tour ×

Akhil showed that the Cardinality of set of real continuous functions is the same as the continuum, using as a step the observation that continuous functions that agree at rational points must agree everywhere, since the rationals are dense in the reals.

This isn't an obvious step, so why is it true?

share|improve this question
I think this is a perfect example of the type of question we will encounter that is not a homework question for the asker, but is, in the exact form asked, a standard question in a beginning undergraduate class that someone else could easily use to do their homework for them. This is inevitable, and it doesn't mean we shouldn't ask and encourage questions in standard undergrad math, but we need to build intuition and consensus for how to deal. –  Jamie Banks Jul 22 '10 at 19:03
BTW, I generally like the question to be present in the body, even if it's already in the title. Perhaps it's just an idiosyncrasy (look at the title on the question page, then click on it and read only the body), but I've seen others with the same idiosyncrasy on e.g. mailing lists. :-) –  ShreevatsaR Aug 3 '10 at 18:19
@Katie: The question could easily be asked as an undergraduate excercise, but the question provides enough context to show that it wasn't. Evidence of motivation is crucial, I think, in these cases. @ShreevatsaR: there's now a more-or-less equivalent question in the body. But, dammit, mailing lists are different! And I like to keep my questions DRY. –  Charles Stewart Aug 9 '10 at 13:29
This seems exactly like :math.stackexchange.com/questions/38069/… –  gary Jul 27 '11 at 18:17
@gary: That would be why that question to which you linked was closed as a duplicate of this one. –  Isaac Jul 27 '11 at 20:52

4 Answers 4

up vote 35 down vote accepted

Without resorting to ε-δ arguments: Let $f$ and $g$ be continuous real functions and $f(x) = g(x)$ for all rational $x$. For any real number $c$ (in particular, an irrational $c$), there exists a Cauchy sequence of rational numbers such that $\lim_{n \to \infty}x_{n}=c$. Since $f$ and $g$ are continuous, $\lim_{n \to \infty}f({x_{n}})=f({c})$ and $\lim_{n \to \infty}g({x_{n}})=g({c})$. Since $x_n$ is rational, $f(x_n) = g(x_n)$ for all $n$, so the two limits must be equal and so $f(c) = g(c)$ for all real $c$.

share|improve this answer
Please fix the 'Extra open brace or missing close brace'. –  kennytm Aug 3 '10 at 17:45
@KennyTM: Done, thanks. –  Isaac Aug 3 '10 at 18:01

And one more proof, using the topological notion of continuity: Suppose for contradiction that there exists some $x$ with $f(x)-g(x) = k \neq 0$. Since $f$ and $g$ are continuous, $f-g$ is continuous, so we must have that $f(x) - g(x) \neq 0$ on a non-empty open set $S$ since the inverse image of the open interval $(3k/2, k/2)$ must be open. But since the rationals are dense in the reals, $S$ must contain a rational number $y$, with $f(y) \neq g(y)$, a contradiction.

share|improve this answer
More generally, this proves that a continuous function from a topological space $X$ into a Hausdorff space $Y$ is completely determined by its values on a dense subset of $X$. –  Amitesh Datta Jun 4 '11 at 11:06
But, shouldn't 'more generally' include an argument that does not involve numbers nor intervals? Would the argument above work for, e.g., a map into a non-metrizable Hausdorff space(e.g., non-1st-countable) ? Maybe one would need Y to be metric/metrizable. –  gary Jul 27 '11 at 18:20
@gary: You are right that the argument given above does not work for general Hausdorff spaces, but the statement remains true nevertheless. Any proof will be along the following lines: Let $A\subset X$ be dense, $f, g: X \to Y$ continuous with $f|_A = g|_A$, and $Y$ Hausdorff. $Y$ is Hausdorff iff the diagonal $\Delta\subset Y \times Y$ is closed. Now $f\times g: X \to Y\times Y$ is continuous, hence $ B = (f\times g)^{-1}(\Delta) \subset X $ is closed containing $A$. But then $X = \overline A \subset \overline B = B$. Therefore for all $x \in X$: $(f(x),g(x)) \in \Delta$ or $f(x) = g(x)$. –  Sam Jul 27 '11 at 22:21

If there were two continuous functions $f(x)$ and $g(x)$ that were equal at all rationals, then (because the rationals are dense) we can show that $\lim_{x \to a} f(x) - g(x) = 0$ for all values of $a$ using a delta-epsilon proof.

Since the difference of two continuous functions is continuous, we know $\lim_{x \to a} f(x) - g(x) = f(a) - g(a)$ for all $a$, and therefore $f(a) - g(a) = 0$ and $f(x) = g(x)$, proving that $f$ and $g$ must be identical.

share|improve this answer
Indeed I did. Thanks for catching that! –  Ben Alpert Jul 22 '10 at 17:04

Sketch of an alternative proof.

First, recall (or see for the first time) the following fact:

Given a continuous function $h: \mathbb{R} \rightarrow \mathbb{R}$, the set $K_h := \{x \in \mathbb{R}: h(x) = 0\}$ is closed.

"Recalling" this fact might seem just like sweeping details under the rug; indeed, it is Exercise $4.3.7$ in Stephen Abbott's introductory textbook Understanding Analysis.

Nevertheless, one can then proceed as follows:

Let $f, g: \mathbb{R} \rightarrow \mathbb{R}$ be continuous, real-valued functions that agree on $\mathbb{Q}$.

Furthermore, let $h = f - g$. Then $h$ is the difference of continuous functions, hence continuous itself; we can now use the fact above to conclude that $\mathbb{Q} \subset K_h \subset \mathbb{R}$.

In particular, $K_h$ is a closed set of real numbers that contains $\mathbb{Q}$.

We are given that the rationals are dense in the reals, i.e., $cl(\mathbb{Q}) = \mathbb{R}$.

Therefore, $K_h = \mathbb{R}$, which means that for all $x \in \mathbb{R}$, we have $h(x) = 0$.

By the definition of $h$, this means for all $x \in \mathbb{R}$ we have $f(x) - g(x) = 0$, i.e., $f(x) = g(x)$.

This "proves" the desired result. QED

N.B. The problem posed here is also in Abbott's text: it is Exercise $4.3.8(b)$.

share|improve this answer

Your Answer


