5

We can see that if $f(x)=g(x)=x$ then $f(g(x))=g(f(x))$.
I would like to see other examples of functions $f(x)$ and $g(x)$ such that $f(g(x))=g(f(x))$.

P.S. By definition we also must have $D_{f\circ g}= D_{g\circ f}$

lisyarus
  • 15,517

5 Answers5

7

Functions need not be inverses of each other to commute. A simple example. Let $f(x)=x+1$ and $g(x)=x+2$. Here, of course $$f(g(x))=g(f(x))=x+3.$$

4

Here is a family of examples: let $h$ be any function from a set to itself, and $n,m$ any positive integers. Then $f(x)=h^m(x),g(x)=h^n(x)$ (here superscripts denote functional power, so for example $h^3(x)=h(h(h(x)))$). Then clearly $f(g(x))=h^{m+n}(x)=g(f(x))$.

Wojowu
  • 26,600
  • If you generalise to $f^{-m} (x)=(f^{-1})^m (x)$, I think this encompasses all of the answers given so far. So the next natural question to ask is, "are these all the solutions?" – bilaterus Feb 20 '16 at 19:53
  • @bilaterus Certainly not. If you take $f(x)=x^\alpha,g(x)=x^\beta$ for some linearly independent $\alpha,\beta$, then I'd risk betting that $f,g$ aren't expressible as powers of fixed power $h$. – Wojowu Feb 20 '16 at 19:55
3

Take $f(x)=x+1$ and $g(x)=x-1$

$$f(g(x))=g(x)+1\\ =(x-1)+1\\ =x\\ \text{ and }\\ g(f(x))=f(x)-1\\ (x+1)-1\\ =x$$

3SAT
  • 7,512
  • $x^2$ and $\sqrt x$ are wrong – Konstantinos Gaitanas Feb 20 '16 at 18:40
  • You are not restricted to inverses: $f(x)=x+1$ and $g(x)=x+2$ also work – Henry Feb 20 '16 at 18:41
  • @KonstantinosGaitanas Let $f$ and $g$ be functions from $\mathbf{R}{\geqslant0}$ to $\mathbf{R}{\geqslant0}$, where $f:x\mapsto x^2$ and $g:x\mapsto\sqrt{x}$, then $f(g(x))=g(f(x))$, and your desired condition $\operatorname{dom}(f\circ g)=\operatorname{dom}(g\circ f)$ still holds. – Workaholic Feb 20 '16 at 18:43
1

I think if you take two inverse functions, defined over e.g. $\Bbb R$ (or over the same subset of $\Bbb R$),
then you trivially get the desired property, because $x = f(g(x)) = g(f(x))$.

Here is an example where the two functions are not inverse.

$f(x) = x^n$

$g(x) = x^m$

where $n$ and $m$ are e.g. integers

Also:

$f(x) = a \cdot x$

$g(x) = b \cdot x$

where $a$ and $b$ are e.g. reals

peter.petrov
  • 12,568
0

I'm not sure there's much to say.

There's $g= f^{-1}$ so $f (g (x)) = x $

Then there's $f = g $ so $f (g (x))e f (f (x)) $

Then there's $f (g (x)) = g (f (x)) = h (x)$ so $g (x) = f^{-1}(g(f (x))) = f^{-1}(h (x)) $ and/or $f (x)=g^{-1}(h (x))$.

As long as we can find invertible functions we can find these. Is there anything more that needs to be said?

fleablood
  • 124,253