Let $X$ be a set consisting of 5 elements. Let $$A = \{f : X \to X; f(f(x)) = x, \forall x \in X\}.$$ Compute the number of elements of $A$.
To count the number of functions in $A$, we can use the following method:
Pick an element $x$ in $X$. There are $5$ choices for $f(x)$ (it can be any of the $5$ elements in $X$). Once $f(x)$ is chosen, we know that $f(f(x)) = x$, so there are only two choices for $f(f(x))$: it can either be x $(if f(x) = x)$ or one of the $4$ remaining elements in $X$ (if $f(x)$ is one of the other $4$ elements in X)$.
Let's consider the two cases separately:
Case $1: f(x) = x$ In this case, we know that $f(f(x)) = x$, so $f(x)$ must be one of the fixed points of the function (i.e., one of the elements in $X$ that satisfies $f(x) = x)$. There are $5$ choices for $x$ and once $x$ is chosen, there are $4$ choices for $f(f(x))$ (it can be any of the $4$ remaining elements in $X$). For the remaining $3$ elements in $X$, there are $4$ choices for each element, since each element can be mapped to any of the $4$ remaining elements in X. Therefore, there are $5 * 4 * 4 * 4 = 320$ functions in $A$ that have a fixed point.
Case 2: $f(x) ≠ x$ In this case, we know that $f(f(x)) ≠ x$, so $f(f(x))$ must be one of the $3$ remaining elements in $X$ (since $f(x)$ cannot be one of the $2$ elements that are already determined). There are $5$ choices for $x$, and once $x$ is chosen, there are $4$ choices for $f(x)$ (it can be any of the $4$ remaining elements in $X)$. Then there are $3$ choices for $f(f(x))$, and $3$ choices for $f(f(f(x)))$, since f(f(x)) cannot be $x$ or $f(x)$. For the remaining element in $X$, there are $4$ choices for where to map it. Therefore, there are $5 * 4 * 3 * 3 * 4 = 720$ functions in $A$ that do not have a fixed point.
Putting the two cases together, we see that the total number of functions in $A$ is $320 + 720 = 1040$. Therefore, there are $1040$ functions in $A$ that satisfy the condition $f(f(x)) = x$ for each $x ∈ X$.
Right?
$\times$for $\times$. – Shaun May 11 '23 at 19:32