# What is a surjective function?

I am a 9th grader self-studying about set theory and functions. I understood most basic concepts, but I didn't understand what is a surjective function. I have understood what is an injective function, and if I know what is a surjective function, I think I could understand what is a bijective function (this is my main goal).

In formal terms a function $f$ from $A$ to $B$ is said to be surjective if for all $y$ in $B$, there exists $x$ in $A$ such that $f(x)=y$. I don't understand this clearly because i'm still new to these notations. Can you explain this in intuitive way? And for example can you give me a surjective function that is not injective, and inversely, and neither one of the two?

## 8 Answers

A surjective function is a function that "hits everything": so, for example, the function $f(x)=2x$ is surjective as a function from $\mathbb{R}$ to $\mathbb{R}$, since - for any real $a$ - ${a\over 2}$ is also a real number, and we have $f({a\over 2})=a$. By contrast, the function $g(x)=x^2$ is not surjective as a function from $\mathbb{R}$ to $\mathbb{R}$: there is no real $b$ such that $b^2=-1$, so the function $g$ can't "hit" $-1$ (or any other negative number).

Note, though, that surjectivity depends on how exactly we describe the function - specifically, what we take to be the codomain (=set of values the function is allowed, in principle, to output). For instance, $g(x)=x^2$ is surjective as a function from $\mathbb{R}$ to $\mathbb{R}_{\ge0}$, the nonnegative reals. So whenever we want to talk about a function being surjective (really, whenever we talk about functions at all :P), we need to be very precise about exactly what function we're talking about - where is it "coming from" (domain)? where is it "going to" (codomain).

• What I've never understood is, is $f:\Bbb R\to\Bbb R,x\mapsto x^2$ equal to $g:\Bbb R\to\Bbb R_{\ge0},x\mapsto x^2$? One is surjective and the other isn't, but according to the set-theoretic definition of a function (a function is equal to its graph) they're equal. – Akiva Weinberger Sep 3 '15 at 21:57
• This is an issue with how "function" is defined. There are two definitions of function: as a set of ordered pairs, or as a triple $(f, A, B)$ where $f$ is a set of ordered pairs and $A$ and $B$ are the domain and codomain. For functions defined the former way, "surjectivity" doesn't make sense; but usually in mathematics, it's more useful to work with the second notion of function. If you do want to define a function as just a set of ordered pairs (satisfying the obvious properties of course), then you can just talk about "$\subseteq ran$" instead of "surjective." So it's not too important. – Noah Schweber Sep 3 '15 at 22:11
• – Noah Schweber Sep 3 '15 at 22:12

(Prepare to facepalm) In simple cases, especially when $A,B$ are finite sets, you may represent a function $f\colon A\to B$ by a Venn diagram of two disjoint sets $A$ and $B$ and a number of arrows, each going from a point in $A$ to a point in $B$.

• The fact that $f$ is a function corresponds to the fact that each point in $A$ is the origin of exactly one arrow.
• $f$ is injective if no two arrows end in the same point of $B$. In other words: At each point of $B$ there ends at most one arrow
• $f$ is surjective if each point of $B$ is the end point of at least one arrow
• $f$ is bijective if each point of $B$ is the end point of exactly one arrow. (As a consequence, if we turn around each arrow, we obtain now a function $B\to A$)

You can restate it in terms of the range of $f$: a function $f : A \to B$ is surjective if its range is $B$. We also say that "$f$ maps onto $B$".

Surjectivity is a little bit of a weird notion, actually, because every function maps onto its range. That is, given any function $f : A \to B$, there is a surjective function $g : A \to \operatorname{range}(f)$ which is equal to $f$ at every point in $A$.

Some examples (emphasizing the issue in my previous paragraph):

• $f_1 : \mathbb{R} \to \mathbb{R},f_1(x)=x^2$ is neither injective nor surjective.
• $f_2 : \mathbb{R} \to \mathbb{R}_+,f_2(x)=x^2$ is not injective but it is surjective.
• $f_3 : \mathbb{R} \to \mathbb{R},f_3(x)=e^x$ is injective but not surjective.
• $f_4 : \mathbb{R} \to \mathbb{R}_{++},f_4(x)=e^x$ is injective and surjective.

Here $\mathbb{R}_+$ is the nonnegative reals and $\mathbb{R}_{++}$ is the strictly positive reals.

Remember that a function $f$ is defined by a domain $A$ and a co-domain $B$, i.e. $$f: A\to B$$ and some relation that defines the values $f$ takes. Then a surjective function is essentially a function that "hits" all elements in the co-domain $B$. Or said in another way, there is no element $y\in B$ that is not some function value of $f$.

This is explained rigorously by the definition you have, that for all elements $y\in B$ we can find an $x\in A$ such that $f(x) = y$.

Let $f:A\to B$ (i.e. $f$ has domain $A$ and codomain $B$). Then:

• $f$ is injective iff every value of $B$ is obtainable at most once.
• $f$ is surjective iff every value of $B$ is obtainable at least once.
• $f$ is bijective iff every value of $B$ is obtainable exactly once.

$f\colon A\to B$ is surjective if every element $b\in B$ has a pre-image in $A$. In other words: the equation $\;f(x)=b \enspace(x\in A)$ always has a solution, whatever the value of $b$.

Basically, if a function $f: A \to B$ is surjective, it means that every element of the set $B$ can be "obtained" through the function $f$. Formally, like you said, it means that for every $b \in B$, there exists some $a \in A$ such that $f(a) = b$. Phrased differently, $f$ being surjective means that the range of $f$ includes all of the set $B$.

For an example, take $A = \{1,2,3,4\}$ and $B = \{x,y,z\}$. Define $f : A \to B$ by $$f(1) = x$$ $$f(2) = y$$ $$f(3) = z$$ $$f(4) = z$$

Then $f$ is surjective because each element of $B$ has a corresponding element of $A$ which can be mapped onto it; but $f$ is not injective since both 3 and 4 are mapped into the same element of $B$, namely $z$.

If you just fool around with simple functions and sets like these, you can easily get some nice examples of the other two cases you wanted.

A function is surjective if you can get any value you want by giving it the adequate argument. For example, $y=f(x)=2x+1 (x\in R)$ is surjective because for any value of $y$ you can find a value of $x$ such that $f(x)=y$. Another way to see it is that if you express $x$ as an expression of $y$ that expression exists for all the possible values of $x$ (this means that the inverse function exists, although it may not be well defined).

Therefore, a good way to prove that a function $f$ is surjective is to arrive at the expression $f(g(x)) = x$ for some $g$.

Some examples of surjective functions are: $$f(x)=m·x + b$$ $$f(x)=x³$$ $$f(x)=log(x)$$ These three are also injective, but for example the function $$f(x)=x³-x$$ is also surjective but not injective, because it has the value $0$ several times ($x=1, x=0, x=-1$)

The function $$f(x)=x²$$ is not injective nor surjective, because it doesn't take negative values and returns all positive values two times.

And finally, the function $$f(x) = \frac{1}{1+2^x}$$ is injective (doesn't repeat values) but not surjective (it only gives values in the interval $(0, 1)$)