Completion of the real numbers On the real line $\mathbb{R}$ endowed with the Euclidean topology, I may put different metrics, inducing the same topology, but inducing different completions. For example if one considers the standard Euclidean distance you get $\mathbb{R}$ itself, if I see $\mathbb{R}$ as $(0,1)$ and I consider the induced metric, then I get $[0,1]$, similarly I can get $S^1$, and similarly I can get $\mathbb{R}_{\geq 0}$.

What are all the possible completions of $\mathbb{R}$ respect to a metric compatible with the Euclidean topology?

 A: Edit: I've written a much simpler version of the proof of the main theorem.
I will show that every completion of $\mathbb{R}$ is obtained by joining $\mathbb{R}$ to a "space at infinity", which the line "converges" to on its ends.  The examples of the topologist's sine curve (together with an interval along the $y$-axis) and a spiral converging to a circle given by MartianInvader are good examples of this phenomenon.
To make this precise, let $X$ be a completion of $\mathbb{R}$, and define the space at infinity to be the complement $X-\mathbb{R}$.  We will prove several facts about this situation.

$\mathbb{R}$ is dense and open in $X$, and the inclusion $\mathbb{R}\to X$ is an embedding.

MartianInvader proved that $\mathbb{R}$ embeds densely.  To show that $\mathbb{R}$ is open, consider an open interval $(a,b)$.  The corresponding closed interval $[a,b]$ is compact and hence closed in $X$, so $[a,b]$ must be the closure of $(a,b)$.  But $\mathbb{R}$ is embedded in $X$, so there exists an open set $U\subset X$ so that $U\cap \mathbb{R} = (a,b)$.  Since $\mathbb{R}$ is dense in $X$, the interval $(a,b)$ must be dense in $U$, from which it follows that $U=(a,b)$.  Thus every open interval in $\mathbb{R}$ is open in $X$, and it follows that $\mathbb{R}$ is open in $X$.
Note that $\mathbb{R}$ being open means that some portion of $X$ really "looks like" $\mathbb{R}$. That is, $X$ really is a line with stuff attached to the ends.

The space at infinity is a complete, separable metric space.

Since $\mathbb{R}$ is open in $X$, the space $X-\mathbb{R}$ at infinity is closed in $X$. Since $X$ is complete, it follows that $X-\mathbb{R}$ is complete.
As for separability, observe that $X$ is separable, since $\mathbb{Q}$ is dense in $X$.  Then $X$ is second countable, so $X-\mathbb{R}$ must be second countable, and hence separable.

So which complete, separable metric spaces are possible?  From the topologist's sine curve and the spiral, it is clear that a closed interval and a circle are possible.
It is not hard to realize the unit square $[0,1]^2$ as the space at infinity.  For example, if $\gamma\colon [0,1]\to[0,1]^2$ is a closed space-filling curve, let $S_\gamma$ be the following subset of $\mathbb{R}^3$.
$$
S_\gamma \;=\; \bigl\{\bigl(x,\gamma(1/x-\lfloor 1/x\rfloor)\bigl) \;\bigl|\; x\in (0,\infty)\bigr\} \cup \bigl(\{0\}\times [0,1]^2\bigr)
$$
The following picture shows a portion of this set in the case where $\gamma$ is the Moore curve.

The set $S_\gamma$ can be thought of as a variant on the topologist's since curve, with $\gamma$ playing the role of the sine function.  Then $S_\gamma$ is closed in $\mathbb{R}^3$ and hence complete, and has a closed square as its space at infinity.
A similar construction shows that any metric space $X$ that is a continuous image of the unit interval $[0,1]$ can be the space at infinity, which by the Hahn-Mazurkiewicz theorem includes all compact, connected, locally connected metric spaces.  However, these are not the only possibilities.  For example, the set
$$
X \;=\; \left\{\left.\left(x,\frac{\sin(1/x)}{x}\right)\right| x\in (0,\infty)\right\} \cup (\{0\}\times \mathbb{R})
$$
is a completion of $\mathbb{R}$ that has another copy of $\mathbb{R}$ as the space at infinity, and $\mathbb{R}$ is not a continuous image of $[0,1]$.
It turns out that any complete, separable metric space can be the space at infinity for a completion of $\mathbb{R}$.  (Edit: The proof of this provided below is completely different from my original version using the Baire space.)  To prove this, we will start with the following Lemma.

Lemma. Any complete, separable metric space can be the space at infinity for a completion of the natural numbers $\mathbb{N}$.

Proof: Let $M$ be a complete, separable metric space, and let $D$ be a countable dense subset of $M$.  Let
$$
p_1,p_2,p_3,\ldots
$$
be a sequence in $M$ that visits each point of $D$ infinitely often, and extend the metric on $M$ to a metric on $\mathbb{N} \cup M$ as follows:


*

*If $n\in\mathbb{N}$ and $q\in M$, then $d(n,q) \;=\; \dfrac{1}{n} + d(p_n,q)$.

*If $m,n\in\mathbb{N}$ and $m\ne n$, then $d(m,n) \;=\; \dfrac{1}{m}+\dfrac{1}{n} + d(p_m,p_n)$.
It is easy to check that this defines a metric on $\mathbb{N}\cup M$. Since the sequence $p_1,p_2,\ldots$ hits each point of $D$ infinitely often, each point of $D$ lies in the closure of $\mathbb{N}$, and hence all of $M$ lies in the closure of $\mathbb{N}$.  Clearly each point in $\mathbb{N}$ is isolated in $\mathbb{N}\cup M$, so the inclusion $\mathbb{N}\to\mathbb{N}\cup M$ is an embedding.  Finally, it is not hard to show that $\mathbb{N}\cup M$ is complete under the given metric.

Theorem. Any complete, separable metric space can be the space at infinity for a completion of $\mathbb{R}$.

Let $M$ be a complete, separable metric space, and let $\mathbb{Z}\cup M$ denote a completion of $\mathbb{Z}$ whose space at infinity is isometric to $M$.  (We proved in the Lemma that $\mathbb{N}$ has such a completion, but $\mathbb{N}$ is homeomorphic to $\mathbb{Z}$.)  We will use $\mathbb{Z}\cup M$ to construct a completion of $\mathbb{R}$ with the same space at infinity.
The construction is simple: for every $n\in\mathbb{Z}$, we will glue in a geodesic segment from $n$ to $n+1$, and the union of these segments will be the desired copy of $\mathbb{R}$.  That is, we extend the metric on $\mathbb{Z}\cup M$ to a metric on $\mathbb{R}\cup M$ in the following way:


*

*If $x,y\in\mathbb{R}$ lie in the same interval $[n,n+1]$, we define
$$
d(x,y) \;=\; \frac{|x-y|}{d(n,n+1)}.
$$

*If $x\in [n,n+1]$ and $p\in M$, we define
$$
d(x,p) \;=\; \min\biggl(d(x,n)+d(n,p),\;d(x,n+1)+d(n+1,p)\biggr).
$$

*Finally, if $x,y\in\mathbb{R}$ lie in two different intervals $[m,m+1]$ and $[n,n+1]$, we define
\begin{align*}
d(x,y) \;=\; \min\biggl(&d(x,m)+d(m,n)+d(n,y), \\
&d(x,m)+d(m,n+1)+d(n+1,y), \\[6pt]
& d(x,m+1)+d(m+1,n) + d(n,y),\\
&d(x,m+1)+d(m+1,n+1)+d(n+1,y)\biggr).
\end{align*}
It's easy to check that this defines a metric on $\mathbb{R}\cup M$, and that the inclusion $\mathbb{R}\to \mathbb{R}\cup M$ is an embedding.  Clearly $\mathbb{R}$ is dense in $\mathbb{R}\cup M$, since every point of $M$ is a limit point of $\mathbb{Z}$.  It is not hard to show that $\mathbb{R}\cup M$ is in fact complete, so $\mathbb{R}\cup M$ is a completion of $\mathbb{R}$ with $M$ as the space at infinity.
A: Any complete metric space with a dense embedding of $\mathbb{R}$.
Here's a sketch of the proof:  Any space that is a completion of $\mathbb{R}^1$ obviously has such an embedding (the inclusion).  And if a metric space $X$ has a dense embedding of $\mathbb{R}^1$, then the induced metric on $\mathbb{R}^1$ must complete to $X$ (some sequence of points in $\mathbb{R}^1$ converge to any point in $X$, and since the topology is induced by the metric this sequence will be Cauchy).
This is a huge class of spaces, and includes:


*

*Open, closed, and half-open intervals

*The circle, the circle with a line segment attached, the figure eight, and two circles joined by a line segment

*Interesting constructs in $\mathbb{R}^2$ like the topologist's sine curve described by Abraham Frei-Pearson or an infinite spiral that approaches a circle (together with the circle)


Basically, if you can start "scribbling" with a pen in some Euclidean space, and scribble forever without crossing back over your path, the closure of the space you end up scribbling in will be a metric completion of $\mathbb{R}$.
