$A = \{a, b, c, d\}$ and $B = \{1, 2, 3\}$. How many functions from $A$ to $B$ map $a$ to $1$ and are not onto? 
I'm not sure how to do this. I know what an onto function is but I'm not sure how to start.
 A: Hint:
If a function $f$ is not onto, knowing that $a$ maps to $1$, it misses $2$ or $3$ or both. So there are two main cases:


*

*$f$ misses  $2$. The number of  such functions is equal to the number of functions from the set $\{b,c,d\}$ to the set$\{1,3\}$.

*Symmetrically, if $f$ misses  $3$, the number of  such functions is equal to the number of functions from the set $\{b,c,d\}$ to the set$\{1,2\}$.


The number of functions which map  $a$ to $1$ and are not onto is the union of these two sets. You can apply the inclusion-exclusion formula.
A: Let $f$ be such a function.  We are given $f(a) =1$ and $\{f(b), f(c), f(d)\} \subsetneq \{1,2,3\}$.  So how many ways are there to be non-onto?


*

*$b$, $c$, and $d$ all get sent to $1$, or

*all get sent to $2$, or

*all get sent to $3$.

*$b$, $c$, and $d$ all get sent to $1$ and $2$, or

*to $1$ and $3$, 

*(but not to $2$ and $3$ because then $f$ is onto).


You should be able to count each of those easily enough and to see that there are no other options.
A: Use the inclusion-exclusion principle.
The number of functions $A \to B$ that map $a$ to $1$ is 27. To not be surjective (or onto) means that either 2 or 3 is not in the image. Of the 27 functions satisfying (a), 8 of them do not have 2 in the image, and another 8 do not have 3 in the image. One function, the constant function that is everywhere equal to 1, has neither 2 nor 3 in its image.
The answer is that there are $8+8-1=15$ functions satisfying both (a) and (b).
