According this site, 2 functions $f$ and $g$ are the inverse function of each other, only if both $(f \circ g) (x) = x$ and $(g \circ f) (x) = x$ are true.
Is it really necessary to prove both of them? Can someone please provide an counter example where one is satisfied and the other is not?
Edit: what if given $f$ and $g$ have the same domain?
Edit2: what if $f$ and $g$ are both monotonic?
Try $f(x) = x^2$ and $g(x) = \sqrt{x}$. Then $(f \circ g)(x) = x$, but $(g \circ f)(-1) \neq -1$.
EDIT: If you want $f$ and $g$ to have the same domain, let $$f(x) = \left\lbrace \begin{array}{rcl}(x + 1)^3 & : & x \le -1 \\ (x - 1)^3 & : & x \ge 1 \\ 0 & : & -1 < x < 1 \end{array} \right.$$ Notice that $f$ definitely is not invertible, since it isn't one-to-one. Also let $$g(x) = \left\lbrace \begin{array}{rcl}\sqrt[3]{x}-1 & : & x < 0 \\ \sqrt[3]{x}+1 & : & x \ge 0 \end{array} \right.$$ Both functions have a domain of $\mathbb{R}$. Now, I claim that $(f \circ g)(x) = x$ for any $x$. We have two possibilities: $x \ge 0$ and $x < 0$. If $x \ge 0$, then $g(x) = \sqrt[3]{x} + 1 \ge 1$, so $$(f \circ g)(x) = f(\sqrt[3]{x} + 1) = (\sqrt[3]{x} + 1 - 1)^3 = x.$$ On the other hand, if $x < 0$, then $g(x) = \sqrt[3]{x} - 1 < -1$, so $$(f \circ g)(x) = f(\sqrt[3]{x} - 1) = (\sqrt[3]{x} - 1 + 1)^3 = x.$$ On the other hand, we cannot have $(g \circ f)(x) = x$, otherwise $f$ would be invertible and hence injective. Specifically, we can compute $$(g \circ f)(1/2) = g(0) = 1 \neq 1/2.$$
EDIT2: Free bonus! Both $f$ and $g$ are monotonic!