[Math] Counting the number of injections and surjections

combinatoricsfunctions

Let $A$ be a set with $n$ elements and $B$ bet a set with $n+1$ elements.

In order to be injective, for each $b \in B$ there is exactly one $a \in A$ such that $f(a)=b$. I'm under the impression that this comes out to $\frac{(n+1)!}{(n+1-n)!}=(n+1)!$. However, I'm worried that I'm overcounting.

Let $A$ be a set with $n+1$ elements and $B$ bet a set with $n$ elements.

This one I'm a bit more worried about. It seems like for each choice of $b$, there is at most $n+1$ elements to be choosen from $A$. It seems like there are at most $(n+1)^n$ onto functions.

Best Answer

For injectivity you are correct. Another way of getting that number is you have $n + 1$ choices for which element of $B$ to miss, and there are $n!$ choices for how to order the $n$ elements we hit (imagine $A = \{1, 2, \ldots, n\}$).

For surjectivity there can be at most $1$ collision. So there are ${n + 1} \choose 2$ choices for the collision and then $n!$ ways to order the $n$-groups left over (we combine the two that map to the same element onto one "group"). This gives ${{n + 1} \choose 2}\cdot n! = \frac{1}{2}n\cdot(n+1)!$.

Related Question