# Composition of two functions is constant

Suppose $f$ and $g$ are such that $f(g(x)) = 1$. Does this imply that $g(f(x))$ is constant?

-
Although this is a question that doesn't require calculus, I think we can get some additional insight by applying the chain rule to $f(g(x))$ and $g(f(x))$. The chain rule tells us that the product of $f'$ and $g'$ is zero, which is the same condition regardless of the order of composition. One derivative or the other must be zero. This is why most functions you write down will satisfy the conjecture. The reason it can fail is that in the two cases, we could be sampling the derivatives in different regions of their domains. – Ben Crowell Oct 29 '12 at 20:33

NO.

$$f(x) = \begin{cases} 1 & x \geq 0 \\ 0 & x < 0 \end{cases}$$

$$g(x) = x^2, \,\,\, \forall x \in \mathbb{R}$$

We then have $$f(g(x)) = f(x^2) = 1, \,\,\,\, \forall x \in \mathbb{R}$$ whereas $$g(f(x)) = f(x)^2 = \begin{cases} 1 & x \geq 0 \\ 0 & x < 0 \end{cases}$$

-
Just nitpicking. $f(g(x)) = 0$ in your example. – Makoto Kato Oct 29 '12 at 19:53
@MakotoKato Yes. I was changing that. Thanks. – user17762 Oct 29 '12 at 19:53

No, $\forall x \in I$ and $I' = f^{-1}(1)$ \ $g(x)$ $$f(g(x)) = 1$$ $$f(g(f(x))) = 1$$ $$g(f(x)) \in f^{-1}(1) = g(x) \cup I'$$

-