Non trivial solutions of $g\circ f-f\circ g=g\circ f\circ g$ While thinking of perfect numbers, I came across the functional equation $g\circ f-f\circ g=g\circ f\circ g$ where the unknowns $f$ and $g$ are functions from $\mathbb{R}$ to itself. I only know one non trivial solution: $(f,g)=(x\mapsto 2^x,x\mapsto x-1)$. Can someone tell me whether it is the only one or not? Thanks in advance.
 A: Let $g\colon \mathbb R\to\mathbb R$ be any fixpoint-free homeomorphism with inverse $h$ and $g(0)<0$ (hence $h(0)>0$). Then $k\colon x\mapsto x+h(x)$ is also invertible.
Let $x_0=0$ and recursively $x_{n+1}=h(x_n)$, $x_{n-1}=g(x_n)$. Note that $\lim_{n\to\pm\infty}x_n=\pm\infty$ as otherwise we'd have convergence to a fixed point of $g$.
Let $\phi\colon[x_0,x_1]\to\mathbb R$ be any continuous function with $\phi(x_1)=k(\phi(x_0))$.
Proposition. For $n\in\mathbb N$ there exists a unique continuous function $f_n\colon[x_{1-n},x_n]\to\mathbb R$ with $f_n|_{[x_0,x_1]}=\phi$ and $f_n(h(x))=k(f_n(x))$ whenever $\{x,h(x)\}\subseteq [x_{1-n},x_n]$.
Proof: For $n=1$ this follows with $f_1=\phi$.
Assume we have already shown existence and uniqueness for $f_{n-1}\colon[x_{2-n},x_{n-1}]\to\mathbb R$.
Then we must define
$$f_n(x)=\begin{cases}f_{n-1}(x)&\text{if }x_{2-n}\le x\le x_{n-1}\\
k(f_{n-1}(g(x))&\text{if }x_{n-1}\le x\le x_n\\
k^{-1}(f_{n-1}(h(x)))&\text{if }x_{1-n}\le x\le x_{2-n}\\\end{cases} $$
by uniqueness on the smaller interval and the required functional equation.
Fortunately, we can define this way and obtain a continuous function (because $f_{n-1}(x_{2-n})=k^{-1}(f_{n-1}(h(x_{2-n}))$ and $ f_{n-1}(x_{n-1})=k(f_{n-1}(g(x_{n-2}))$ by induction hypothesis) that satisfies the condtion. $_\square$
Then it is well-defined to let $f(x)=f_n(x)$ for any $n$ with $x_{1-n}\le x<x_n$. Then $f\colon \mathbb R\to\mathbb R $ is continuous with $f|_{[x_0,x_1]}=\phi$ and $f\circ h=k\circ f$, i.e. $f\circ h-h\circ f=f$. We conclude that
$$\tag1g\circ f-f\circ g = g\circ(f\circ h-h\circ f)\circ g = g\circ f\circ g.$$
Conclusion. For any $g$ and $\phi$ as above there exists a unique continuous $f$ such that $(1)$ holds.
Remark. We could do the same with $g(0)>0$. If we drop the fixed-point-freeness condition, we can argue as above for all intervals bounded by consecutive fixed points. One has to take care a bit to check the continuity of $f$ at the fixed-points in this case: If $x$ is a fixed point of $g$, we need to have $f(x)=0$ and this restricts the choice of $\phi$ (possibly too much). Or we recall that continuity wasn't even among the requirements from the problem statement.
A: There are quite a lot of solutions to this. To simplify the setting a bit, set $f := id$. Then the equation becomes $g \circ g = 0$, which has a number of non-trivial solutions, e.g.:    $g(x) = -x$ for $x \geq 0$ and $g(x) = 0$ for $x \leq 0$.
Edit: Starting from the choice of $g$ and revisiting the choice of $f$, note that $g$ also works just fine together with $x \mapsto 2x$ in place of $f$, or any other positive real in place of $2$.
