I was curious whether functions that have an inverse are more or less common than functions that don't. My intuition tells me there are more functions without an inverse.
1 Answers
For finite sets, we can just compute it. If there are few elements in the domain and many in the range, the chances of a collision are small and most functions will be invertible. If there are $n$ elements in the domain and $m$ in the range, there are $m^n$ functions in total. Of these $\frac {m!}{(m-n)!}$ are invertible because there are $m$ choices for where to send the first element, $m-1$ choices for the second, and so on until $m-n+1$ for the last. If $n=3$ you need $m=6$ to have more functions invertible than not. If $n=5$ you need $m=18$ and so on. If there are $n$ elements in both the domain and range, Stirling's approximation says that about $e^{-n}\sqrt{2 \pi n}$ of the functions are invertible, which quickly becomes very small with $n$.
If both sets are infinite you need to define what you mean by more. Cardinality is too coarse a tool to tell the difference. There are $\mathfrak{c^c}$ functions from $\Bbb R$ to $\Bbb R$ and the same quantity of invertible ones. Intuitively, invertible functions are rare, but I don't know how to define a measure on this space that shows it.
- 374,822
-
Thanks, this is very helpful! I guess maybe what I want is "the likelihood that, given a problem, a solution has an inverse", in order to make an argument about the likelihood of some solution space being dominated by functions with/without inverses after many generations of running a genetic algorithm. – Ziggy Mar 14 '20 at 16:29