Which functions satisfy $f^n(x) = f(x)^n$ for some $n \ge 2$?

Let $n$ be an integer greater than $1$. The notation $f^n$ is notoriously ambiguous: it means either the $n$-th iterate of $f$ or its $n$-th power.

I was wondering when the two interpretations are in fact the same. In other words, if we write $f^n(x)$ for $f(f(\dotsb f(x) \dotsb))$ and $f(x)^n$ for $f(x) \cdot f(x) \dotsb f(x)$:

For which functions $f \colon I \to \mathbb R$ is $f^n(x) = f(x)^n$ for all $x \in I$?

So far I have been able to show that:

  • The constant functions $f(x) = 0$ and $f(x) = 1$ satisfy the condition for all $n$ and $f(x) = -1$ satisfies the condition for all odd $n$. Also, if $f$ satisfies the condition for $n$, then the only fixed points of $f$ can be either $0$, $1$, or if $n$ is odd also $-1$.
  • The squaring function $f(x) = x^2$ satisfies the condition for $n = 2$ and is essentially the only non-constant differentiable function to do so. Indeed, $$f(f(x)) = f(x)^2 \implies f'(f(x)) f'(x) = 2 f(x) f'(x)$$ so if we assume $f'(x) \neq 0$ and let $y = f(x)$, we have that $$f'(y) = 2 y \implies f(y) = y^2 + c$$ and furthermore $$(y^2 + c)^2 + c = (y^2 + c)^2 \implies c = 0.$$ (Of course we could then consider also, e.g., $f(x) = x^2$ for $x \ge 0$ and $f(x) = 0$ for $x < 0$.)
  • More generally, $f(x) = x^\sqrt[n-1]{n}$ satisfies the condition for any $n > 2$. These functions are only defined on $\mathbb R^+$: this is why I chose an interval $I$ instead of all $\mathbb R$ as the domain, but I actually don't care if a solution is defined on any other non-trivial subset.

Are there any other solutions? If not, how can we prove so?


Remark: The question can be generalized to $n \in \mathbb Z$ if we assume $f$ to be invertible and denote by $f^{-n}$ either the $n$-th iterate of its compositional inverse or the $n$-th power of its multiplicative inverse (the cases $n = 0, 1$ are trivial). But this seems to be an even harder problem. For the case $n = -1$ see this question.


Solution 1:

Something non-constant and discontinuous everywhere:

$$f(x) = \left\{\begin{array}{ll} x^2 & \text{if } x \text{ is an integer} \\ \lceil x \rceil & \text{if } x \text{ is rational but not an integer}\\ \lfloor x \rfloor & \text{if } x \text{ is irrational} \end{array} \right.$$

seems to satisfy $f(f(x))=f(x)\cdot f(x)$