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

I'm not as experienced at writing proofs as you. It seems it would be enough since the domain and codomain are both Z\mathbb{Z}?
What I meant is that just for even nn's the image of ff is all of Z\mathbb Z (i.e. the image is the same as codomain), which makes ff surjective before we even consider its values for odd nn's.
 
What I meant is that just for even nn's the image of ff is all of Z\mathbb Z (i.e. the image is the same as codomain), which makes ff surjective before we even consider its values for odd nn's.
In other words, the range of the function is equal to the codomain. Yes, I think I understand this. I have a book at home that presents this as a theorem, although I haven't read that far yet.
 
Last edited:
I thought of this as a definition of surjectivity. Which definition does your book use?
The book I'm currently reading gives the following definition.

A function is surjective (a surjection or onto) if every element of the codomain is the output for at most one element from the domain.
 
AAThe book I'm currently reading gives the following definition.

A function is surjective (a surjection or onto) if every element of the codomain is the output for at most one element from the domain.
The other book I'm referring to is more formal.

FF is a relation from AA to BB. Then FF is called a function from AA to BB if for every aAa\in A there is exactly one bBb \in B such that (a,b)F.(a,b)\in F. In other words

aA!bB((a,b)F)\forall a \in A \exist !b\in B((a,b)\in F)
Suppose f:ABf:A\rightarrow B. We say that ff is onto if

bBaA(f(a)=b)\forall b\in B \exists a\in A (f(a)=b)
The range of ff is the set

Ran(f)={bB:aA(a,b)f}Ran(f)=\lbrace b\in B:\exist a\in A (a,b)\in f\rbrace
We can relate the definition of onto to the definition of range.

fis onto iffbBaA(f(a)=b)\begin{aligned} f \,\text{is onto iff} \quad & \forall b\in B \exist a\in A (f(a)=b) \end{aligned}fis onto iffbBaA((a,b)f)\begin{aligned} f \,\text{is onto iff} \quad & \forall b\in B \exist a\in A ((a,b)\in f) \end{aligned}fis onto iffbB(bRan(f))\begin{aligned} f \,\text{is onto iff} \quad & \forall b\in B (b\in Ran(f))\end{aligned}BRan(f)B \subseteq Ran(f)
Suppose ff is onto. By equivalence just derived we have BRan(f)B\subseteq Ran(f), and by the definition of range we have Ran(f)BRan(f) \subseteq B. Thus it follows that Ran(f)=BRan(f)=B.
 
Last edited:
The book I'm currently reading gives the following definition.

A function is surjective (a surjection or onto) if every element of the codomain is the output for at most one element from the domain.
Whops, I accidentally wrote that incorrectly without thinking. The definition given is:

A function is surjective if every element of the codomain is the output for at least one element of the domain.

By this definition it is quite obvious that the range must equal the codomain, however, the author never mentions this fact.
 
Whops, I accidentally wrote that incorrectly without thinking. The definition given is:

A function is surjective if every element of the codomain is the output for at least one element of the domain.

By this definition it is quite obvious that the range must equal the codomain, however, the author never mentions this fact.
Sounds like you got it figured out by now. A minor note: this Wikipedia article says that term range is more ambiguous than image.
 
The book I'm currently reading gives the following definition.

A function is surjective (a surjection or onto) if every element of the codomain is the output for at most one element from the domain.
Why at most. I'd like to see an image of that definition. I suspect that it says at least.
Consider the following mapping/function.
Suppose f: Z-> {7,8} where if n is even, f(n)=8 and if f is odd, f(n)=7.
This function is surjective because you hit every element in {7,8}. That is, for each element in y in {7,8} there is an (at least!) element z in Z such that f(z) = y.
What you described is a function which is both 1-1 and onto!

Edit: I'll leave this post but I now see that you updated your definition of surjective.
 
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 }.
Looks fine to me.
disclaimer: I have a huge headache so don't trust my opinion at this time.
 
No, in theory if n is odd you can get non-integers.
f(n)f(n) is defined differently for odd nn. But the image of even nn's alone covers all of Z\mathbb Z, which by itself makes ff surjective.
 
f(n)f(n) is defined differently for odd nn. But the image of even nn's alone covers all of Z\mathbb Z, which by itself makes ff surjective.
As always, you are correct as f maps from Z to Z.
To OP: Since the range is Z and we already showed that if n is even we cover all of Z then in fact, as blamocur pointed out, the proof is done.
 
Top