TITLE: If $f(f(x))=x$ does that mean $f(x)$ equals its inverse?
QUESTION [6 upvotes]: Given any real function, if $f(f(x))=x$ does that mean $f(x)$ is its own inverse? I am confused since $f^{-1}(f(x))=x$ and this is a fact, so can we assume that $f(x)$ will equal $f^{-1}(x)$ by substitution? Specify if possible if it is never, sometimes, or always true.

REPLY [5 votes]: Let $f:A\rightarrow A$ with $f\circ f=1_A$ (The identity in $A$)
If $f$ is not surjective then $f\circ f$ is not surjective and if $f$ is not injective $f\circ f$ is not injective.
Hence if $f\circ f$ is bijective then $f$ is bijective. $f$ must therefore have an inverse $f^{-1}$. Using this we obtain the following:
$f\circ f=1_a\implies f^{-1}\circ f\circ f=f^{-1}\circ 1_A\implies 1_A\circ f=f^{-1}\implies f= f^{-1}$