2

In class we learned the number of functions from an $m$-element set to an $n$-element set is $n^{m}$. So this answer should be $5^{3}$?

I just need confirmation if my answer is correct, if not explain to me why it's not.

Nixie777
  • 741
  • 4
    If it concerns all functions from ${1,2,3,4,5}$ to ${1,2,3}$ then the answer is $3^5$ (you switched $m$ and $n$). – drhab Jul 12 '17 at 07:51
  • 1
    Note that "onto" has a specific meaning for functions (i.e. if a function is from set A "onto" B, then all values in B can be reached as f(a) for some a in A). If you just mean any function from A to B (regardless of whether all values in B are used), then avoid using the word "onto". – psmears Jul 12 '17 at 10:47
  • It should be $3^5$, not $5^3$. (And as others explained, it's actually less than that because of the requirement to be onto). – Meni Rosenfeld Jul 12 '17 at 13:30

6 Answers6

4

hint

From the total number of functions $3^5$ subtract the number of functions which are NOT onto. Suppose your target set is $\{a,b,c\}$. Then

  1. There are only $3$ functions with range as singletons, for example everything mapping to $a$.
  2. Now count the number of functions whose range is of the form $\{a,b\}$. This will be $3(2^5-2)=90$ (Think why?).

In general, inclusion-exclusion principle is used for such problems.

Anurag A
  • 42,261
3

Let $F$ denote the set of all functions $\{1,2,3,4,5\}\to\{1,2,3\}$.

For $i=1,2,3$ let $F_i\subset F$ denote the functions in $F$ that have not $i$ in their image.

Then you are looking for: $$|F|-|F_1\cup F_2\cup F_3|=3^5-|F_1\cup F_2\cup F_3|$$

Term $|F_1\cup F_2\cup F_3|$ can be found by means of inclusion/exclusion combined with symmetry:$$|F_1\cup F_2\cup F_3|=\binom31|F_1|-\binom32|F_1\cap F_2|=3\cdot2^5-3\cdot1^5$$

drhab
  • 153,781
3

Let $S_j$ be all the functions from $\{1,2,3,4,5\}$ to $\{1,2,3\}$ that miss $j$, for $j\in\{1,2,3\}$ $$ N_k=\sum_{|A|=k}\left|\,\bigcap_{j\in A} S_j\,\right| $$ Note that $\bigcap\limits_{j\in A} S_j$ is the set of functions from $\{1,2,3,4,5\}$ to $\{1,2,3\}\setminus A$.

There are $\binom{3}{k}$ ways to choose $A$.
For each choice of $A$, there are $(3-k)^5$ functions in $\bigcap\limits_{j\in A} S_j$.

Therefore, $N_k=\binom{3}{k}(3-k)^5$. Using the Generalized Principle of Inclusion-Exclusion, there are $$ \sum_{k=0}^3(-1)^k\binom{k}{0}\binom{3}{k}(3-k)^5=150 $$ functions in none of the $S_j$.

robjohn
  • 353,833
3

First split $[5]$ into $3$ nonempty blocks, then assign values from $[3]$ to these blocks in $3!=6$ ways. The number of splittings is the Stirling number of the second kind $S(5,3)$. It is obtained as follows:

The blocks can have sizes (a) $3,1,1$ or (b) $2,2,1$. In case (a) the large block can be formed in ${5\choose 3}=10$ ways. In case (b) the singleton can be chosen in $5$ ways, and the remaining four elements can then be paired in $3$ ways, makes $15$ splittings.

It follows that $S(5,3)=25$, so that there are $25\cdot6=150$ surjective mappings $f:\>[5]\to[3]$.

  • We have not learned Stirling numbers yet, so I this is all new to me. – Nixie777 Jul 14 '17 at 11:49
  • O.k. Later you'll learn that Stirling numbers are the standard tool to count surjective mappings.There are recursions and tables for them. Above I computed $S(5,3)$ from scratch. – Christian Blatter Jul 14 '17 at 16:27
2

$n^m$ counts all functions from $m$ to $n$, but you want only the onto ones, so all values in the image should occur at least once, this forces $n \le m$ of course (every $i \in m$ has at least one $j \in m$ mapping to it, and different $i$'s have different $j$'s)

A hint as to how to count them: inclusion-exclusion with the properties $P_i: i \notin \operatorname{Im}(f)$. See wikipedia which even covers this specific problen lower in the page.

Henno Brandsma
  • 250,824
0

When talking about functions, the word 'onto', which you used in the title of the question, has a specific technical meaning (it means the function is 'surjective'). If this is what you meant then the other responses give the answer.

If you were just using 'onto' to mean the same as 'to', then the only problem with your answer is that you swapped the roles of $n$ and $m$, so the answer should be $3^5$. (You can see this, as each of the five elements has a choice of three things the function can send it to, so there are $3\times 3\times 3\times 3\times 3$ possible choices.)

aPaulT
  • 998