I've been stumped by this problem:

Find three non-constant, pairwise unequal functions $f,g,h:\mathbb R\to \mathbb R$ such that $$f\circ g=h$$ $$g\circ h=f$$ $$h\circ f=g$$ or prove that no three such functions exist.

I highly suspect, by now, that no non-trivial triplet of functions satisfying the stated property exists... but I don't know how to prove it.

How do I prove this, or how do I find these functions if they do exist?

All help is appreciated!

The functions should also be continuous.

  • 10
    $\begingroup$ easy thing to notice is that all three functions when applied twice look exactly the same $f \circ g \circ h = h^2 = f^2 = g \circ h \circ f = g^2$. $\endgroup$
    – mdave16
    Commented Jul 10, 2017 at 21:21
  • 3
    $\begingroup$ @mdave16 Yes, but the problem is, functions have lots of functional square roots. Just as $$x^2=y^2$$ does not imply $x=y$, $$f(f(x))=g(g(x))$$ does not imply $f=g$. $\endgroup$ Commented Jul 10, 2017 at 21:29
  • 4
    $\begingroup$ i know, i thought it might help in some way $\endgroup$
    – mdave16
    Commented Jul 10, 2017 at 21:31
  • 8
    $\begingroup$ This is relevant, I'm sure. $\endgroup$ Commented Jul 10, 2017 at 21:34
  • 3
    $\begingroup$ @Jeppe: Take any existing solution. Choose any collection of 8 points closed under the action of $f,g,h$. There exists a faithful action of $Q_8$ on that set of 8 points, and you can modify $f,g,h$ to act as $i,j,k$ do on those points under that action. $\endgroup$
    – user14972
    Commented Jul 11, 2017 at 16:32

6 Answers 6


Here is a proof that no such continuous functions exist. I'll use juxtaposition to denote function composition. As noted in the comments, $$ h^2=fgh=f^2=ghf=g^2. $$ Let $e=f^4=g^4=h^4$. Note that $fgf=hf=g$ and $gfg=gh=f$, so $$ ef=g^4f=gf^2gf=gfg=f, $$ $$ fe=fg^4=fgf^2g=gfg=f. $$ Similarly $eg=g=ge$ and $eh=h=he$. In particular $e^2=ef^4=f^4=e$, so $e$ is idempotent. Consider its image $X=\mathrm{im}\,e\subseteq\mathbb R$, so $e|_X$ is the identity. We have $\mathrm{im}\,f\subseteq X$ since $ef=f$. Moreover $f|_X^{4}=e|_X=\mathrm{id}_X$, so $f|_X$ is a permutation of $X$, and similarly for $g$ and $h$. (aside: it now follows that $f|_X$, $g|_X$ and $h|_X$ generate a quotient of the quaternion group).

Suppose $|X|>1$. Since $e$ is continuous, $X$ is a (possibly infinite) interval. Any continuous permutation of such a set is strictly monotone (either increasing or decreasing). Moreover the only strictly increasing involution of $X$ is the identity. Indeed suppose $\sigma$ is such a function. If $\sigma(x)>x$ then $$ x=\sigma^2(x)>\sigma(x)>x, $$ a contradiction. Similarly we cannot have $\sigma(x)<x$, so $\sigma$ is the identity.

In particular $f|_X$, $g|_X$ and $h|_X$ are strictly monotone. Since $f|_X=g|_Xh|_X$, they can't all be decreasing. wlog suppose $f|_X$ is increasing. Then $f|_X^2$ is increasing. Since $f|_X^4=\mathrm{id}_X$, applying the above result twice gives $f|_X^2=\mathrm{id}_X$ and then $f|_X=\mathrm{id}_X$.

If $|X|=1$, then we also have $f|_X=\mathrm{id}_X$. In either case, for any $x\in\mathbb R$ we have $g(x)\in X$, so $$ h(x)=f(g(x))=g(x), $$ whence $h=g$.

  • $\begingroup$ Could you clarify for a nonexpert (me) how $f^4\rvert_X = \operatorname{id}_X$ implies that $f\rvert_X$ is a permutation of $X$? By analogy, something like $q(z) = iz$ for $x\in\mathbb{R}$ satisfies a similar criterion that $q^4\rvert_{\mathbb{R}} = \operatorname{id}_{\mathbb{R}}$, but that case we cannot conclude that $q\rvert_{\mathbb{R}}$ is a permutation of $\mathbb{R}$. I'm missing what makes the logic different in your answer. $\endgroup$
    – David Z
    Commented Jul 11, 2017 at 0:19
  • $\begingroup$ @DavidZ, A standard exercise in functions states that if $v \circ u$ is injective, then $u$ is injective, and if $v \circ u$ is surjective, then $v$ is surjective. Thus, $(f|X \circ f|X) \circ (f|X \circ f|X)$ is bijective implies that $(f|X \circ f|X)$ is bijective, implies that $f|X $is bijective. A bijection $X$ to $X$ is a permutation. $\endgroup$ Commented Jul 11, 2017 at 0:24
  • 1
    $\begingroup$ @DavidZ Your function $q$ is not analogous because it doesn't map $\mathbb R$ to itself, whereas in this case we know $f(X)\subseteq X$. $\endgroup$
    – stewbasic
    Commented Jul 11, 2017 at 0:27
  • 1
    $\begingroup$ @user52733 1) Yes, the closed part also uses that $e$ is idempotent (though I think I don't need that $X$ is closed anyway). 2) The statement still holds if we allow constant functions. The argument goes through when $X$ is a singleton (except you need to replace "can't all be decreasing" by "can't all be not increasing"). $\endgroup$
    – stewbasic
    Commented Jul 11, 2017 at 0:30
  • 1
    $\begingroup$ @user52733 I split that case out for clarity. $\endgroup$
    – stewbasic
    Commented Jul 11, 2017 at 0:48

(This is by no means a comprehensive and strict answer, just few observations I made).

If you removed $0$ from the domain, the functions might be:

$$f_0 (x) \equiv -x$$ $$g_0(x) \equiv \frac 1 x$$ $$h(x) \equiv -\frac 1 x$$

Or better don't remove $0$ but allow $\infty$ into the domain and the image, making each of them the projectively extended real line. This is interesting because if you take a broader look at complex numbers and their representation as the Riemann sphere, you will notice that:

  • $f_0$ corresponds to rotating the sphere half turn, while the axis goes through $0$ and $\infty$;
  • $g_0$ is a similar rotation, the axis goes through $-1$ and $1$;
  • $h$ is also a similar rotation, the axis goes through $-i$ and $i$.

Rotating comes easy to my imagination so I will stick to this interpretation for a while, but we should remember that every half turn rotation is equivalent to some axial reflection.

So in this case the three functions (and their compositions) correspond to certain operations (and their compositions) in 3D space where we imagine the Riemann sphere is.

In general you could choose any three half turns with respect to mutually perpendicular axes. In this case however each of them must map the extended real line (which is a great circle on the Riemann sphere) onto itself. This means one of the axes must go through $-i$ and $i$, i.e. one of the functions must be our $h(x)$.

If I did my calculations right, more general forms are ($\alpha \in \mathbb R$):

$$f_\alpha (x) \equiv \frac {-x+\alpha} {\alpha x + 1},$$ $$g_\alpha (x) \equiv \frac {\alpha x + 1} {x-\alpha} $$ $$h(x) \equiv -\frac 1 x$$

The following picture shows the projectively extended real line as a cross section of the Riemann sphere. Few possible axes are drawn.

projectively extended real line

I said our functions correspond to certain reflections (or rotations) in 3D. Now in 2D the interpretation is:

  • $f_\alpha$ and $g_\alpha$ correspond to reflections about certain axes;
  • $h$ corresponds to the reflection through the point $S$ (or a half turn, if you wish).

To me the most surprising conclusion is that: $$f_0 (x) \equiv -x$$ and $$g_0(x) \equiv \frac 1 x$$ are more similar than I ever thought.

  • $\begingroup$ Wow, beautiful answer! (+1) and $\checkmark$! $\endgroup$ Commented Jul 11, 2017 at 15:07
  • 4
    $\begingroup$ Or you could allow $0$ to be in the domain, but just define $f$, $g$, and $h$ in a piecewise manner such that $f(0) = g(0) = h(0) = 0$. $\endgroup$
    – Michael L.
    Commented Jul 14, 2017 at 0:35
  • $\begingroup$ beautiful answer $\endgroup$
    – thomson
    Commented May 10, 2018 at 16:59

An example:

$$f(x) = \begin{cases} x, & \text{if $x\in \mathbb Q$} \\ -x, & \text{if $x\notin \mathbb Q$} \end{cases}$$

$$g(x) = \begin{cases} -x, & \text{if $x\in \mathbb Q$} \\ x, & \text{if $x\notin \mathbb Q$} \end{cases}$$


  • $\begingroup$ ...can you find a continuous example? $\endgroup$ Commented Jul 10, 2017 at 21:31
  • 14
    $\begingroup$ Ah, yes. Thought you might ask for that. So far, no. $\endgroup$
    – lulu
    Commented Jul 10, 2017 at 21:31
  • $\begingroup$ Lol, I still upvoted you though. :D $\endgroup$ Commented Jul 10, 2017 at 21:32
  • 2
    $\begingroup$ @Nilknarf: Would anyone really expect a solution to problems of this kind to be uncomplicated? :) $\endgroup$ Commented Jul 10, 2017 at 21:33
  • $\begingroup$ Why not just lulu's example with $f(x) = x\mathrm{sgn}(x)$, $g(x) = -x\mathrm{sgn}(x)$, $h(x) = -x$? $\endgroup$
    – Chris
    Commented Jul 10, 2017 at 21:46

A simple answer that almost works is $f(x)=g(x)=-x,h(x)=x$ with the only problem being $f=g$ but we can patch that up by making each one the identity on different parts of the real line. Split the reals into $|x| \gt 2,1 \le |x| \le 2, |x| \lt 1$. Make each the identity on one part and $-x$ on the other two.

Explicitly $$f(x)=\begin {cases} x& x \lt -2\\-x & -2 \le x \le 2 \\x & x \gt 2 \end {cases}\\g(x)=\begin {cases} -x& x \lt -2\\x & -2 \le x \le -1 \\-x & -1 \lt x \lt 1\\x&1 \le x \le 2\\-x&2 \lt x \end {cases}\\h(x)=\begin {cases} -x& x \le -1\\x & -1 \lt x \lt 1 \\-x & x \gt 1 \end {cases}$$

  • 2
    $\begingroup$ Piecewise continuous, but still not continuous. $\endgroup$ Commented Jul 10, 2017 at 22:02
  • $\begingroup$ Fix a bounded interval $I=[-a,a]$ with zero as its midpoint (either open or closed, not half-open). Comparing this answer and that of lulu, we can also see a solution with $f(x)=x$ for $x\in I$ and $f(x)=-x$ for $x\notin I$; and $g(x)=-x$ for $x\in I$ and $g(x)=x$ for $x\notin I$; and $h(x)=-x$ everywhere. $\endgroup$ Commented Jul 10, 2017 at 22:11

A simple, isometric solution exists in $\mathbb{R}^n$ for $n \ge 2$: let $f$ be a reflection in the first coordinate, and $g$ be a reflection in the second. A bijection between $\mathbb{R}^n$ and $\mathbb{R}$ then yields a solution to the stated problem, though continuity is lost.


For the non-continuous version, you can just consider the three imaginary quaternion units, acting by left multiplication on the space of quaternions (or just the unit quaternions) -- it has the same cardinality as the reals, so it resolves the problem in the non-continuous case.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .