# Question about one-to-one and onto with functions

1. Feb 18, 2006

### kingerd

the following is a problem in the book.

$$f(x)=\left\{\begin{array}{cc}\frac{1}{2}(x+1),&\mbox{ if x is odd} \\\frac{1}{2}x, & \mbox{ if x is even}\end{array}\right$$

the solutions that's given is This function is onto because, for any $$y\epsilonZ, g(2y)=y.$$ It is not one-to-one because g(1) = g(2).

I understand where the numbers come from stating why it's not one-to-one, but i'm a little confused about the onto part, in that they got the 2

Last edited: Feb 18, 2006
2. Feb 18, 2006

### arildno

This is an integers-to-integers function.
Now, given any integer y, does there exist an integer x so that g(x)=y?
The number 2y is certainly an integer, it can qualify as an x, and g(2y) is indeed equal to y.
Thus, you have shown that g is onto.

3. Feb 18, 2006

### kingerd

so the fact that they use 2y is irrelevant just so long as g(x)=y

4. Feb 18, 2006

### HallsofIvy

Staff Emeritus
For any y, there exist x so that g(x)= y.

I wouldn't say the 2y was "irrelevant", a good way to show such and x exists is to tell how to find it!! (And your original post had f(x), not g(x).)

What they are really doing is this:
Given such a y, how would you find the corresponding x?
If f(x)= y then either $\frac{1}{2}x= y$ in which case x= 2y (and is even) or $\frac{1}{2}(x+1)= y$ in which case x+ 1= 2y and x is odd. That shows that not only is there such an x, there are 2! Which is why it is not "one to one".

Here's another example: show that g(x), from R to R, defined by g(x)= x is x<= 1,
g(x)= 2x-1 if x> 1, is both one-to-one and onto.
To show that it is one to one, assume that g(x1[/sup])= g(x2). Because of the way the function is defined we would really need to consider 4 possibilities:
If x1, x2 are both less than or equal to 1, then we must have g(x1)= x1[/sup]= g(x2)= x2 so x1= x2- that was easy!
If x1, x2 are both greater than 1, then we must have g(x1)= 2x1-1= g(x2= 2x1-1 and again get x1= x2
The third possibility is x1[/sup] less than or equal to 1, x2> 1 so that g(x1)= x1= g(x2)= 2x2- 1. But if x2> 1 then 2x2> 2 so x1= 2x2-1> 1, a contradiction- that can't happen.
The fourth possibility is that x1> 1 while x2 is less than or equal to 1. Just reverse x1 and x2in the above to see that that can't happen.
If g(x1)= g(x2) then x1= x2 so g is one-to-one.

To see that g is "onto", assume that y is any real number and find x so that g(x)= y.
There are now two possiblities. If y is less than or equal to 1 then obviously, x= y works. If y> 1, does there exist x> 1 so that 2x-1= y?
Solving for x, we get x= (y+1)/2. But is that >1? Yes, if y> 1 then y+1> 2 and so (y+1)/2> 1.

Last edited: Feb 18, 2006