Let $D(\mathbb R) $ be the set of all differentiable functions $f: \mathbb R \to \mathbb R$. Then obviously $D(\mathbb R)$ forms a semigroup under usual function composition. Can we characterize (up to semigroup isomorphism) all finite subsemigroups of $D(\mathbb R)$ which do not contain any constant function ? 



Semigroup of differentiable functions on real line
**Yes, we can!** ;-)


In fact there are only **two** finite subsemigroups of $D(\mathbb{R})$ which do not contain constant functions.




---


Every finite subsemigroup of $D(\mathbb{R})$ necessarily contains an idempotent $f$, i.e. a function $f$ such that $f \circ f = f$. Let us examine the properties of $f$.


Let $A$ be the range of $f$. By continuity of $f$, $A$ is an interval. Since $f(f(x)) = f(x)$ for every $x \in \mathbb{R}$, we have $f(x) = x$ for $x \in A$.


If $f$ is non-constant, then $A$ has non-empty interior. We claim that in this case $A = \mathbb{R}$.


Suppose, contrary to this claim, that $A$ is bounded from above, and denote the right endpoint of $A$ by $b$. Then $f(b) = \lim\_{x \to b^-} f(x) = \lim\_{x \to b^-} x = b$, and so $b \in A$. Thus, $f$ attains a local maximum at $b$. Since $f$ is differentiable at $b$, we have $f'(b) = 0$. On the other hand, $f'\_-(b) = \lim\_{x \to b^-} f'(x) = 1$, a contradiction. We conclude that $A$ is not bounded from above. Similarly, $A$ is unbounded from below.


Thus, either $f$ is constant or $f$ is the identity function. It follows that any finite subsemigroup of $D(\mathbb{R})$ contains either a constant function or the identity function.




---


Suppose that $X$ is a finite subsemigroup of $D(\mathbb{R})$ with no constant function and $g \in X$. Then the subsemigroup of $X$ generated by $g$ contains an idempotent, and hence — the identity function. In other words, $g^{\circ n}$ is the identity function for some $n$.


Todd Trimble already pointed out in his answer that necessarily $n = 1$ or $n = 2$, and if $n = 2$, then $g$ is decreasing. Here is a shorter variant of his argument that does not require differentiability:


1. $g$ is invertible and continuous, and hence strictly monotone; $g \circ g$ is thus strictly increasing;
2. if $g(g(x)) > x$ for some $x$, then $g^{\circ 2n}(x) > x$, a contradiction; similarly, if $g(g(x)) < x$ for some $x$, then $g^{\circ 2n}(x) < x$; therefore, $g(g(x)) = x$ for all $x$;
3. if $g$ is increasing, then in a similar way $g(x) = x$ for all $x$.


Finally, if $g, h \in X$ and none of them is the identity function, then both are decreasing, and so $g \circ h$ is an increasing function in $X$. Therefore, $g \circ h$ is the identity function, and consequently $g = h^-1 = h$.




---


We have thus proved that that any discrete subsemigroup of $D(\mathbb{R})$ with no constant function contains the identity function and at most one strictly decreasing function $g$ such that $g = g^{-1}$.


