4

Let A and B be two sets.

$A=\{1,2,\dots m\}$

$B=\{1,2,\dots n\}$

We have to find the number of onto functions from A to B

In the following link , the approach of the answer was applying Inclusion Exclusion to count the complement. Can't we use it directly?

Number of onto functions

My Approach

Let $J_i$ denote the number of mappings in which there exists a pre-image of $i$.

We need to find $|J_1\cup J_2\cup \dots J_n|$.

From inclusion exclusion we conclude

$$|J_1\cup J_2\cup \dots J_n|=\sum_{i=0}^n|J_i|- \sum_{1\leq i <j\leq n}|J_i\cap J_j| \dots$$

Now, $|J_i| = m * n^{m-1}$

$|J_i\cap J_j|$= $m*(m-1)*n^{m-2}$ and so on.

Then we just put in the values. Is it correct?

Soham
  • 2,029
  • You may also make use of exponential generating function. Obtain $$\left[\frac{x^m}{m!}\right]\left(e^x-1\right)^n$$ – gar Jul 06 '14 at 14:46

1 Answers1

2

A function is onto iff every element of the codomain has nontrivial fiber.

So you need to compute $|\bigcap J_i|$, not $|\bigcup J_i|$.

anon
  • 151,657