Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Prove that the following function is invertible: $$g:\mathbb{Z}\rightarrow\mathbb{N}$$

$$ g(x) = \left\{ \begin{array}{lr} -2x & : x\le0\\ 2x-1 & : x>0 \end{array} \right. $$

I'm having an issue proving that it is one-to-one in all cases. The cases where $x_{1},x_{2}\le0$ and $x_{1},x_{2}>0$ both pass proof by contrapostitive where $g(x_{1})=g(x_{2})$. I'm having a problem proving it is also one-to one if $x_{1}\le0$ but $x_{2}>0$ which would result in:

$$ -2x_{1}=2x_{2}-1 $$ $$ x_{1}=-x_{2}+\frac{1}{2} $$

I know I'm going something wrong in my thinking and I have a sneaking suspicion it has something to do with the fact that I'm mapping to $\mathbb{N}$, but I'm completely unsure of where to go from here.

share|improve this question
Are you sure that $g:\mathbb{R} \rightarrow \mathbb{N}$? Because if $x=\sqrt{2}$, then surely $g(x)$ is not a natural number. –  user39280 Oct 20 '12 at 18:19
Sorry, it's actually $\mathbb{Z}\rightarrow\mathbb{N}$. Let me edit my question. –  kamikazekent Oct 20 '12 at 18:39
add comment

1 Answer 1

up vote 0 down vote accepted

$-2x$ will always give you a nonnegative, even integer, when $x \leq 0$. And, $-2x$ is strictly decreasing. $2x - 1$ will always give a positive, odd integer, when $x > 0$. And, $2x - 1$ is strictly increasing. That's all you need.

share|improve this answer
Thanks, I think that makes sense. Normally I do have to prove that $g(x_{1})=g(x_{2})$, but what you're saying is in the third case I can apply a direct proof showing that it is impossible for an element to map to multiple elements in the co-domain since $x_{1}$ would always be even and $x_{2}$ would always be odd. Am I understanding that correctly? –  kamikazekent Oct 20 '12 at 20:29
@kamikazekent Correct. Injective means that $g(x_1) = g(x_2)$ implies $x_1 = x_2$. Or, equivalently, the contrapositive is $x_1 \neq x_2$ implies $g(x_1) \neq g(x_2)$. So, pick two $x$ values that are both $x \leq 0$. The fact that the function is strictly decreasing implies $g(x_1) \neq g(x_2)$. Similarly if your two $x$ values are both $> 0$. And, if one is nonpositive and one is positive, then $g(x_1)$ is even and $g(x_2)$ is odd, so they're not equal then also. –  Graphth Oct 20 '12 at 20:34
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.