Show the function $f(n)=\dfrac {(-1)^n (2n-1)+1} {4}$ is a surjection

• Let $$f:\mathbb{N}\rightarrow\mathbb{Z}$$ be a function which $$f(n)=\dfrac {(-1)^n (2n-1)+1} {4}$$. Show that $$f$$ is surjection.

Proof. Let $$m\in\mathbb{Z}$$. We need to find $$n\in\mathbb{N}$$ such that $$f(n)=m$$.Let $$m=\dfrac {(-1)^n (2n-1)+1} {4}$$ for $$n\in\mathbb{N}.$$ If $$n$$ is even then we get

$$m=\dfrac {(-1)^n (2n-1)+1} {4},$$

$$4m=2n,$$

$$2m=n\in\mathbb{N}.$$

If $$n$$ is odd, then we get

$$4m=-2n+1+1$$

$$1-2m=n\in\mathbb{N}.$$

Therefore, can we say $$f$$ is surjective?

You can leave it more explicit

Let $$n \in \mathbb{N}$$

If $$n$$ is even, $$n = 2k$$ for some $$k \in \mathbb{N}$$

Then $$f(2k) = f(n) =\frac{(-1)^{n}(2n-1)+1}{4} = \frac{(2n-1)+1}{4} = \frac{2n}{4} = \frac{4k}{4} = k$$

So, for each $$m \in \mathbb{N}$$, if we take $$n = 2m$$, we have that $$f(n) = f(2m) = m$$

Now if $$n$$ is odd, we have $$n = 2k -1$$ for some $$k \in \mathbb{N}$$

Then $$f(2k-1) = f(n) = \frac{(-1)^{n}(2n-1)+1}{4} = \frac{(-2n +1) +1}{4} = \frac{(-2n + 2)}{4} = \frac{-2(2k-1) +2}{4} = \frac{-4k + 4}{4} = -k + 1$$

So if $$m \in \mathbb{Z}, m ≤ 0$$ then $$m - 1≤-1$$ so $$-m +1≥ 1$$ Then $$-m + 1 \in \mathbb{N}$$ And if we take $$n = 2(-m+1) -1$$ then we have $$f(n) = f(2(-m+1)-1) = -(-m+1) + 1 = m$$

Then $$f$$ is surjrctive.

Your proof is a little backward. You need to find $$n \in \mathbb{N}$$ such that $$f(n)=m$$. So you can't say "let $$m= f(n)$$", because you don't know that there is such $$n$$ a priori. As such, it doesn't make sense to say "if $$n$$ is even" or "if $$n$$ is odd", since you have not demonstrated that $$n$$ exists. What you have written down is like the scratch work to figure out how the proof should go, but it does not constitute a proof.

Notice that: \begin{align*} f(1)&=0\\ f(2) &= 1 \\ f(3) &= -1\\ f(4) &=2\\ f(5)&=-2 \\ &\vdots \end{align*}

Now consider separately the cases $$m=0$$, $$m>0$$, and $$m<0$$. In each case, come up with a formula for $$n$$ in terms of $$m$$ that will satisfy $$f(n)=m$$.

a little algebra shows: $$f(n+2) - f(n) = (-1)^n$$

since $$f(0) = 0$$, then by a telescoping sum: $$f(0+2m) = \sum_{k=1}^m (-1)^0 = m$$

similarly, $$f(1) = 0$$, and so $$f(1+2m) = \sum_{k=1}^m (-1)^1 = -m$$