Proving a function is surjective. f(n) = n/2 for even n, (n+1)/2 for odd n, n an integer

Aion

Junior Member
Joined
May 8, 2018
Messages
204
Problem.

Suppose f:ZZf:\mathbb{Z}\rightarrow\mathbb{Z} given by

f(n)={n2if n is evenn+12if n is oddf(n)=\begin{cases} \frac{n}{2}&\text{if}~n~\text{is even}\\ \frac{n+1}{2}&\text{if}~n~\text{is odd}\end{cases}
Determine if the function is injective or surjective.

My attempt: By evaluating the function we see that each output repeats twice. Hence to show that the function is not injective is simple, since f(0)=0f(0)=0 and f(1)=0f(-1)=0 but 010\neq-1. However, I find it difficult to prove that the function is surjective. The goal is to show that f(Z)=Zf(\mathbb{Z})=\mathbb{Z}.

My first thought was to suppose we partitioned Z=Z1Z2\mathbb{Z}=\mathbb{Z_1}\cup\mathbb{Z_2}. Where Z1\mathbb{Z_1} is the odd integers and Z2\mathbb{Z_2} the even integers. And so Z1=2t+1\mathbb{Z_1}=2t+1 and Z2=2t\mathbb{Z_2}=2t for some integer tt. Then for each case, we have

f(Z1)=f(2t+1)=t+1f(\mathbb{Z_1})=f(2t+1)=t+1 And
f(Z2)=f(2t)=tf(\mathbb{Z_2})=f(2t)=t
Now if tt is even, then t+1t+1 is odd. And if tt is odd, then t+1t+1 is even. Then clearly as tt varies over all integers, so will the f(n)f(n) vary over all integers as well. Hence it must be true that f(Z)=Zf(\mathbb{Z})=\mathbb{Z}.

I know this is not a correct proof, but it was my attempt anyway.
 
Last edited:
Problem.

Suppose f:ZZf:\mathbb{Z}\rightarrow\mathbb{Z} given by

f(n)={n2if n is evenn+12if n is oddf(n)=\begin{cases} \frac{n}{2}&\text{if}~n~\text{is even}\\ \frac{n+1}{2}&\text{if}~n~\text{is odd}\end{cases}
Determine if the function is injective or surjective.

My attempt: By evaluating the function we see that each output repeats twice. Hence to show that the function is not injective is simple, since f(0)=0f(0)=0 and f(1)=0f(-1)=0 but 010\neq-1. However, I find it difficult to prove that the function is surjective. The goal is to show that f(Z)=Zf(\mathbb{Z})=\mathbb{Z}.

My first thought was to suppose we partitioned Z=Z1Z2\mathbb{Z}=\mathbb{Z_1}\cup\mathbb{Z_2}. Where Z1\mathbb{Z_1} is the odd integers and Z2\mathbb{Z_2} the even integers. And so Z1=2t+1\mathbb{Z_1}=2t+1 and Z2=2t\mathbb{Z_2}=2t for some integer tt. Then for each case, we have

f(Z1)=f(2t+1)=t+1f(\mathbb{Z_1})=f(2t+1)=t+1 And
f(Z2)=f(2t)=tf(\mathbb{Z_2})=f(2t)=t
Now if tt is even, then t+1t+1 is odd. And if tt is odd, then t+1t+1 is even. Then clearly as tt varies over all integers, so will the f(n)f(n) vary over all integers as well. Hence it must be true that f(Z)=Zf(\mathbb{Z})=\mathbb{Z}.

I know this is not a correct proof, but it was my attempt anyway.
I would use proof by contradiction.
 
I've read that the formal definition of a subjective function is the following: f:AB,f:A\rightarrow B, is subjective if bBaA:f(a)=b.\forall b\in B \exist a\in A:f(a)=b. Applying this definition in conjunction with your idea to use proof by contradiction, I need to suppose

bZaZ:f(a)b\exist b\in \mathbb{Z}\forall a\in\mathbb{Z} : f(a)\neq b
And somehow derive a contradiction from this.
 
I've read that the formal definition of a subjective function is the following: f:AB,f:A\rightarrow B, is subjective if bBaA:f(a)=b.\forall b\in B \exist a\in A:f(a)=b. Applying this definition in conjunction with your idea to use proof by contradiction, I need to suppose

bZaZ:f(a)b\exist b\in \mathbb{Z}\forall a\in\mathbb{Z} : f(a)\neq b
And somehow derive a contradiction from this.
Given this b you need to prove that such a exists. One way to do it is to provide an expression for it.
 
Given this b you need to prove that such a exists. One way to do it is to provide an expression for it.
Let bb be an arbitrary integer, and suppose f(a)=b.f(a)=b.

Case(1) If aa is even. Then b=f(a)=a/2.b=f(a)=a/2. Hence a=2bZa=2b \in \mathbb{Z}
Case (2) If aa is odd. Then b=f(a)=(a+1)/2b=f(a)=(a+1)/2. Hence a=2b1Za=2b-1 \in \mathbb{Z}

Thus aZ:f(a)=b\exist a \in \mathbb{Z} : f(a)=b. Since bb was an arbitrary integer we conclude that

bZaZ:f(a)=b\forall b \in \mathbb{Z} \exist a \in \mathbb{Z} : f(a)=b
 
Last edited:
Let bb be an arbitrary integer, and suppose f(a)=b.f(a)=b.

Case(1) If aa is even. Then b=f(a)=a/2.b=f(a)=a/2. Hence a=2bZa=2b \in \mathbb{Z}
Case (2) If aa is odd. Then b=f(a)=(a+1)/2b=f(a)=(a+1)/2. Hence a=2b1Za=2b-1 \in \mathbb{Z}

Thus aZ:f(a)=b\exist a \in \mathbb{Z} : f(a)=b. Since bb was an arbitrary integer we conclude that

bZaZ:f(a)=b\forall b \in \mathbb{Z} \exist a \in \mathbb{Z} : f(a)=b
Maybe it's wrong to suppose f(a)=bf(a)=b above. I've tried to remedy this below.

Let bb be an arbitrary integer, and suppose for contradiction that f(a)b.f(a)\neq b.

Case (1) Suppose aa is even. Let a=2ba =2b. Then f(a)=f(2b)=bf(a)=f(2b)=b

Case (2) Suppose aa is odd. Let a=2b1a=2b-1. Then f(a)=f(2b1)=bf(a)=f(2b-1)=b

Hence by contradiction f(a)=bf(a)=b, therefore bZaZ:f(a)=b\forall b \in \mathbb{Z} \exist a \in \mathbb{Z} : f(a)=b
 
Last edited:
Maybe it's wrong to suppose f(a)=bf(a)=b above. I've tried to remedy this below.

Let bb be an arbitrary integer, and suppose for contradiction that f(a)b.f(a)\neq b.

Case (1) Suppose aa is even. Let a=2ba =2b. Then f(a)=f(2b)=bf(a)=f(2b)=b

Case (2) Suppose aa is odd. Let a=2b1a=2b-1. Then f(a)=f(2b1)=bf(a)=f(2b-1)=b

Hence by contradiction f(a)=bf(a)=b, therefore bZaZ:f(a)=b\forall b \in \mathbb{Z} \exist a \in \mathbb{Z} : f(a)=b
This is not quite right. You are given this special b for which supposedly there is no a, such that f(a)=b. Your task is to come up with an expression for a (based on b), such that f(expression)=b, which contradicts the assumption that a does not exist.
 
This seems trivial. n/2 will generate ALL integers when n is even. Done.
Now write it up nicely and post back with your completed proof.
 
This seems trivial. n/2 will generate ALL integers when n is even. Done.
Now write it up nicely and post back with your completed proof.
That was my first thought. Suppose nn is even, then by definition, there exists some kZk\in \mathbb{Z} such that n=2kn=2k. Then f(n)=kf(n)=k for some integer kk. And so f(n)f(n) will generate all integers kk when nn is even.
 
Is not this enough for surjectivity?
Suppose bb be an arbitrary integer. Let a=2ba =2b, then aa is even by definition, hence f(a)=f(2b)=bf(a)=f(2b)=b. Therefore aZf(a)=b\exist a \in \mathbb{Z} \, f(a)=b. And since bb was arbitrary we conclude that bZaZf(a)=b.\forall b\in\mathbb{Z} \,\exist a \in \mathbb{Z} \,f(a)=b.
 
This is not quite right. You are given this special b for which supposedly there is no a, such that f(a)=b. Your task is to come up with an expression for a (based on b), such that f(expression)=b, which contradicts the assumption that a does not exist.
Not quite sure how to apply a proof by contradiction on this problem.
 
I found it interesting that all the points that satisfy the function lie on the two parallel straight lines f(t)=tf(t)=t and f(t)=t+1f(t)=t+1.
 
The expression in question is in your previous post.
GivensGoal
bZaZf(a)=b\forall b\in \mathbb{Z} \,\exists a \in \mathbb{Z}\, f(a)=b
Givens
bZb\in \mathbb{Z}
Goal
aZ:f(a)=b\exists a \in \mathbb{Z}\,: f(a)=b
Givens
bZb\in \mathbb{Z}
¬aZf(a)=b\neg \exists a \in \mathbb{Z}\, f(a)=b
Goal
Contradiction
Givens
bZb\in \mathbb{Z}
aZf(a)b\forall a \in \mathbb{Z}\, f(a)\neq b
Goal
Contradiction

Is this the correct proof structure? So I need to suppose bb and aa are arbitrary integers and suppose f(a)bf(a)\neq b. But if a=2ba=2b, then aa is even so f(a)=f(2b)=bf(a)=f(2b)=b, which contradicts the assumption that f(a)bf(a)\neq b for all aZa\in \mathbb{Z}. Hence aZ:f(a)=b\exists a \in \mathbb{Z}\,: f(a)=b.
 
Last edited:
That was my first thought. Suppose nn is even, then by definition, there exists some kZk\in \mathbb{Z} such that n=2kn=2k. Then f(n)=kf(n)=k for some integer kk. And so f(n)f(n) will generate all integers kk when nn is even.
Now you need to show that if n is odd, you also get only integers. If n is even you get all the integers. If n is odd you only get integers (it doesn't matter if you get all the integers or not!). Now the union of Z with a subset of Z is Z. The proof is done.
 
Now you need to show that if n is odd, you also get only integers. If n is even you get all the integers. If n is odd you only get integers (it doesn't matter if you get all the integers or not!). Now the union of Z with a subset of Z is Z. The proof is done.
Thank you, Steven, that was an oversight on my part.

Suppose nn is even. By definition, there exists some kZk\in\mathbb{Z } such that n=2kn=2k. Therefore, f(n)=kf(n)=k for some integer kk. Hence, f(n)f(n) will generate all integers kk when nn is even.

Now suppose nn is odd. By definition, there exists some mZm\in\mathbb{Z } such that n=2m+1n=2m+1. Thus, f(n)=m+1f(n)=m+1. Since the integers are closed under addition, f(n)f(n) will generate a subset of the integers when nn is odd.

In either case f(n)f(n) will generate the union of Z\mathbb{Z } with a subset of the integers. But the union of Z\mathbb{Z } with a subset of Z\mathbb{Z } is equal to Z\mathbb{Z }. Therefore f(Z)=Zf(\mathbb{Z })=\mathbb{Z }.
 
Last edited:
I did a similar problem today.

Consider the function f:ZZf:\mathbb{Z}\rightarrow \mathbb{Z} given by

f(n)={n+1if n is evenn3if n is oddf(n)=\begin{cases} {n+1}&\text{if}~n~\text{is even}\\ {n-3}&\text{if}~n~\text{is odd}\end{cases}
Proof of that it's injective:

Suppose aZa\in \mathbb{Z} and bZb\in \mathbb{Z} are elements in the domain.

Case 1. Suppose aa is even and bb is even. Then f(a)=f(b)f(a)=f(b) iff. a+1=b+1a+1=b+1 iff. a=ba=b.

Case 2. Suppose aa is odd and bb is odd. Then f(a)=f(b)f(a)=f(b) iff. a3=b3a-3=b-3 iff. a=ba=b.

Case 3. Suppose aa is odd and bb even (or vice versa). Then f(a)=a3f(a)=a-3 and f(b)=b+1f(b)=b+1, clearly in this case aba\neq b

Hence if f(a)=f(b)a=bf(a)=f(b) \rightarrow a=b, which proves that it's injective.

Proof that ff is surjective.

Suppose bZb\in \mathbb{Z} and suppose for contradiction that aZ:f(a)b\forall a \in \mathbb{Z} \, : f(a) \neq b.

Case 1. Suppose bb is even. Then consider a=b+3a=b+3. Since aa is odd, f(a)=f(b+3)=b.f(a)=f(b+3)=b.

Case 2. Suppose bb is odd. Then consider a=b1a=b-1. Since aa is even, f(a)=f(b1)=bf(a)=f(b-1)=b.

Hence for each possible case, aZ:f(a)=b\exists a \in \mathbb{Z}: \, f(a)=b, which proves that it's surjective.
 
Top