Show that $\displaystyle f\left(g^{-1}(x)\right)=g\left(f^{-1}(x)\right) \Leftrightarrow f^{-1}\left(g(x)\right)=g^{-1}\left(f(x)\right)$

If we substitute $\displaystyle x=f(u)$, we get

$\displaystyle f\left(g^{-1}\left(f(u)\right)\right)=g^{-1}\left(f\left(f^{-1}(u)\right)\right)$

$\displaystyle \Updownarrow$

$\displaystyle f\left(g^{-1}\left(f(u)\right)\right)=g(u)$

This means that $\displaystyle g^{-1}\left(f(u)\right)=f^{-1}\left(g(u)\right)$, because $\displaystyle f\left(f^{-1}\left(g(u)\right)\right)=g(u)$.

Now, if the above equality holds for $\displaystyle u$, it must also hold for $\displaystyle x$, and we have that

$\displaystyle g^{-1}\left(f(x)\right)=f^{-1}\left(g(x)\right)$

and that

$\displaystyle f\left(g^{-1}(x)\right)=g\left(f^{-1}(x)\right) \Leftrightarrow f^{-1}\left(g(x)\right)=g^{-1}\left(f(x)\right)$

Which was to be shown.

Does this hold, or have I overlooked something?

Thanks in advance.