Example of $f,g:\mathbb{R}\to\mathbb{R}$ such that $f\circ g$ is bijective but $g\circ f$ is not bijective

examples-counterexamplesfunction-and-relation-compositionfunctions

I am seeking functions $f:\mathbb{R}\to\mathbb{R}$ and $g:\mathbb{R}\to\mathbb{R}$ such that $f\circ g$ is a bijection and $g\circ f$ is not a bijection.

Here is what I have done so far in terms of gathering clues:

  • If $f\circ g$ is bijective, then it is both injective and surjective
    by definition, which makes it necessary that $g$ is injective and $f$
    is surjective.
  • If $g\circ f$ is not a bijection, then it is necessary
    that $f$ is not a bijection or $g$ is not a bijection (since the
    composition of bijections is a bijection). Combined with the previous bullet point, it means that $f$ is not an injection or $g$ is not a surjection.

An example of $f$ that is surjective but not injective is $x^3-x$, and an example of $g$ that is injective but not surjective is $2^x$. These $f$ and $g$ don't seem to help in this case though.

Could someone provide examples of suitable functions $f$ and $g$? I have also checked the classic books Counterexamples in Topology and Counterexamples in Analysis without any progress.

Best Answer

Pick any injective, non-surjective $g$. Make sure that $f$ is an inverse of $g$ on the range of $g$. That's all you need.

For instance: $$ g(x)=e^x\\ f(x)=\cases{\ln(x)& if $x>0$\\0 & otherwise} $$