Is this true?
Given $f,g\colon\mathbb R\to\mathbb R$. $f(g(x))=g(f(x))\iff f^{-1}(g^{-1}(x))=g^{-1}(f^{-1}(x))$.
I met this problem when dealing with a coding method, but I'm really not familiar with functions. Please help.
Thank you.
Is this true?
Given $f,g\colon\mathbb R\to\mathbb R$. $f(g(x))=g(f(x))\iff f^{-1}(g^{-1}(x))=g^{-1}(f^{-1}(x))$.
I met this problem when dealing with a coding method, but I'm really not familiar with functions. Please help.
Thank you.
Apply $g^{-1}\circ f^{-1}$ to the equation $f(g(x))=g(f(x))$. You'll obtain: $$g^{-1}\left(f^{-1}\left(f(g(x))\right)\right)=g^{-1}\left(f^{-1}\left(g(f(x))\right)\right)$$ In other words, we know that $x=g^{-1}\left(f^{-1}\left(g(f(x))\right)\right)$.
Now let $x=f^{-1}\left(g^{-1}(t)\right)$. You'll obtain: $$f^{-1}\left(g^{-1}(t)\right)=g^{-1}\left(f^{-1}\left(t\right)\right)$$ which is what you want.
Others have covered the case where $f$ and $g$ are invertible, and this may very well be the intended meaning of the original question. However, it's worth pointing out that the notation $f^{-1}(y)$ is also used even when $f$ is not injective. In general, suppose that $f:X\to Y$ and $A\subseteq Y$. Then $f^{-1}(A)$ is defined to be the set $\{x\in X:f(x)\in A\}$.
Then $f^{-1}(y)$ is defined to be $f^{-1}(\{y\})$, with the caution that $f^{-1}(y)$ is now a set, which may contain more than one element or which may be empty.
Now in this general setting the answer to the original question is still yes. Indeed if $f$ and $g$ both map $X\to X$ and $f\circ g(x)=g\circ f(x)$ for all $x\in X$ then \begin{eqnarray*}x\in f^{-1}\circ g^{-1}(y)&\Leftrightarrow& g\circ f(x)=y\\ &\Leftrightarrow& f\circ g(x)=y\\ &\Leftrightarrow& x\in g^{-1}\circ f^{-1}(y)\end{eqnarray*}
That is, $f^{-1}\circ g^{-1}(y)$ and $g^{-1}\circ f^{-1} (y)$ contain the same elements; in other words they are equal. It follows that $f^{-1}\circ g^{-1}(A)=g^{-1}\circ f^{-1}(A)$ for any $A\subseteq X$.
EDIT: Just saw the $\Leftrightarrow$ in the question; this answer just shows the $\Rightarrow$ implication.
Of course that is only true if $f^{-1}$ and $g^{-1}$ exist. But then, it's easy to show:
Be $y=f^{-1}(g^{-1}(x))$. Then obviously $g(f(y))=g(f(f^{-1}(g^{-1}(x)))) = g(g^{-1}(x)) = x$.
On the other hand, by assumption $f(g(y))=g(f(y))=x$. Therefore $g^{-1}(f^{-1}(x)) = g^{-1}(f^{-1}(f(g(y)))) = g^{-1}(g(y)) = y = f^{-1}(g^{-1}(x))$
As others have said, $f$ and $g$ must be invertible. Now recall the following identity:
For any invertible functions $f,g$, it follows that $(f \circ g)^{-1} = g^{-1} \circ f^{-1}$.
Hence, observe that: $$ \begin{align*} f \circ g=g \circ f &\iff (f \circ g)^{-1}=(g \circ f)^{-1} \\ &\iff g^{-1} \circ f^{-1}=f^{-1}\circ g^{-1} \\ &\iff f^{-1}\circ g^{-1} = g^{-1} \circ f^{-1} \\ \end{align*} $$ as desired.