Unbounded continuous function on non-compact metric space Suppose $(S,d)$ is a non-compact metric space. Is it possible to construct an unbounded continuous function from $S$ to $\mathbb{R}$? If it is possible, please show the construction method :)
Here's my attempt to solve this problem: Because $S$ is not compact, we can find a neighborhood assignment function $N(x)$ so that a finite cover is not possible. Then each time we can find an uncovered point from the union of neighborhoods before, and change the function by $f(x):=max\{f(x),\text{a function which equals to the indice of this point at that point and gradually vanishes at further points from the selected point}\}$. However I'm concerned that while this function is unbounded, there may be some invalid points for this function (goes to infinity)...
EDIT: As I found out there is a duplicate question, however the elementary solution is not presented in that question, so I still wish to know about this problem. :)
 A: A non-compact metric space is not countably compact, so it has a countably infinite, closed, discrete subset $D=\{x_n:n\in\Bbb N\}$. Define $f:D\to\Bbb R:x_n\mapsto n$. $D$ is a closed subset of the normal space $S$, so by the Tietze extension theorem there is a continuous $g:S\to\Bbb R$ such that $g\upharpoonright D=f$; clearly $g$ is unbounded.
Added: It's possible to make this construction more explicit. Because $D$ is closed and discrete, there are real numbers $r_n>0$ for $n\in\Bbb N$ such that the open balls $B(x_n,r_n)$ are pairwise disjoint, and we may further assume that $\lim_nr_n=0$. Because $D$ is closed, each $x\in X$ has an open nbhd that intersects at most one of these open balls. (Verifying this is a nice little exercise.) Now define $f:X\to\Bbb R$ as follows.


*

*If $x\in X\setminus D$, then $f(x)=0$.  

*If $x\in B(x_n,r_n)$, then $f(x)=\frac{n}{r_n}\big(r_n-d(x,x_n)\big)$.


Clearly $f(x_n)=n$ for each $n\in\Bbb N$, and the fact that each point of $X$ has an open nbhd meeting at most one of the open balls $B(x_n,r_n)$ makes it quite easy to show that $f$ is continuous (by showing that it's continuous at each point).
