Miscellaneous · Q4: Number of onto functions from to itself
Find the number of all onto functions from the set to itself.
Let and .
If is onto, the values cover all elements of , so no two are equal: is one-one. If is one-one, the values are distinct, so they fill : is onto.
So the onto functions are exactly the one-one functions. Choosing in turn, with no value repeated, there are choices. So the number of such functions is
The number of onto functions is .
Want the reason behind every step, the basics and the checks?
When a function goes from a finite set to itself, "onto" and "one-one" are the same condition. There are inputs and targets: to hit all targets, the outputs must all be different, and different outputs automatically hit every target. So counting onto functions is the same as counting one-one functions, that is, arrangements of , and the multiplication principle gives .
- Given
- The set , with elements, used both as domain and as codomain.
- To find
- How many functions are onto.
- Plan
- (1) Describe a function by its list of values. (2) Prove onto one-one, and (3) one-one onto, so the two sets of functions are identical. (4) Count one-one functions by making the choices in turn, and show every such function is counted exactly once. (5) Conclude and check with small .
Basics you need
A function assigns to each input exactly one output. On it is completely described by the list , and two functions are equal exactly when their lists agree in every position. Basics: what a function is
One-one: different inputs give different outputs. Onto: every element of the codomain is an output, that is, the range equals the codomain. Basics: one-one and onto
If a task is done in stages, with ways for the first stage, then ways for the second whatever the first choice was, and so on, the number of ways to do the whole task is . Basics: counting choices
. For example , , . It counts the arrangements (permutations) of different objects.
Solution
Write each function as a list of values
By Basic 1, a function is the same thing as a list in which each entry is one of . For instance, with , the list means , , . In this language:
- the range of is the set of numbers appearing in the list;
- is onto when every number appears in the list;
- is one-one when no number appears twice.
For , the list is a function that is neither: 1 appears twice and 3 never appears.
Lists are much easier to count than "rules". Each function gives exactly one list and each list gives exactly one function, so counting functions with a property is the same as counting lists with the matching property.Onto forces one-one
Let be onto. Then the range is all of , so it has exactly elements. Suppose, for contradiction, that two different inputs had the same output, say with . Then the list of values contains a repeat, so it has at most different values, and the range has at most elements. That contradicts "the range has elements". So no two inputs share an output: is one-one.
This is the textbook's Example 13 argument (done there for ) written for a general . The key is counting: a list of entries with a repeat cannot show all numbers. We argue by contradiction because "one-one" is a statement about every pair of inputs, and assuming a single failing pair leads straight to a count that is too small.A list of entries has at most different values, and fewer if any value repeats (the pigeonhole idea). See Example 13 for the case .One-one forces onto
Let be one-one. Then the values are all different, so the range is a subset of with elements. But itself has only elements, and the only subset of with elements is . So the range is : is onto.
Together with Step 2: for ,
So the onto functions are exactly the one-one functions, and we may count those instead.
Step 3 is not needed to get an upper bound, but it is needed for an exact count: it shows that every one-one function is onto, so when we count one-one functions in Step 4 we are counting onto functions and nothing else. This is the Remark after Examples 13 and 14: for a finite set the two properties coincide. For an infinite set they do not; on is one-one but not onto (Example 8).A subset of a finite set with as many elements as the whole set is the whole set. See Example 14 for .Count the one-one functions, one value at a time
Build a one-one function by choosing its values in order, never reusing a value already taken:
Stage Values already used Number of choices choose none choose choose choose values choose values By the multiplication principle the number of one-one functions is
The choice tree for . Each level fixes one value; the number of branches drops by one at each level because a value already used may not be used again. The 6 complete paths are the 6 onto functions, written as . Why every function is counted exactly once. Each complete path through the tree is a list of different values, which is a one-one function. Conversely, every one-one function appears: at stage its value differs from , so it is one of the allowed choices, and following its values picks out one path. Two different paths differ at some stage , so they give different values and therefore different functions. Hence paths and one-one functions match one-to-one, and the count has no omissions and no repeats.
The multiplication principle needs the number of choices at each stage to be the same whatever happened earlier. That is true here: at stage , exactly values are used up (they are all different), so exactly remain, no matter which ones were used. The textbook makes the same count for in Example 22, where it calls these functions permutations of the symbols 1, 2, 3.Multiplication principle (Basic 3). The arrangements of are the permutations. Basics: counting choicesConclude
By Steps 2 and 3, the onto functions from to itself are exactly the one-one functions, and by Step 4 there are of these. So the number of onto functions is .
The answer is a count of one-one functions, but it is the answer to the question about onto functions only because Steps 2 and 3 showed the two collections are identical. Both directions were needed.On a finite set, is one-one if and only if it is onto (the chapter Summary). Lesson: counting functions and relations
The number of onto functions from to itself is . On a finite set, onto and one-one coincide, so these are the one-one functions, chosen as ways for , for , and so on down to 1 way for . (Textbook answer: .)
For there are functions in all (3 choices for each of 3 values, with repeats allowed). Listing all 27 and keeping those in which 1, 2 and 3 all appear leaves exactly the 6 lists , , , , , , and ✓. The other 21, such as , each miss at least one value. The site's verification script repeats this brute force for every from 1 to 6 (up to functions) and finds onto functions, which are , and in each case the onto functions are exactly the one-one ones.
- Answering . That counts all functions from to , including the many that repeat a value and miss another.
- Counting with choices at every stage. After is chosen, it may not be reused, so the next stage has choices, not .
- Using the "onto = one-one" shortcut for infinite sets. It holds only because is finite and the function maps to itself. On , Examples 8 and 10 show it fails both ways.
- Proving only one direction. To replace "onto" by "one-one" in the count, both onto one-one and one-one onto are needed.
- For with finite: one-one onto bijective.
- Count functions by choosing their values one input at a time; the multiplication principle does the rest.
- Every count should come with a reason that nothing is missed and nothing is counted twice. Here that reason is the match between paths in the choice tree and one-one functions.
Every fact used, and where it comes from
| Fact | Used in | Source |
|---|---|---|
| One-one, onto, bijective; onto range = codomain | Steps 1–3 | Definitions 5–7 and the Remark after Definition 6, Section 1.3 (Lesson: types of functions) |
| Onto one-one and one-one onto on a finite set | Steps 2, 3 | Examples 13, 14 and the Remark after them, Section 1.3; chapter Summary |
| on is one-one but not onto | Step 3 | Example 8, Section 1.3 |
| Multiplication principle; | Step 4 | Class XI, Permutations and Combinations (Basics: counting choices) |
| One-one maps of are the permutations | Step 4, Check | Example 22, Miscellaneous Examples |
| Counts by enumerating all functions | Check | Brute force in the site's verification script |
Tell us if something on this page is wrong or unclear, or if you would like a fuller explanation, another method or a new feature. Send feedback on this problem →