1

Ok so following questions are given in my text book

Let $A = \{1, 2, 3,...., n\}$ and $B =\{a, b, c\}$ then the number of functions form $A$ to $B$ that are onto is.

I have no idea how to find the answer can anybody help me

Thanks Akash

Deiknymi
  • 383
  • You can find many similar problems here (with answers). For example http://math.stackexchange.com/questions/500674/number-of-surjective-functions-from-a-to-b, http://math.stackexchange.com/questions/264799/calculating-the-total-number-of-surjective-functions and many other can be found with a little searching. – Martin Sleziak Apr 16 '14 at 18:03

1 Answers1

0

For a function we know that a unique element from $B$ is assigned to every element of $A$. Therefore counting functions from $A$ to $B$ is the same as counting strings of length $|A|=n$ with elements from $B$.

So then there are $3^n$ functions from $A$ to $B$ in total. To find all surjective functions we must subtract all strings which only consist of elements in $\{a,b\}$ or $\{a,c\}$ or $\{b,c\}$ or only of either of the single elements $a,b$ or $c$.

Now each time we count the strings consisting of two elements (functions with an image containing only 2 elements in B) we also count two strings consisting of only a single element in B (eg counting strings consisting of {a,b} include counting the two strings only consisting of a and b). So we must subtract 2 strings for every such a case. This gives us all the functions with exactly 2 elements in its image: $3\cdot 2^n-3 \cdot 2$.

Finally we count functions which only have a single element of B in its image (there are only 3).

So then, taking it all together we have, number of functions onto $B$ is \begin{equation} 3^n-(3\cdot 2^n-3\cdot 2)-3. \end{equation}

  • What does your formula give for $n=3$ and what do you actually expect in this case? Conclude. – gniourf_gniourf Apr 16 '14 at 18:21
  • 1
    "The formula above holds for all n≥3" No it doesn't. For $n=3$ your formula gives $0$, whereas we'd be expecting $6$ surjections. You're wrong in the way you're counting the non-surjective maps, since you're counting several times the constant ones. – gniourf_gniourf Apr 16 '14 at 18:32
  • In fact it's when you're saying that there are $2^n$ mappings from ${1,\ldots,n}$ to ${a,b}$. This is correct, but you're also counting two constant ones: the one constant equal to $a$ and the one equal to $b$. Then you're counting these again when counting the mappings with values in ${a,c}$ and ${b,c}$, and eventually you're counting them again as the constant ones! – gniourf_gniourf Apr 16 '14 at 18:37
  • @ gniourf_gniourf is @Christiaan Hattingh wrong because the answer he gave is one of the the option to the question – Deiknymi Apr 17 '14 at 16:36