Show that there exists a metric $d$ on $\mathbb{R}$ such that $(\mathbb{R},d)$ is compact 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.
 A: There exists a  bijection $f: \mathbb R \to [0,1]$. Define $d(x,y)=|f(x)-f(y)|$. This makes $\mathbb R$ compact.
A: Compactness or lack thereof is an inherent property of a topology, and the usual topology on $\Bbb R$ is not compact, so your metric will have to generate a topology different from the usual one. One fairly elegant way is to bend $\Bbb R$ into a figure eight by making $0$ the limit of all unbounded monotonic sequences in $\Bbb R$. In effect this is wrapping the ends of the real line around as if they had $0$ as an endpoint. The line keeps its original topology everywhere except at $0$; a basic open nbhd of $0$ has the form $(\leftarrow,-n)\cup\left(-\frac1n,\frac1n\right)\cup(n,\to)$ for $n\in\Bbb Z^+$.
There are many ways to accomplish this; one is to define
$$h:\Bbb R\to\Bbb R^2:x\mapsto\left\langle\frac{2x}{1+x^2},2\tan^{-1}x\right\rangle\;,$$
where I’m using polar coordinates in $\Bbb R^2$; note that if $\theta=2\tan^{-1}x$, then $\frac{2x}{1+x^2}=\sin\theta$. The non-negative positive reals map to a circle in the upper half-plane tangent to the $x$-axis at the origin, and the non-positive reals map to its reflection in the $x$-axis, so $h[\Bbb R]$ is a compact subset of the plane. For your metric you can simply use any of the usual metrics in the plane.
