Your function is not correct. It needs to be That is 1-1 and onto (i.e., a bijection).
To show this is 1-1, look at the definition of 1-1. A function is 1-1 if and only if for every such that it follows that Or, equivalently, implies So, assume and Can you prove that ?
For onto, you have to show that the function "hits" every value in the range. That is, for every there exists such that So, pick a Now show that you can find an such that
Can you finish from here?