Mapping the Real Line to the Unit Interval What is a continuous mapping of the real line $(-\infty, \infty)$ to the interval $[0, 1]$? I'm trying out logs and exponentials but they don't seem to work?
 A: I take it you want a continuous surjection from $\mathbb{R}$ to $[0,1]$. A simple example of such a function is $f(x)= \begin{cases} 0 & x<0 \\ x & 0 \le x \le 1 \\ 1 & x>1\end{cases}$
A: $\frac{x+\sqrt{x^2+1}}{2\sqrt{x^2+1}}$ and $\frac{\tanh(x)+1}{2}$ both map $\mathbb{R}$ into $[0,1]$ but not onto. As Phira mentions $\frac{\sin(x)+1}{2}$ maps $\mathbb{R}$ onto $[0,1]$ but is not $1{-}1$. However, you won't find a $1{-}1$ and onto function whose inverse is continuous, since $[0,1]$ is compact and $\mathbb{R}$ is not.
A: $\dfrac{1}{1+e^{-x}}$ is a one-to-one monotonically increasing map from $\mathbb R$ onto the open interval $(0,1)$.
A: $\dfrac{\sin x +1}2$ is a continuous surjective function from the reals to this interval.
A: All you need is a continuous function that maps $\mathbb{R}$ onto a closed interval; once you have that, adjusting the interval is fairly easy. (For instance, you can use a linear function.) The natural starting points are the sine and cosine functions.
A: As the question is formulated, any function that would map all number of the real line to a fixed number of $[0, 1]$ would do. A Lo's (down voted by Julian) answer is also a correct answer, since mapping to $(0,1)$, you map to $[0,1]$.
But what user18723 probably meant, but didn't specify, is to have more than just a continuous function. Perhaps the intent was to have a bijective function? But in that case, it's not possible. A good discussion on this situation can be found here.
A: I'm going to answer another related "what you meant" question. Namely, a (non-continuous) bijection from $[0, 1]$ to $\mathbb{R}$.
Firstly, we can use the Schroder-Berstein theorem to show that a bijection exists, because $[0, 1]$ can be embedded into $\mathbb{R}$ naturally, and $\mathbb{R}$ is bijective with $(\frac{\pi}{2}, \frac{\pi}{2})$ via $tan$, and so bijective to $(0, 1)$ and so $\mathbb{R}$ can be embedded within $[0, 1]$.
However, this theorem does not give us this mapping.

Let's construct the mapping.
Firstly, we can note that all open intervals are homeomorphic. Similarly, all closed intervals are homeomorhpic to one another; as are are call half-closed intervals. Further $\mathbb{R}$ is homeomorphic any open interval.$
Our question can then be reframed in terms of bijections between different types of intervals.
Half-open intervals are useful here for various reasons. A half-open interval can be expressed as a countably infinite (and finite) partition of half-open intervals. For example, $[0, 1) = [0, \frac{1}{2}) \cup [\frac{1}{2}, 1)$ (the infinite case follows because all half open intervals are essential the same)
So how can we convert $\mathbb{R}$ (the same as $(0, 1)$) and $[0, 1]$ into half open intervals? Well, an open intervals can be written as an infinite union of half-open intervals.
$\mathbb{R} = \cup_{x \in \mathbb{Z}}[x, x + 1)$
And a closed interval can be written as the intersection of points and half-open intervals:
$[0, 1] = \{ \frac{1} {2} \} \cup [0, \frac{1}{2} ) \cup (\frac{1}{2}, 1]$
We can also represent half-open intervals in terms of points.
Further $[0, 1) = [0, \frac{1}{2}) \cup \{ \frac{1}{2} \} \cup (\frac{1}{2}, 1)$
So using $=$ to mean bijection, where $O, H, C, P$ mean open, half-open, closed and point, respectively we have:
$O = \mathbb{Z} \times H = O \cup P \cup O $
$H = \mathbb{N} \times H = H \cup  P \cup O $
$C = H \cup P \cup H$ 
We want to show $C = O$, that is $H \cup P \cup H = O \cup P \cup O$.
So, if we can show $H = O$ then we are done. 
But, $O = \mathbb{Z} \times H$ and $H = \mathbb{N} \times H$ meaning it is sufficient to show that $\mathbb{N} = \mathbb{Z}$. The mapping, $2n \to n$, $2n + 1 \to -n$, takes $\mathbb{N}$ to $\mathbb{Z}$ giving us the bijection we need and completing our proof. 
A: A continuous mapping is entirely possible: just one such is
$$f: \mathbb{R} \rightarrow [0, 1],\ f(x) := \frac{\sin(x) + 1}{2}$$
which is just a sine wave translated and compressed to fit its peaks/troughs snugly within $[0, 1]$.
As said by the other posters, however, a bijective continuous mapping is not possible. The most elegant way to understand this is with a little topology. A bijective continuous map, in effect by the very definition of "continuity", preserves all topological properties of a space(*), and that includes things such as compactness: roughly (and to all the extent we need for this specific problem), that a space doesn't have "open ends" like $(0, 1)$, or $(-\infty, \infty)$. $[0, 1]$ is compact. $(-\infty, \infty)$ is not. Thus, no bijective continuous map exists.

(*) As I would have liked to have written to expound upon a rather well-directed (but that seems to not quite be ideal) answer on MathOverflow here:
https://mathoverflow.net/a/19156/11576
regarding the core intuition behind topology, but can't because that question is now closed, topology fundamentally is about spaces where the notion of "approximation" makes sense, and the usual definitions used for topological spaces are a perhaps unhelpfully boiled-down version of this. And as I talk about here:
What is the intuition behind uniform continuity?
continuity is all about approximation.
