Consider sets $A=\left\{a,\:b,\:c,\:d\right\}$ and $B=\left\{1,\:2,\:3\right\}$. How many functions can be defined with domain $A$ and codomain $B$?
How would guess it is the cardinality of the power set of $A$ x $B$, but I'm lost on this one...
Consider sets $A=\left\{a,\:b,\:c,\:d\right\}$ and $B=\left\{1,\:2,\:3\right\}$. How many functions can be defined with domain $A$ and codomain $B$?
How would guess it is the cardinality of the power set of $A$ x $B$, but I'm lost on this one...
Your guess is not correct. There are $3$ choices for $f(a)$, $3$ choices for $f(b)$, and so on. These choices are completely independent of one another, so there are a total of $3^4 = 81$ functions from $A$ into $B$. But if I correctly understand your question, you want the number of surjections.
So you have to subtract the number of functions that aren't surjections. There is one way to map a $4$-element set into a $1$-element set and you have three elements to choose from, so there are $3$ functions that map $A$ onto a single element of $B$.
There are $2^4=16$ ways to map a $4$-element set into a $2$-element set, but $2$ of those don't hit both elements, so there are $14$ ways to map a $4$-element set onto a $2$-element set. There are $3$ ways to choose a $2$-element subset of $B$ so there are $42$ functions from $A$ into $B$ that map into exactly $2$ elements of $B$.
Thus, of the $81$ total functions from $A$ into $B$, $45$ of them are not surjective. That means there are $36$ functions from $A$ onto $B$.