Given finite sets $A$ and $B$, let $I = \{f: A \rightarrow B : f$ is one to one$\}$ and $S = \{f : A \rightarrow B : f$ is onto$\}$. Compute |I||S|. Maybe I'm overthinking this question. $A$ and $B$ are said to be finite, but how can I express the number of one to one functions and onto functions generically?
 A: I believe I've figured it out.
Let $a = |A|$ and $b = |B|$.
If $a > b$, $|I| = 0$.
If $a < b$, $|S| = 0$.
In either of these cases, $|I| * |S| = 0.$
This leaves the case that $a = b$. Since we want the product of the injectives and surjectives, we have the following:
$|I||S| = P(b, a)\sum_{j=0}^b (-1)^j {b \choose j} (b-j)^a$
However, we can simplify this by acknowledging the fact that $a = b$.
$P(a, b) = P(a, a) = a!$
Since $a = b$, there are also $a!$ bijections. Since there are $a!$ bijections, there has to be $a!$ surjections as well.
$|I||S| = P(b, a)\sum_{j=0}^b (-1)^j {b \choose j} (b-j)^a = a! * a! = (a!)^2$
A: The answer depends on the relative sizes of the finite sets $A$ and $B$.
Hints:


*

*If $|A| > |B|$, what can you conclude about $|I|$?

*If $|A| < |B|$, what can you conclude about $|S|$?

*If $|A| = |B|$, then an injective function is also a surjective function.  Likewise, every surjective function is also an injective function.  How many injective functions are there from a set with cardinality $n$ to a set with cardinality $n$?

