Functions that are their own inversion.

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 > 0$)

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

Solutions Collecting From Web of "Functions that are their own inversion."

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>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 & b \\ c & 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&1\\1&-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)$.

There are in fact many involutions. But if you want an involution that is rational function and is involutory on a dense subset of $\mathbb R$, then you end up with Möbius transforms $f(x)=\frac{ax+b}{cx+d}$ where $\begin{pmatrix}a&b\\c&d\end{pmatrix}^2=1$ (and the domain of $f$ is $\mathbb R\setminus\{-\frac dc\}$). Your first four examples correspond to the matrices
Your fifth example is really a transformation of the Möbius transform $f(x)=\frac{x+1}{x-1}$ obtained from the matrix $-\frac12\begin{pmatrix}1&1\\1&-1\end{pmatrix}$. Of course, whenever $f\colon D\to D$ is an involution and $g\colon D’\to D$ a bijection, then $g’^{-1}\circ f\circ g\colon D’\to D’$ is also an involution. (In this special case we need to verify that $x\mapsto \frac{x+1}{x-1}$ maps $(1,\infty)\to(1,\infty)$)

Why would you think those are the only functions possible? If we consider discrete functions rather than only explicit, algebraically defined, functions, then it’s easy to come up with examples (obviously we need to ensure that our functions are bijective–but this has more to do with defining proper domain and range sets). The simplest example is a function which maps from a singleton set to the same singleton set (which means $f(x) = x$ is the only possible function anyway). It’s trivial to come up with examples of functions which are their own inverse with sets of size two (and they no longer have to have the form $f(x) = x$–which certainly always satisfies this property). For example:

\{a_1, a_2\}\mapsto \{a_1, a_2\}: f(x) = \begin{cases} a_2 & x = a_1 \\
a_1 & x = a_2

Or we can do a set with three items:

\{a_1, a_2, a_3\}\mapsto \{a_1, a_2, a_3\}: f(x) = \begin{cases} a_2 & x = a_1 \\
a_1 & x = a_2 \\
a_3 & x = a_3

…or four:

\{a_1, a_2, a_3, a_4\}\mapsto \{a_1, a_2, a_3, a_4\}: f(x) = \begin{cases} a_3 & x = a_1 \\
a_4 & x = a_2 \\
a_1 & x = a_3 \\
a_2 & x = a_4

…etc. Now it may be “difficult” to come up with functions defined through algebraic operations that satisfy this condition over a continuous domain (like $\mathbb{R}$) but I don’t see why one would assume there are a finite number of them a priori.

And David Quinn and Maciek raise a good point–which is that any function which is symmetric about the line $y = x$ is an inverse of itself. Just because you may not be able to “write down”, algebraically, such a function doesn’t mean one doesn’t exist. Here’s an example graph from a function which is its own inverse:

enter image description here

And you can create all sorts of different looking such functions by just drawing some curve (it must pass the horizontal line test) and reflecting it by the line $y = x$ (which is how I generated the above example).

Any rectangular hyperbolas of the form $$f(x)=\frac{ax+b}{x-a}$$ are self-inverse since they are reflections of themselves in the line $y=x$.

For algebraic solutions, take $f(x,y) = 0$ for any nonconstant symmetric polynomial (on an appropriate domain). Of course, if the degree in $x$ or $y$ is greater than $5$, this may not be solvable by radicals.

For example, $f(x,y) = x^3 + x y + y^3 – 1$. This one can be solved by radicals:
$$ y = \dfrac{\sqrt [3]{108-108\,{x}^{3}+12\,\sqrt {81\,{x}^{6}-150\,{x}^{3}+81
}}}{6}-{\frac {2x}{\sqrt [3]{108-108\,{x}^{3}+12\,\sqrt {81\,{x}^{6}-150