# In which cases are $(f\circ g)(x) = (g\circ f)(x)$?

I have found three cases:

1) If $f$ and $g$ are the same function.

2) If $f$ and $g$ are mutually inverse.

3) If both are polynomials of degree $1$

Maybe there are more.

• Polynomials of degree $1$ don't generally commute. Take for example $x+1$ and $2x$. Feb 8, 2016 at 0:53
• Use $(f\circ g)(x)$ to show $(f\circ g)(x)$. Formatting tips here.
– Em.
Feb 8, 2016 at 0:55
• Or, for instance, any functions where $f$ is $\alpha$ on $\text{im}\,g$ and $g$ is $\alpha$ on $\text{im}\, f$. This is not hard to construct.
– jcg
Feb 8, 2016 at 0:59
• Another interesting example is that this is true whenever $g=f\circ f$. Feb 8, 2016 at 1:01
• Feb 8, 2016 at 1:26

If $X = \{w, x, y, z\}$ is an arbitrary set of four elements, the permutations $$f = (w\ x)(y\ z),\qquad g = (w\ y)(x\ z)$$ commute. In words, $f$ exchanges $w$, $x$ and $y$, $z$, while $g$ exchanges $w$, $y$ and $x$, $z$. Together, $f$ and $g$ generate a Klein $4$-group under composition. (Pleasant observation: If the elements of $X$ are placed at the corners of a rectangle and arrows are drawn to create a commutative diagram, the actions of $f$ and $g$ coincide with Euclidean symmetries of the rectangle, i.e., with the customary representation of the Klein $4$-group as symmetries of a rectangle.)

Now, let $X$ be an arbitrary set that can be partitioned into quadruples (e.g., a finite set of $4n$ elements for some positive integer $n$, or a countably infinite set, or the set of real or complex numbers). Partition $X$ arbitrarily into quadruples, define $f$ and $g$ as above on each quadruple, and note that $f$ and $g$ commute under composition. This by no means exhausts all possibilities. At the same time, the vastness of the number of ways this can be done should suggest how hopeless it is to "classify" all commuting real-valued functions of one real variable.