Are there continuous functions $f,g:\mathbb{R}\longrightarrow\mathbb{R}$ such that for any $x$, $f(g(x))=\sin x$ and $g(f(x))=\cos x$?

Is it possible to find continuous functions $f,g : \mathbb{R}\longrightarrow \mathbb{R}$ such that for any $x$, $f(g(x)) = \sin x$ and $g(f(x)) = \cos x$?

(The question came up to me while thinking on another problem. but I couldn’t solve it)


If such $f$ and $g$ existed, then they would have to stablilise the set $[-1, 1]$. Fix $x \in [-1, 1]$. Then \begin{align*} f(x) &= (f \circ \cos \circ \arccos)(x) \\ &= (f \circ g \circ f \circ \arccos)(x) \\ &= (\sin \circ f \circ \arccos)(x) \in [-1, 1], \end{align*} since $\sin$'s range is $[-1, 1]$. Similarly, $g(x) \in [-1, 1]$.

Let $F : [-1, 1] \to [-1, 1]$ be the restriction of $f$, and similarly $G$ for $g$. Note that $F \circ G = \sin\mid_{[-1,1]}$ and $G \circ F = \cos\mid_{[-1, 1]}$. Further, note that $F \circ G$ is injective, hence so is $G$. Like all continuous injective functions, $G$ must be strictly monotone, either increasing or decreasing (by the intermediate value theorem).

I claim that $F$ must also be strictly monotone increasing or decreasing, and specifically, it must have the same monotonicty as $G$.

Suppose $G$ is monotone increasing, but $F$ is not. Then, there exist $x < y$ such that $F(x) > F(y)$. This would imply that $(F \circ G)(x) > (F \circ G)(y)$, by monotonicity of $G$, which is plainly false, since $\sin$ is increasing. Similar logic produces a contradiction when $G$ is decreasing but $F$ is not.

However, this means that $\cos\mid_{[-1, 1]}$ is the composition of two monotone functions, which should imply that it's monotone. It's not, hence we have a contradiction, and no such functions $f$ and $g$ exist.