When one is working with even roots care must be exercised
If \(\displaystyle f(x) = \sqrt {x - 2} ,\quad x \ge 2\) note the domain. Moreover, the range is \(\displaystyle f(x) \ge 0\).
Consider \(\displaystyle g(x) = x^2 + 2\).
Thus if \(\displaystyle f(x) \ge 0\) then \(\displaystyle \begin{eqnarray}
g(f(x)) & = & \left( {\sqrt {x - 2} } \right)^2 + 2 = x \\
f(g(x)) & = & \sqrt {\left( {x^2 + 2} \right) - 2} = \left| x \right| \\
\end{array}\).
Therefore we must say that the domain of g is \(\displaystyle x \ge 0\).
Having done that then \(\displaystyle g(x) = f^{ - 1} (x)\).