Is Inverse Function Composition Commutative? Given $f: \mathbb{R}\to(-1,1)$ is there a theorem that states
$f\left(f^{-1}(x)\right) = f^{-1}\left(f(x)\right)$. In example, is $\tanh{\left(\tanh^{-1}{(x^2)}\right)} =\tanh^{-1}{\left(\tanh(x^2)\right)} = x^2$ even though on the left hand side $\tanh^{-1}\left(x^2\right)$ does not exist for $|x| \geq 1$. Once again how can I prove this equivalence, or is there a theorem that states it.
 A: Actually, this is a definition. We say that function $f : X \rightarrow Y$ has an inverse iff there is a function $g : Y \rightarrow X$ such that 
$$\forall x \in X.g(f(x))=x \quad \forall y \in Y.f(g(y)) = y$$

It turns out that if $g$ exist, it is unique. So we denote it $f^{-1}$.

To see this, assume we have functions $g,g' : Y \rightarrow X$ satisfying the following.
$$\forall x \in X.g(f(x))=x \quad \forall y \in Y.f(g(y)) = y$$
$$\forall x \in X.g'(f(x))=x \quad \forall y \in Y.f(g'(y)) = y$$
Now prove that $g=g'$.

Also, it turns that $f^{-1}$ exists iff $f$ is a bijection (i.e. one-one and onto).

Now in the example you give, $X = \mathbb{R}$ and $Y = (-1,1)$. So for $\mathrm{tanh} : \mathbb{R} \rightarrow (-1,1)$ to have an inverse, we require that there exists a function $\mathrm{tanh}^{-1} : (-1,1) \rightarrow \mathbb{R}$ such that:
$$\forall x \in \mathbb{R}.\mathrm{tanh}^{-1}(\mathrm{tanh}(x))=x \quad \forall y \in (-1,1).\mathrm{tanh}(\mathrm{tanh}^{-1}(y)) = y$$
Hence, it follows that:
$$\forall y \in (-1,1).\mathrm{tanh}^{-1}(\mathrm{tanh}(y)) = \mathrm{tanh}(\mathrm{tanh}^{-1}(y))$$
But this does not hold with $y \in (-1,1)$ replaced by $y \in \mathbb{R}.$
A: When $f$ is both injective and surjective, we have 
$$f(f^{-1}(x))=x,x\in (-1,1)$$
and
$$f^{-1}(f(x))=x,x\in\mathbb{R}.$$
So even in this special case, the equality $f(f^{-1}(x))=f^{-1}(f(x))$ does not hold. For example, when $f$ is both injective and surjective, we have
$$f(f^{-1}(0))=0=f^{-1}(f(0)).$$
But $f(f^{-1}(2))$ doesn't defined and $f^{-1}(f(2))=2$.
When $f$ is both injective and surjective, and also its domain and range are same, the equality $f(f^{-1}(x))=f^{-1}(f(x))=x$ will be true.
A: The inverse function composition is commutative if and only if domain and codomain coincide. 
If $f:X\rightarrow Y$ has an inverse $g$ then automatically $g:Y\rightarrow X$. 
This with $f\circ g=id_Y$ and $g\circ f=id_X$ wich leads to: 
$$f\circ g=g\circ f\iff id_X=id_Y\iff X=Y$$
