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

I noticed the following statement on a comprehensive exam, and I am having trouble proving it. Can anyone help?

If $X$ is a non-compact metric space, then there exists a continuous function $f: X \rightarrow \mathbb{R}$ such that $f(X)$ is dense in $\mathbb{R}$.

Thanks in advance!

share|cite|improve this question
This seems not true because $f:\mathbb{N}\longrightarrow \mathbb{R}$ can not have $F(\mathbb{N})$ dense in $\mathbb{R}$. Notice that $\mathbb{N}$ is not compact with the topology induced by usual metric. – user29999 Sep 3 '12 at 15:36
@user29999 Fix an enumeration of the rationals $r_n$ define a map $f: \mathbb N \rightarrow \mathbb R$ by $f(n)=r_n$. Since $\mathbb N$ has the discrete topology any map with it as the domain is continuous. Thereby $f$ is a continuous map with dense image. This is also a step in Nate's hint. – JSchlather Sep 3 '12 at 15:43
up vote 5 down vote accepted

Hint: If $X$ is not compact, it contains an infinite set $E$ with no limit point. Try defining $f : E \to \mathbb{R}$ so that $f(E)$ is dense. Then show that you can extend $f$ continuously to $X$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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