TITLE: Does a injective function need every element of the domain to map onto some element of the codomain?
QUESTION [8 upvotes]: My question is, is it necessary for every element of the domain to map onto some element of the range for a function to be injective? For example, is
$$f(x) = x,\ f:\Bbb R \to \Bbb Z$$
one-to-one/injective, even though there are many elements of the reals that cannot map onto the integers? Obviously for every element that can map onto $\Bbb Z$, it is the only element that corresponds to its output, but I guess I'm wondering if this "overflow" of elements in $\Bbb R$ that don't map onto $\Bbb Z$ matter.
Another example, which is the reason I wanted to know the answer to this question:
$$f(x)= 1/x,\ f:\Bbb R \to \Bbb R \setminus \{0\}$$
So obviously, every element of the domain points to only $1$ element of the range in this function, but does it matter that when $x=0$ the function is undefined? Or does that not effect whether the function is one-to-one or not?

REPLY [0 votes]: No, it is not necessary every element of the domain to map onto some element in the codomain. A function that does not map all elements of its domain is called partial.
The function from you first example ($f(x)=x, f:\mathbb{R}\to\mathbb{Z}$) is partial and bijective. It is partial because there are arguments for which it is undefined ($f(1.5)$ is undefined). It is surjective because for every element $y$ in $\mathbb{Z}$ there is at least one element $x$ in $\mathbb{R}$ such that $f(x)=y$ as $\mathbb{Z}\subsetneq\mathbb{R}$. It is injective because every distinct element in $\mathbb{R}$ is mapped to a distinct element in $\mathbb{Z}$. It is bijective because it is both injective and surjective.
Similarly, the function from your second example ($f(x)=1/x, f:\mathbb{R}\to\mathbb{R}\setminus\{0\}$) is partial ($f(0)$ is undefined) and bijective.
In addition, function $f(x)=1/x, f:\mathbb{R}\setminus\{0\}\to\mathbb{R}\setminus\{0\}$ is total and bijective, while function $f(x)=1/x, f:\mathbb{R}\to\mathbb{R}$ is partial ($f(0)$ is undefined) and non-surjective (there is no $x$ such that $f(x)=0$).
{"set_name": "stack_exchange", "score": 8, "question_id": 1964882}