TITLE: Cardinality of the set of functions commuting with $f:X\to X$
QUESTION [13 upvotes]: If $X$ is an infinite set and $f:X\to X$, do we have $$\big|\{g:X\to X: g\circ f =f \circ g\}\big|\geq |X| ?$$

REPLY [2 votes]: This isn't a proof for the question itself, but a demonstration that you don't need to assume $X$ infinite. From now on, assume $X$ finite.
Assume $X$ connected, that is, $\forall x, y \exists m, n f^m(x) = f^n(y)$. By the pigeonhole principle, we have some $j \neq k$ with $f^j = f^k$, so eventually $\text{Im} f^i$ is constant. Let $X_0$ be that image. 
Claim 1: $X_0$ is a loop. In other words, $\forall x, x' \in X_0 \exists n f^n(x) = x'$
Proof: As $X_0$ is the eventually constant image, we have that $f(X_0) = X_0$, so $f|_{X_0}$ is a bijection. Therefore, there is some $N$ with $f^N|_{X_0} = \text{Id}|_{X_0}$. Combining this with connectedness gives the claim. 
Inductively let $X_i = f^{-1}(X_{i - 1})$. By the definition of $X_0$, we have that $X = \cup X_i$. Then there is a smallest $i_0$ with $X_{i_0} = X$. Choose $x_i \in X\backslash X_{i_0 - 1}$.
Claim 2: For any $y \in X$, let $m_y$ be the smallest integer such that there is some $n$ with $f^{m_y}(y) = f^n(x_0)$. Then $n \geq m_y$ for all such $n$.
Proof: Assume $m_y > n$. For some smallest $j$, we have $f^n(x) \in X_j$. Then $x_0 \in X_{j + n}$. By the definition of $x_0$, we must also have that $y \in X_{j + n}$, so $f^n(y) \in X_j$. But as $m_y > n$, we must have that $f^{m_y}(y) \in X_{j - 1}$ or that $j = 0$. By the assumption that $j$ is the smallest, we must have that $j = 0$, so $f^n(y) \in X_0$. But then there is some $n'$ such that $f^{n'}(x) = f^n(y)$, by claim 1, which contradicts the assumption. Therefore, the current claim is proved. 
Claim 3: For any $z \in X$, there is a map $g: X \rightarrow X$ such that $g_z \circ f = f \circ g_z, g_z(x_0) = z$.
Proof: For $y \in X$, define $n_y$ as the smallest integer such that $f^{m_y}(y) = f^{n_y}(x_0)$, and define $\iota_{x_0}(y) = n_y - m_y$. By claim 2, $\iota_{x_0}(y) \geq 0$. Then for $z \in X$, define $g_z(y) = f^{\iota_{x_0}}(z)(x_0)$. For $y = x_0$, we have $m_y = n_y = 0$, so $g_z(x_0) = z$. 
I claim that $g_z \circ f = f \circ g_z$. 
If $m_y \neq 0$, then $m_{f(y)} = m_y - 1, n_{f(y)} = n_y$. We therefore only need to check the case where $m_y = 0$. 
If $m_y = 0$, then $y = f^{n_y}(x_0)$, so $f(y) = f^{n_y + 1}(x_0)$. If $n_{f(y)} = n_y + 1$, this is clear: $g_z(f(y)) = f^{n_y + 1}(z) = f(f^{n_y}(z)) = f(g_z(y))$, so we only need to check for $y$ such that $n_{f(y)} \neq n_y + 1$.
It's clear that this can only happen if $f(y) = f^i(x_0)$, recalling that $i$ is the smallest number such that $X_i = X$, and if $y \in X_0$ is the element that precedes it in the "loop". Then $y = f^{p - 1}(f(y))$, where $p$ is the length of the loop. But then $g(y) = f^{i + p - 1}(z)$, so $f(g(y)) = f^p(f^i(z)) = f^i(z) = g(f(y))$ by the definition of $i$ and the loop. So we are done.
Now consider $X$ not connected. We proceed by induction. Let $Y$ be a component of $X$, and $X'$ the rest of $X$. Assume $Y$ consists of a single element $\{y\}, f(y) = y$. Then we know that $|\{g: X' \rightarrow X'|g \circ f = f \circ g\} \geq |X'|$. For each such $g$, we can construct $g': X \rightarrow X$ such that $g'|_{X'} = g, g'(y) = y$; by inspection, this commutes with $y$. We also have the constant map $g_0: g_0(x) = y$. This gives us enough distinct maps that commute with $f$.
Assume neither $Y$ nor $X'$ consists of a single element. Then $\{g: X \rightarrow X|g \circ f = f \circ g\} \supset \{g_1: X' \rightarrow X', g_2: Y \rightarrow Y| g_1 \circ f = f \circ g_1, g_2 \circ f = f \circ g_2\}$, so by induction, $|\{g: X \rightarrow X|g \circ f = f \circ g\}| \geq |\{g: X' \rightarrow X'|g \circ f = f \circ g\}| |\{g: Y \rightarrow Y|g \circ f = f \circ g\}| \geq |X'||Y| \geq |X'| + |Y| = |X|$.
Edit: To picture this, define by a "lasso" a finite set $L = \{f^n(x)\}$. Lassos are characterized by two numbers: the length of the loop, and the length of the "rope" before the loop. Effectively, this proof "collapses" $X$ to the lasso with the longest rope, then shows that for any $i, i', j, j'$ such that $j'|j, i' \leq i$ there is a "lasso map" $L_{ij} \rightarrow L_{i'j'}$.