# If $g \circ f$ is surjective, show that $f$ does not have to be surjective?

Suppose $f: A \to B$ and $g: C \to D$ are functions, and that $B ⊆ C$.

I need to come up with an example where $g \circ f$ is surjective but $f$ is not. I'm confused on how exactly to do that, but I understand that to show something is surjective you have to have the range of the function equal to the codomain of the function. Here's my attempt:

So if $g(x) = x^2$ with a codomain of $ℝ$, and $f(x) = \sqrt{x}$ with a codomain of $ℝ$, then $g(f(x)) = (\sqrt{x})^2 = x$. Since the range of this function and codomain are the same, this is surjective.

But, since $f(x) = \sqrt{x}$, its range is only $[0, ∞)$, which is smaller than its codomain of $ℝ$, meaning $f$ is not surjective.

• This is harder with $\mathbb R$ than it might be with some very simple sets.
– user208649
Mar 19, 2016 at 23:36
• @Chris Your example is correct if you admit $A=[0,+\infty)=D$ and $B=\mathbb{R}=C$ Mar 19, 2016 at 23:39

Put $f:\mathbb{R}\to \mathbb{R}$ defined by $f(x)=x^2$, and $g:\mathbb{R}\to \{0\}$ defined by $g(x)=0$. Then $g\circ f:\mathbb{R}\to \{0\}$ is clearly surjective but $f$ is not surjective.
Let $B=C=\{1,2\}$, and $A=D=\{3\}$. Then pick any functions $f,g$ you want, to get $g\circ f$ surjective but $f$ not surjective.