Is there a function that maps $\mathbb{R}$ to {$-1,1$}

59 Views Asked by At

I know how to map a set of real numbers $\mathbb{R}$ or integers $\mathbb{Z}$ to an interval, e.g. $[0,1]$, but how would I do it for a set containing two elements? I know such a set would not be injective, though, that's for sure. Suggestions?

2

There are 2 best solutions below

9
On BEST ANSWER

It depends what you want this function to do. The constant functions $x\mapsto -1$ or $x\mapsto 1$ do the job. Or maybe you want a surjection? Then how about $x\mapsto 1$ if $x\ge 0$ and $x\mapsto -1$ otherwise; or $x\mapsto 1$ if $x\not=17$, and $17\mapsto -1$; or so on.

0
On

Choose some subset $A\subset\mathbb{R}$. Then $$ f(x)=\left\{\begin{array}{ll}1&x\in A\\ -1&x\in\mathbb{R}\setminus A\end{array}\right. $$ is such a function (and every other function $g:\mathbb{R}\to\{-1,1\}$ is of this form).