Show that there exists a metric $d$ on $\mathbb{R}$ such that $(\mathbb{R},d)$ is compact

compactnessgeneral-topologymetric-spacesreal-analysis

I've come across this problem here and I've been trying to solve it. I've tried metrics like $d(x,y) = \ln(1+\frac{|x-y|}{1+|x-y|})$ but these end up not working (I believe this one does not give a totally bounded set). My thinking is that if I can get a metric such that $d(x,y)<|x-y|$ then $(\mathbb{R},d)$ should be complete. But for every such metric $d$ I try, it turns out that either $d$ does not satisfy the triangle inequality (hence $d$ is not a metric) or $(\mathbb{R},d)$ is not totally bounded (hence $(\mathbb{R},d)$ is not compact).

My final thinking is that maybe some theorem can used to show existence of such a metric without an explicit construction, but I've not been able to make any progress this way either.

Best Answer

There exists a bijection $f: \mathbb R \to [0,1]$. Define $d(x,y)=|f(x)-f(y)|$. This makes $\mathbb R$ compact.