Define a function $f:\Bbb Z \to \Bbb Z$ by \begin{equation*} f(x) = \begin{cases} x, & \text{if $x$ is even}\\ x+1, & \text{if $x$ is odd} \end{cases} \end{equation*} for all $x \in \Bbb Z$. Find a right inverse of $f$ if it exists.

Attempt: $f$ has a right inverse iff $f$ is surjective, so we must check that $f$ is whether surjective or not. Let $y=f(x)$. Then, \begin{equation*} x = \begin{cases} y, & \text{if $y$ is even}\\ y-1, & \text{if $y$ is odd} \end{cases} \end{equation*} for all $x,y \in \Bbb Z$. Now, consider \begin{align*} f(x) &= \begin{cases} f(y), & \text{if $y$ is even}\\ f(y-1), & \text{if $y$ is odd} \end{cases}\\ &= \begin{cases} y, & \text{if $y$ is even}\\ (y-1)+1,& \text{if $y$ is odd} \end{cases} \end{align*} Hence, we see that $f(x) = y$ for all $x \in \Bbb Z$. Thus, $f$ is surjective and therefore, $f$ has a right inverse.

Am I true?

  • 1
    $\begingroup$ The image is of $f$ is only even numbers, so $f$ is not surjective $\endgroup$ Jan 4, 2021 at 16:55
  • $\begingroup$ Oh, I see. The odd numbers doesn't have preimage in $\Bbb Z$, right? $\endgroup$
    – lap lapan
    Jan 4, 2021 at 16:56
  • $\begingroup$ Right, the odd numbers don't have pre-images in $\Bbb Z$; by the way, your function is not injective either, because $f(1)=f(2)$ but $1\ne2$ $\endgroup$ Jan 4, 2021 at 16:57

1 Answer 1


No; the image of $f:\Bbb Z\to\Bbb Z$ as you have defined it consists of only even numbers --

$y=f(x)$ is always even --

so $f$ is not surjective -- odd numbers do not have pre-images in $\Bbb Z$ --

so $f$ does not have a right inverse.

By the way, $f$ is not injective either, because $f(1)=f(2)$, but $1\ne2$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .