Example 4, Sec. 29, in Munkres' TOPOLOGY, 2nd ed: How is the one-point compactification of the real line homeomorphic with the circle?
Here is Theorem 29.1 in the book Topology by James R. Munkres, 2nd edition:
Let $X$ be a [topological] space. Then $X$ is locally compact Hausdorff if and only if there exists a [topological] space $Y$ satisfying the following conditions:
(1) $X$ is a subspace of $Y$.
(2) The set $Y - X$ consists of a single point.
(3) $Y$ is a compact Hausdorff space.
If $Y$ and $Y^\prime$ are two [topological] spaces satisfying these conditions, then there is a homeomorphism of $Y$ with $Y^\prime$ that equals the identity map on $X$.
Following the proof of this theorem, Munkres gives this definition:
If $Y$ is a compact Hausdorff space and $X$ is a proper subspace of $Y$ whose closure equals $Y$, then $Y$ is said to be a compactification of $X$. If $Y - X$ equals a single point, then $Y$ is called the one-point compactification of $X$.
Thus from Theorem 29.1 we can conclude the following:
If $X$ is a topological space that is locally compact and Hausdorff but not compact, then $X$ has a one-point-compactification, and conversely.
Now here is Example 4, Sec. 29, in Munkres' Topology:
The one-point compactification of the real line $\mathbb{R}$ is homeomorphic with the circle, . . . [How to prove this?] Similarly, the one-point compactification of $\mathbb{R}^2$ is homeomorphic to the sphere $S^2$. [How to prove this?]
The real line $\mathbb{R}$ is the set of real numbers with the standard (or usual) topology having as a basis all the open intervals of the form $(a, b)$, where $a, b \in \mathbb{R}$ and $a < b$.
How to proceed from these facts and show explicitly and rigorously that the one-point compactification of $\mathbb{R}$ is homeomorphic with the (unit) circle $S^1$ and that the one-point compactification of the plane $\mathbb{R}^2$ is homeomorphic with the (unit) sphere $S^2$?
PS:
The map $f \colon \mathbb{R} \longrightarrow (-1, 1)$, $$ r \mapsto \frac{ r }{ \sqrt{1 + r^2} } $$ is a homeomorphism. The derivative $f^\prime$ of $f$ is given by $$ f^\prime(r) = \frac{1}{ (1+ r^2) \sqrt{ 1+r^2 } } > 0$$ for all $r \in \mathbb{R}$ so that $f$ is strictly increasing. Of course, $f$ is continuous. Moreover, $$ \lim_{r \to +\infty} f(r) = +1, \ \mbox{ and } \ \lim_{r \to -\infty} f(r) = -1. $$ Thus we indeed have $$ f(\mathbb{R}) = (-1, 1). $$
The inverse $f^{-1} \colon (-1, 1) \longrightarrow \mathbb{R}$ is given by $$ f^{-1}(s) = \frac{s^2}{1-s^2}, $$ which is also continuous. Thus $f$ is a homeomorphism of $\mathbb{R}$ with $(-1, 1)$.
And, let $g \colon (-1, 1) \longrightarrow S^1 \setminus \{ (-1, 0 ) \}$ be the mapping $$ t \mapsto \left( \cos \pi t \ , \ \sin \pi t \right). $$ Then $g$ is a homeomorphism of $(-1, 1)$ with $S^1 \setminus \{ (-1, 0) \}$, which in turn is dense in $S^1$.
Thus the map $g \circ f \colon \mathbb{R} \longrightarrow S^1\setminus \{ (-1, 0) \}$ is a homeomorphism of $\mathbb{R}$ with $S^1 \setminus \{ (-1, 0) \}$, which is dense in the compact Hausdorff space $S^1$.
Therefore the one-point compactification of $\mathbb{R}$ is $S^1$.
Is my reasoning correct?
Consider the map$$\begin{array}{rccc}s\colon&\mathbb R&\longrightarrow&S^1\\&x&\mapsto&\left(\dfrac{1-x^2}{1+x^2},\dfrac{2x}{1+x^2}\right).\end{array}$$Then $s$ is a homeomorphism between $\mathbb R$ and $S^1\setminus\bigl\{(-1,0)\bigr\}$. So, since $S^1\setminus\bigl\{(-1,0)\bigr\}$ is dense in $S^1$ and $S^1\setminus\left(S^1\setminus\bigl\{(-1,0)\bigr\}\right)$ consists of a single point, $S^1$ is the one-point compactification of $\mathbb R$. More generally, if $\theta\in\mathbb R$, then$$\begin{array}{rccc}s_\theta\colon&\mathbb R&\longrightarrow&S^1\\&x&\mapsto&\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}.\left(\dfrac{1-x^2}{1+x^2},\dfrac{2x}{1+x^2}\right)\end{array}$$is a homeomorphism between $\mathbb R$ and $S^1\setminus\bigl\{(-\cos\theta,-\sin\theta)\bigr\}$.
A similar argument applies to $\mathbb R^2$ and $S^2$. Just consider the map:$$\begin{array}{rccc}\psi\colon&\mathbb R^2&\longrightarrow&S^2\\&(x,y,z)&\mapsto&\left(\frac{2x}{x^2+y^2+1},\frac{2y}{x^2+y^2+1},\frac{x^2+y^2-1}{x^2+y^2+1}\right).\end{array}$$It is a homeomorphism between $\mathbb R^2$ and $S^2\setminus\{(0,0,1)\}$.