Is f(x)=|x| injective (or one-to-one), surjective (onto) for range & domain Z→Z

discrete mathematicsfunctions

The premise is as following:

"f: Z→Z, f(x)=|x|. Is the function surjective, injective or bijective?".

My (simplified) understanding of a injective function is that every value for X has to map to a unique value on Y. With this definition in mind, the function would not be considered injective since (for example) f(-4)⟺f(4) in this scenario. Is this correct?

Regarding wether the function is surjective my (again, simplified) understanding of surjective functions tells me that every Y value within the allowed range has to be mapped to at least one X value within the allowed domain. Considering the functions domain and range, this would be true as every Y-value within has at least one X-value mapped to it (since there is no limit to the domain or range), hence f(x) is surjective. However, just googling around I've found multiple posts that say f(x)=|x| is not surjective. As such I am unsure on what to write it down as and I'm asking for clarification because I feel as if I've missed something.

Edit: Additionally, from what I've read, all surjective functions must have an inverse, but f(x)=|x| does not have an inverse (to my knowledge). Is it even a function then considering its not injective or surjective?

Changed the range and domain to the correct set. Sorry for the misstype!

Best Answer

Renaming functions:

Let $f~:~\Bbb N\to\Bbb N,~f(x)=|x|$

Let $g~:~\Bbb Z\to\Bbb N,~g(x)=|x|$

Let $h~:~\Bbb N\to\Bbb Z,~h(x)=|x|$

Let $\ell~:~\Bbb Z\to\Bbb Z,~\ell(x)=|x|$

Note that all of these functions are very similar. They all map an input $x$ to an output $|x|$. These are indeed all considered functions. Their domains may be different however, and their codomains may be different as well.

Those with domain $\Bbb N$, $f$ and $h$, will be injective. It is clear that if $0<x_1<x_2$ that $|x_1|=x_1$ and $|x_2|=x_2$ and so $|x_1|<|x_2|$ implying that so long as $x_1\neq x_2$ we have $f(x_1)\neq f(x_2)$ and similar for $h$, and so they are injective.

Those with domain $\Bbb Z$, $g$ and $\ell$, will not be injective. Your example was a good one. $g(-4)=g(4)$ despite $-4\neq 4$.

Those with codomain $\Bbb N$ will be surjective. Given a value $y$ from the codomain of $\Bbb N$, it follows that $y$ is also an element of the domain and that $f(y)=|y|$ will equal $y$ since the absolute value of a non-negative real is equal to itself. Since every value in the codomain has an element from the domain who can map to it (that element being itself) surjectivity follows.

Those with codomain $\Bbb Z$ will not be surjective. Since absolute value is always going to give a non-negative result, there is no value which will map to a negative result. As a specific example, nothing will ever map to $-2$.

So again, $f$ is injective and surjective (thus bijective), $g$ is surjective but not injective, $h$ is injective but not surjective, and $\ell$ is neither injective nor surjective.


"All surjective functions have an inverse... but what is the inverse of $|x|$?"

All bijective functions have an inverse function. Surjective functions you can define an inverse relation but not necessarily an inverse function. In such an event it might be ambiguous which among several values to pick for the inverse to map to. For instance, with $g$, what should be the "inverse of $4$?" The question is, what value(s) from the domain map to $4$? The answer would be that both $4$ and $-4$ mapped to $4$. Usually we prefer just a single result.

"What is the inverse of $|x|$?" For $f$, it might help to recognize that instead of writing it as $f(x)=|x|$ we could have achieved the same effect as $f(x)=x$. The punchline is that in this specific instance, $f$ is it's own inverse... and both are what are known as the "identity function."