Question
Find the number of onto (surjective) functions from a set with 4 elements to a set with 3 elements.
(JEE Main 2022)
Solution — Step by Step
Total number of functions from to : each of the 4 elements in can map to any of the 3 elements in . So total .
An onto function must “hit” every element of . We need to subtract functions that miss at least one element of .
Let = set of functions that miss element from .
We want: Total
By inclusion-exclusion:
= functions missing one specific element = . There are such terms.
= functions missing two specific elements = . There are such terms.
= functions missing all three elements = .
Why This Works
A function from to is onto if every element of is the image of at least one element of . Since , onto functions exist (they wouldn’t if ).
The inclusion-exclusion principle handles the “at least one element missed” condition systematically. Directly counting onto functions is hard, but counting functions that miss specific elements is easy — if we exclude elements from , the remaining elements give functions.
Alternative Method — Using the formula directly
The number of onto functions from a set of elements to a set of elements () is:
For , :
This formula is worth memorising for JEE. For small values, you can also use: onto functions from to = where is the Stirling number of the second kind. For : partition 4 elements into 3 non-empty groups = 6 ways, then assign to 3 elements of = .
Common Mistake
A frequent error is computing and stopping there — forgetting the inclusion-exclusion correction for double-counting. When we subtract functions missing , missing , and missing , we over-subtract functions that miss TWO elements (they get subtracted twice). We must add those back. Always complete all terms of inclusion-exclusion.