Number of onto functions from $Y$ to $X$ (JEE Advanced 2018)

Let $$X$$ be a set with $$5$$ elements and $$Y$$ be a set with $$7$$ elements. If $$\beta$$ is the number of onto functions from $$Y$$ to $$X$$ then the value of $$\dfrac{\beta}{5!}$$ is?

My approach is:

First I give each element of $$Y$$ one element of $$X$$ which then leaves me with two possibilities for the remaining two elements of $$Y$$.

1) Both can take same value

2) Both take different value from X.

So number of onto functions = $$\beta = {^7}C_5\times 5! \times(5+ 5\times4)$$ but this is wrong.

What's my mistake?

Also, I know how to solve the problem using principle of inclusion exclusion and that gives the right answer but we are not given calculators in exam and the calculation involved there is very lengthy.

The mistake is that you are overcounting some maps. For example (assuming $$X=\{1,\dots,5\}$$ and $$Y=\{1,\dots,7\}$$), the map that is the identity on $$X$$ and maps $$6,7\mapsto 1$$ is counted several times. Once, by choosing in your first step the elements $$1,2,3,4,5$$, then assigning the remaining two elements to $$1$$. A second time by choosing in your first step $$6,2,3,4,5$$ and then assigning the remaining elements (1 and 7) to $$1$$. A third time by choosing $$7,2,3,4,5$$ and then assigning the remaining elements (1 and 6) to 1.

You see that the surjective maps that map three elements to a same $$x$$ (the first type in your question) are counted three times. If you can figure out how many times you count each map of the other type (type 2 in your question), then you can fix your argument.

You are overcounting. Take $$X = \{1,2,3,4,5\}$$ and $$Y = \{1,2,3,4,5,6,7\}$$. Then in your methodology, choosing $$5$$ elements from $$Y$$ and mapping them to all elements in $$X$$, suppose $$f:Y \to X$$ is a function such that $$f(1) = 1$$, $$f(2) = 2$$,$$f(3) = 3$$,$$f(4) = 4$$,$$f(5) = 5$$ . Then for $$6$$ and $$7$$, suppose $$f(6) = 1$$ and $$f(7) = 2$$. But this fucntion is as same as the following: Let $$g:Y\to X$$. While choosing $$5$$ elements from $$Y$$, we choose $$3,4,5,6,7$$ and map them as $$g(3) = 3$$, $$g(4) = 4$$, $$g(5) = 5$$, $$g(6) = 1$$, $$g(7) = 2$$, which is still a valid mapping in your methodology. Then, for $$1$$ and $$2$$, map them in a way that $$g(1) = 1$$ and $$g(2) = 2$$. Now we have $$f = g$$ but we count both of them.

In this way, you need to find the number of functions that are counted multiple times and how many times they are counted. I would not suggest that because it may be even more lengthy and it is easier to miss some of the cases.

The method that involves Inclusion-Exclusion Principle leads us to Stirling Number of the Second Kind. I am not sure it gives a way to count it with less calculations but you can read it, there is also a recursion formula for it, which might be helpful.

Your method counts each surjective function that maps three elements of $$Y$$ to one element of $$X$$ three times, once for each way you could designate one of those three elements as the element of $$Y$$ that maps to that element of $$X$$.

For example, consider the surjective function $$f: Y \to X$$ defined by $$f(1) = 1$$, $$f(2) = 2$$, $$f(3) = 3$$, $$f(4) = 4$$, $$f(5) = f(6) = f(7) = 5$$. You count this function three times:

$$\begin{array}{c | c} \text{designated ordered pairs} & \text{additional ordered pairs}\\ \hline (1, 1), (2, 2), (3, 3), (4, 4), (5, 5) & (6, 5), (7, 5)\\ (1, 1), (2, 2), (3, 3), (4, 4), (6, 5) & (5, 5), (7, 5)\\ (1, 1), (2, 2), (3, 3), (4, 4), (7, 5) & (5, 5), (6, 5)\\ \end{array}$$ where we have written $$(y, x)$$ if $$f(y) = x$$.

You count each surjective function that maps two elements of $$Y$$ to one element of $$X$$ and two other elements of $$Y$$ to a different element of $$X$$ four times, twice for each pair of elements of $$Y$$ that map to a single element of $$X$$.

For example, consider the surjective function $$f: Y \to X$$ defined by $$f(1) = 1$$, $$f(2) = 2$$, $$f(3) = 3$$, $$f(4) = f(6) = 4$$, $$f(5) = f(7) = 7$$. You count this function four times:

$$\begin{array}{c | c} \text{designated ordered pairs} & \text{additional ordered pairs}\\ \hline (1, 1), (2, 2), (3, 3), (4, 4), (5, 5) & (6, 4), (7, 5)\\ (1, 1), (2, 2), (3, 3), (6, 4), (5, 5) & (4, 4), (7, 5)\\ (1, 1), (2, 2), (3, 3), (4, 4), (7, 5) & (6, 4), (5, 5)\\ (1, 1), (2, 2), (3, 3), (6, 4), (7, 5) & (4, 4), (5, 5)\\ \end{array}$$

Surjective functions in which exactly three elements of $$Y$$ map to a single element of $$X$$: Choose which three of the seven elements of $$Y$$ map to a single element of $$X$$. Choose that element of $$X$$. Since the function is surjective, the remaining four elements must map to distinct elements from the remaining four elements of $$X$$. The number of such functions is $$\binom{7}{3}\binom{5}{1}4!$$
Surjective functions in which exactly two elements of $$Y$$ map to a single element of $$X$$ and exactly two other elements of $$Y$$ map to a different element of $$X$$: Choose which two of the five elements of $$X$$ are each the images of two elements of $$Y$$. Choose which two of the seven elements of $$Y$$ map to the smaller of these elements of $$X$$. Choose which two of the remaining five elements of $$Y$$ map to the larger of these elements of $$X$$. Since the function is surjective, the remaining three elements of $$Y$$ must map to distinct elements from the remaining three elements of $$X$$. The number of such functions is $$\binom{5}{2}\binom{7}{2}\binom{5}{2}3!$$
Total: Since the two cases above are mutually exclusive and exhaustive, the number of surjective functions from $$Y$$ to $$X$$ is $$\binom{7}{3}\binom{5}{1}4! + \binom{5}{2}\binom{7}{2}\binom{5}{2}3!$$