A question about composition of functions If   $f(x)=g(h(x))$,  why is $f^{-1}(x)=h^{-1}(g^{-1}(x))$ ?
 A: Think about dressing your feet.  Here are the instructions


*

*Put on socks

*Put on shoes


What is the reverse of this operation?


*

*Remove shoes

*Remove socks.


You must undo the operations in the reverse order in which you did them.
Now think about f(g(x)):  first apply g to x then f.....
A: What gets done last gets undone first.  Thus:
$$
\begin{array}{c}
\text{input} & \mapsto & \text{multiply by }5 & \mapsto& \text{add }2 \\[10pt]
x & \mapsto & 5x & \mapsto & 5x+2 = y
\end{array}
$$
The inverse is:
$$
\begin{array}{c}
\text{input} & \mapsto & \text{subtract }2 & \mapsto & \text{divide by }5 \\[10pt]
y & \mapsto & y-2 & \mapsto & \frac{y-2}{5}
\end{array}
$$
A: By definition, $f^{-1}$ is the function with the following properties: for each $x$ in the domain of $f$, $f^{-1}(f(x))=x$, and for each $x$ in the range of $f$, $f(f^{-1}(x))=x$. In other words, $f^{-1}$ undoes the effects of $f$, and $f$ undoes the effects of $f^{-1}$.
If $f(x)=g(h(x))$, then in order to undo the effects of $f$ you have to undo those of $g$ to get at $h(x)$, and then you have to undo those of $h$ to get at $x$. In other words, you must first apply $g^{-1}$ to $f(x)$, and then you must apply $g^{-1}$ to the result. This is actually easier to follow in symbols than in words:
$$\begin{align*}
h^{-1}\Big(g^{-1}\big(f(x)\big)\Big)&=h^{-1}\left(g^{-1}\Big(g\big(h(x)\big)\Big)\right)\\
&\overset{(*)}=h^{-1}\big(h(x)\big)\\
&=x\;.
\end{align*}$$
The starred step makes use of the fact that $g^{-1}\big(g(u)\big)=u$ no matter what $u$ is, provided that it’s in the domain of $g$.
The calculation showing that $g\left(h\Big(h^{-1}\big(g^{-1}(x)\big)\Big)\right)=x$ is entirely similar.
A: If you take each function as a transformation, $g(h(x))$ means first apply the transformation described by $h(x)$ to $x$, then apply the transformation described by $g(x)$ to the result of that.
Therefore, in order to get the  original image from the result of these transformations, we first undo the latest transformation (in this case $g(x)$), and then undo the transformation described by $h(x)$.
Therefore, we have $f^{-1}(x)=h^{-1}(g^{-1}(x))$.
