4

How many surjective functions $f:\{0,1,2,3,4\} \rightarrow \{0,1,2,3\}$ are there?

So as I understand it I need to determine how many functions map from the set $\{0,\ldots,4\}$ to the set $\{0,\ldots,3\}$ such that for every element in $\{0,\ldots,3\}$ there is at least one element in $\{0,\ldots,4\}$.

My guess is that the total number of functions is $4^5$.

nmasanta
  • 9,640
  • 5
    HINT: If $f$ is a surjective function from ${0,1,2,3,4}$ to ${0,1,2,3}$, there must be exactly one element of ${0,1,2,3}$ that is the image under $f$ of two different elements of ${0,1,2,3,4}$. – Brian M. Scott Oct 01 '20 at 00:25
  • @OliverDiaz Follow Brian M. Scott's suggestion. Choose which element of the codomain is the image of two elements of the domain. Choose which two elements of the domain map to that element. Map the remaining three elements to the remaining three elements of the codomain so that each of the remaining elements in the codomain is the image of exactly one element of the domain. – N. F. Taussig Oct 01 '20 at 00:44
  • 1
    Precisely one pair of elements in the domain will map to the same element, so you need to choose which pair, and then choose a bijection between sets of size $4$ (e.g. ${0,1,{2,3},4}\to {0,1,2,3}$). Each combination of a pair and a bijection gives you a different surjection, so you just need to multiply the number of pairs by the number of bijections. – tkf Oct 01 '20 at 01:12
  • 1
  • This is a related posting – Mittens Oct 01 '20 at 01:56

3 Answers3

4

We can solve this using inclusion and exclusion principle

Let $A = \{0,1,2,3,4\}$ and $B = \{0,1,2,3\}$

The total number of functions from $A$ to $B$ is $4^5 = 1024$

Total number of functions which miss one element in $B=$ $^{4}\text {C}_1$ $3^5 = 972$

Since we have to choose from $3$ elements from set $B$ and the number of ways in which we can exclude one element from $B$ is $^{4}\text {C}_1$

Similarly, Total number of functions which miss $2$ elements in $B=$$^{4}\text {C}_2$ $ 2^5 = 192$

And , Total number of functions which miss $3$ elements in $B=$$^{4}\text {C}_3$ $ 1^5 = 4$

Thus , Total number of surjective functions = Total functions$−$Functions missing at least one element$+$Functions missing at least two elements$−$Functions missing at least three elements.

$= 1024-972+192-4$

Total number of surjective functions $=240$

Ved Patel
  • 623
  • Here I have excluded the possibility of missing 4 elements from $B$ as it will be $^{4}\text {C}_4$ $0^5 = 0$ – Ved Patel Mar 08 '25 at 11:28
3

You can determine which element of the codomain appears twice, e.g. if $0$ then we would consider $0,0,1,2,3$.

There are $\frac{5!}{2!}=60$ combinations of the $4$ ways to do this, so $240$ in total.

JMP
  • 22,637
-1

Rule: If A and B are two sets having $m$ and $n$ elements respectively such that $1≤n≤m$, then $$\text{number of surjection} ~=\sum_{r=1}^n(-1)^{n-r}~ {}^{n}\text{C}_r ~r^m~.$$

Here A$=\{0,1,2,3,4\}~$ B$=\{0,1,2,3\}~,$ hence $~m=5~,~ ~n=4~$ and clearly, $~1≤n≤m~.$

Therefore the number of surjection from A to B
$=\sum_{r=1}^4(-1)^{4-r}~ {}^{4}\text{C}_r ~r^5\\=(-1)^{3}~ {}^{4}\text{C}_1 ~1^5+(-1)^{2}~ {}^{4}\text{C}_2 ~2^5+(-1)^{1}~ {}^{4}\text{C}_3 ~3^5+(-1)^{0}~ {}^{4}\text{C}_4 ~4^5\\=-4+192-972+1024\\=240$

nmasanta
  • 9,640