How to prove that there exist no functions $f,g:\Bbb{R}\to\Bbb{R}$ such that $f(g(x))=x^{2018}$ and $g(f(x))=x^{2019}$?

I have tried a little bit to solve the problem which goes as follows:

My intuition says that there exist no $$f:\Bbb R\to\Bbb R$$ such that $$f(g(x))=x^{2018}\text{ and }g(f(x))=x^{2019}.$$

Note that $$f(g(f(x)))=f(x)^{2018}\implies f(x^{2019})=f(x)^{2018}$$

Similarly, $$g(x^{2018})=g(x)^{2019}$$ Putting $$x=1$$ in $$f(x^{2019})=f(x)^{2018}$$, we get $$f(1)=f(1)^{2018}$$ and thus $$f(1)=0$$ or $$f(1)=1$$.

Similarly, putting $$x=1$$ in $$g(x^{2018})=g(x)^{2019}$$ we get $$g(1)=g(1)^{2019}$$ and thus $$g(1)=0,1,-1$$.

Now, I can't proceed further. Can anybody solve it? Thanks for assistance in advance.

Here is a simple proof (to avoid confusion I will write $$f^{y}(x)$$ instead of $$f(x)^{y}$$):

Suppose that there are two such functions $$f,g$$ as in your question.

Note that $$\forall\space i \in\{-1, 0, 1\}$$, we have $$f(i^{2019}) = f(i) = f^{2018}(i)$$ and thus $$\label{*}\tag{*} f(i) \in \{0, 1\} \quad\forall\space i \in\{-1, 0, 1\}.$$

On the other hand, since $$g(f(x)) = x^{2019} \space\forall x\in\mathbb{R}$$,

• $$g(f(1)) = 1$$,
• $$g(f(0)) = 0$$,
• $$g(f(-1)) = -1$$.

This is impossible since $$f$$ (and thus also $$g\circ f$$) only takes two (or fewer) values on $$\{-1, 0, 1\}$$ after \eqref{*}. $$\Longrightarrow\Longleftarrow\quad\square$$

Another classic trick that can be used here is that there is a bijection between the set of fixed points of $$fg$$ and fixed points of $$gf$$. If $$x$$ is such that $$f(g(x))=x$$ then $$g(f(g(x)))=g(x)$$ so $$g(x)$$ is a fixed point of $$gf$$. Similarly whenever $$y$$ is a fixed point of $$gf$$, we can show that $$f(y)$$ is a fixed point of $$fg$$. Convince yourself that on the sets of fixed points, this gives a bijection.

Can you see why the $$fg$$ and $$gf$$ you've been given fail this condition?