Why is this function neither injective nor surjective? Hello guys I am doing some maths revision and I am stuck. I read and I saw videos and I still can't get my head around it.
I have this example:

Determine whenever this function $\mathbb{Z}\to\mathbb{Z}$ is injective, surjective, neither, both:
$$f(x) = n^2 + 1$$

In the answer it is given that is neither without explaining why not.
If I substitute $n$ with $1$, I will get $f(1) = 2$ and, with $-1$, $f(-1) = 2$ again. So that should be surjective but it says is neither?
 A: The fact that $f(1)=f(-1)$ implies that $f$ is not injective.
Then $n^2+1>0, \forall n\in \mathbb{Z}$, so $f(\mathbb{Z}) \subseteq \mathbb{N}$ so f is not surjective.(=there exists a so that for all b $\in \mathbb{Z}$ $f(b) \ne a$ ; ex : $a=-1$)
A: You're given a function $f$ which takes values in $\mathbb Z$ to values in $\mathbb Z$ by the rule $f(x)=x^2+1$.
Let's recall what injective means. Our function $f$ will be injective if for any $x_1,x_2\in\mathbb Z$ such that $f(x_1)=f(x_2)$, we have $x_1=x_2$. You pointed out that $f(1)=2=f(-1)$, but that $1\neq -1$. We plugged $x_1=1$ and $x_2=-1$ into $f$ and saw that $f(x_1)=f(x_2)$. But $x_1\neq x_2$. Therefore, $f$ cannot be injective. Another intuitive way to see this is to view whether or not $f$ passes the horizontal line test. Does it?
In general, to show that a function $f:X\to Y$ is injective, we can show that $$f(x_1)=f(x_2)\implies x_1=x_2$$ or we can show that $$x_1\neq x_2\implies f(x_1)\neq f(x_2).$$
So let's look at whether or not $f$ is surjective. Remember that $f$ is surjective if for any $y\in\mathbb Z$ (in the target set) there is some $x\in\mathbb Z$ (in the domain) such that $f(x)=y$. But notice that $f(x)=x^2+1>0$ for each $x\in\mathbb Z$. So what happens if we choose $y\leq 0$?
In general, to show that a function $f:X\to Y$ with some rule $f(x)$ is surjective, we pick some arbitrary $y\in Y$. Then we find some value in $x\in X$ in terms of $y$, by looking at the rule of our function, that gives $f(x)=y$.
A: I look at injectivity, surjectivity, and bijectivity this way:
A mapping $f : A \to B$ is injective if, for every element in the codomain $B$, there is at most one element in the domain $A$ that maps to it.
A mapping is surjective if, for every element in the codomain, there is at least one element in the domain that maps to it.
A mapping is bijective if, for every element in the codomain, there is exactly one element in the domain that maps to it.
Since your range is $\mathbb Z$, that means that for the function $f(n) = n^2 + 1$ to be injective, no two elements of the domain can map to the same element in the codomain.  This is obviously false--$f(-n) = f(n)$ for all integers $n$.
For the function to be surjective, for any integer $m$, there must be another integer $n$ such that $n^2 + 1 = m$.  This is also obviously false--if $m = 0$, then there is no integer (or even real) solution to $n^2 + 1 = 0$.
A: Surjective means that every number $n\in \mathbb{Z}$ can be written in the form $n=f(m)=m^2+1$, it is clear that negative numbers $n$ cannot be written like this, so $f$ is not surjective. $f$ injective means that different numbers $n$ and $m$ cannot have the same value by $f$, but $1$ and $-1$ are different and have the same value by $f$: $f(-1)=f(1)=2$, so $f$ is not injective.
A: Loosely speaking a function is injective if it cannot map to the same element more than one place. A function is surjective if it maps into all elements (that the function is defined onto). For your example:
First remember that $\mathbb{Z} = \{0,1,-1,2,-2,...\}$. Since the function $f$ maps to $2$ both when $n=1$ and $n=-1$, i.e. $f(1)=f(-1)=2$ it maps to the same element at more than one place. So it is not injective.
Let's check if it is surjective. Then all values of $\mathbb{Z}$ must be mapped to by the function ($f: \mathbb{Z}\rightarrow\mathbb{Z}$). Since there is no $n$ that produces (for example) the value $-2\in\mathbb{Z}$ it cannot be surjective.
Here are some more for you. Is the function $g:[0,\infty)\rightarrow \mathbb{R}$ defined by $g(x)=x^2$ injective, surjective, both or none? Well, $x^2$ is positive or zero for all $x\in[0,\infty)$ so it cannot be surjective since it doesn't map to for example $-3\in\mathbb{R}$. Since $x^2$ maps into a unique element for all $x\in[0,\infty)$ it is, in fact, injective. Now if we look at $h:\mathbb{R}\rightarrow\mathbb{R}$ defined again by $h(x)=x^2$ then it is not surjective for the same reasons. But it is not injective either since we now can take $h(2)=h(-2)=4$. So the function $h$ maps different elements into the same element so it is not injective. As you can see, it is very important which spaces the functions go from and to.
