Let $f: \mathbb{R} \to \mathbb{R}$ be continuous everywhere in $\mathbb{R}$ except on some finite set.
Suppose we also have $f^n(x) = x$ for all $x$ where $f$ is defined. Note that by $f^n(x)$ I mean the $n$th composition of $f$ with itself. Given a fixed $n$, how do you classify all solutions to this?
For $n=1,2$ this is easy enough.
But when $n=3$ we have for example, $f(x) = \frac{1}{1-x}$. It's not obvious how to find all the solutions to $f^3(x) = x$.
Here is the $n=2$ case, where already it's not so simple.
Consider the maximal open intervals on which $f$ is continuous and $f(x) \ne x$. Of these intervals, let $A_k$ be the ones on which $f(x) > x$ and $B_k$ the ones on which $f(x) < x$.
Note that if $f(x) > x$, $f(f(x)) = x < f(x)$. Thus $f$ must map each interval $A_j$ into an interval $B_k$, and then $B_k$ into $A_j$. Moreover, it's easy to see these maps must be 1-1 and onto.
On the other hand, consider any partition of $\mathbb R$ into finitely many intervals. The set of endpoints of these intervals may be mapped to itself by any permutation whose square is the identity (thus a product of disjoint transpositions). Let some of the open intervals be paired with others; on the unpaired intervals we just take $f(x)=x$. If interval $A$ is paired with interval $B$, let the restriction of $f$ to $A$ be any homeomorphism of $A$ to $B$, and the restriction to $B$ be the inverse of that homeomorphism. The result is a function $f$ such that $f^2(x)=x$, continuous except on the set of endpoints.