Functions that are their own inverse. What are the functions that are their own inverse?

(thus functions where $ f(f(x)) = x $ for a large domain)

I always thought there were only 4:

$f(x) = x , f(x) = -x , f(x) = \frac {1}{x} $ and $ f(x) = \frac {-1}{x} $ 

Later I heard about a fifth one   

$$f(x) = \ln\left(\frac {e^x+1}{e^x-1}\right) $$ (for $x &gt; 0$)

This made me wonder are there more? What are conditions that apply to all these functions to get more, etc.
These are called involutions.

If you don't require continuity, then the set of involutions $\Bbb R\to\Bbb R$ corresponds to the set of ways to partition $\Bbb R$ into at most $2$-element subsets. This train of thought follows from thinking about the cycle decomposition of an involution, considered as a permutation of an infinite set. 

This is massively infinite, with $2^{\frak c}$-many elements, where ${\frak c}=|\Bbb R|$. Indeed, if we take for granted the fact that every infinite set has a decomposition into $2$-sets, or equivalently every infinite set has a fixed-point-free involution (which I am sure follows from some level of choice), then a lower bound for the number of involutions would be the number of coinfinite subsets of $\Bbb R$ chosen to be the fixed-point sets, and a lower bound for the number of coinfinite subsets is the number of subsets of say $\Bbb R\setminus[0,1]$ of which there are $2^{\frak c}$. An upper bound is given by the number of functions $\Bbb R\to\Bbb R$, which is also $2^{\frak c}$ - see here.

If you do require continuity there are ${\frak c}=|\Bbb R|$-many continuous involutions. As an upper bound, there are $\frak c$ continuous real-valued functions - see here. As a lower bound, $\log_a\left(\frac{a^x+1}{a^x-1}\right)$ is a distinct continuous involution for every $a&gt;0$, of which there are $\frak c$-many.

To see where these ideas are coming from, we employ two ideas: conjugation from group theory and linear fractional transformations from complex analysis. Given any involution $\sigma$ and any homeomorphism $f:\Bbb R\to\Bbb R$ (continuous function with continuous inverse) there is a conjugate function $f\circ\sigma\circ f^{-1}$ which is also an involution. Of course, this can still equal $\sigma$ in general.

A linear fractional transformation is a map $[\begin{smallmatrix} a &amp; b \\ c &amp; d\end{smallmatrix}]z:=\frac{az+b}{cz+d}$. This creates a group action of the group of invertible matrices. That is, if $A$ and $B$ are matrices, then $A(Bz)=(AB)z$ in this notation, where $AB$ is the product of $A$ and $B$. Usually we have them acting on the complex plane or the Riemann sphere (or the upper half plane in hyperbolic geometry), but we can certainly consider matrices with real coefficients acting on the real number line $\Bbb R$. Note that scalar multiples of the identity matrix act as the identity function.

Note $[\begin{smallmatrix}1&amp;1\\1&amp;-1\end{smallmatrix}]^2$ is proportional to the identity matrix, and conjugating the corresponding linear fractional transformation $\frac{u+1}{u-1}$ by $a^x$ yields the aforementioned family of examples. Technically $a^x$ is a homeomorphism $\Bbb R\to(0,\infty)$, but this is fine since $\frac{u+1}{u-1}$ is well-defined on $(0,\infty)$.
I'll give you an example of a nonlinear involution, that is a transcendental function, and a composition of $e^x$ and $\frac{1}{\log(x)}.$ Composing one way gives $1/x$ (an involution) and composing the other way gives a different involution, whose reciprocal is an involution, and whose fixed points are reciprocals of one another: $f(x)=\exp(\frac{1}{\log(x)}).$