# How to tell if a function is onto or one-to-one

I'm practicing what we learned in lecture today and unfortunately I have little to no understanding about the material. I only know the difference of these functions only when a diagram is present (and I can't always have that, so I need to learn how to figure it out without one)

So I've provided an example from my textbook (not assigned work)

Question: Determine whether each of these functions from $\mathbb{Z}$ to $\mathbb{Z}$ is one-to-one

$a$) $f(n)=n-1$ (ANS: onto)

$b$) $f(n)=n^2+1$ (ANS: one-to-one)

I know the answers only since I looked in the back, but have no idea why. Can someone please explain? I will be using the answers as a base to complete the rest of the questions for study.

-
One of the answers is wrong. $f(n) = n^2 +1$ is not one-to-one, it is two-to one – Rustyn Nov 13 '13 at 17:03
try to solve for n. that means: a)n=f(n)+1. Try to do it for (b). can you get only one solution? If yes, it is 1-1 – Thanos Darkadakis Nov 13 '13 at 17:05
Note: the answer to (b) is correct if the function is actually from $\mathbb{N}$ to $\mathbb{N}$. – vadim123 Nov 13 '13 at 17:06
@vadim123 That's actually something else I haven't been able to understand. Why would the answer be different for N (natural numbers) than with Z (set of integers)? – user734923 Nov 13 '13 at 17:11
How many natural number have a square of $4$? How many integers have a square of $4$? I mean, one glaring difference between Z and N is the negative numbers... – The Chaz 2.0 Nov 13 '13 at 17:24

One of the answers is wrong. $f(n) = n^2 +1$ is not one-to-one, it is two-to one. (Do you understand what I mean?). The reason why $f(n) = n-1$ is onto, is because for any integer $m$, the successor integer, $m+1$ corresponds to it. Explicitly, $f(m+1) = (m+1) -1 = m$

-

Let $\mathrm f$:$R\rightarrow S$ be a relation. The relation is one-one if every elemt in $R$ is mapped uniquely to every element in S. That means for every x $\in$ R $\exists$ y $\in$S such that

$$f(x)=y$$The relation is then said to be one-one.

Now,the function(a relation which is one one and onto) is said to be onto if every element of $R$ is mapped to every element in $S$. To determine whether the function is one-one and onto the domain and range of the function has to be known

As an example lets take the function

$$y=x^2 \text{, x \in R}$$ The relation here is not one-one as you have 2 different values of x which gives the same value of y.$$f(-2)=f(2)=4$$

However if we restrict the domain of the function to the set of positive natural numbers(or negative) the function becomes one-one.

-

A function $f:A\rightarrow B$ is one-to-one if whenever $f(x)=f(y)$, where $x,y \in A$, then $x=y$. So, assume that $f(x)=f(y)$ where $x,y \in A$, and from this assumption deduce that $x=y$.

If we assume that $f(n_1)=f(n_2)$ where $n_1,n_2\in \mathbb{Z}$, that is we assume that $(n_1)^2+1=(n_2)^2+1$, then $(n_1)^2=(n_2)^2$. This does not imply that $n_1=n_2$, consider $n_1=1$ and $n_2=-1$. Thus $f(n)=n^2+1$ is not a one-to-one function.

-