[Math] An example where $g \circ f$ is surjective but $f$ is not surjective, where $f,g:\mathbb{R}\to\mathbb{R}$.

discrete mathematicsfunction-and-relation-compositionfunctions

$g \circ f$ is surjective but $f$ is not surjective. With $f,g$ from $\mathbb{R} \to \mathbb{R} $

There is a similar question If $g \circ f$ is surjective, show that $f$ does not have to be surjective? but it does not my answer my question since it does not require having $f,g$ from $\mathbb{R} \to \mathbb{R} $

I tried many functions but can't find any functions to satisfy the conditions. I am not sure which two functions can be used in this which also have the domain $\mathbb{R}$, for example $log x$ would work in for subjectivity but it does not match the domain.

Best Answer

Define $g(x)=\tan x$ for $x\ne k\pi+\pi/2$, and $g(k\pi+\pi/2)=0$, $k=1,2,...$, and $f(x)=\tan^{-1}(x)$, so $f$ maps $\bf{R}$ onto $(-\pi/2,\pi/2)$, $f$ is not surjective but $g\circ f$ is.