I tried using a very specific counterexample here where I select a surjective function for which the compositions are equal but the functions within are not.

This is probably off-base, but it's what I've got so far.

Assume $f \circ g = f \circ h$.

Consider the surjective function $f:\mathbb{R} \rightarrow \mathbb{R}$ given by $f(x) = x*sin(x)$.

Should I prove this is surjective before proceeding?

Suppose for the sake of contradiction that $g \neq h$ given by

$g(x) = 0$ and $h(x) = 2\pi$.

Can I choose these constant functions? Do I need to define domains and codomains?

$(f \circ g)(x) = f(g(x)) = f(0) = 0 * sin(0) = 0$

$(f \circ h)(x) = f(h(x)) = f(2\pi) = 2\pi * sin(2\pi) = 0$

Observe that $f \circ g = f \circ h$ $\land$ $x_1 \neq x_2$.

Thus we have given a counterexample to disprove the statement. Thus surjectivity of $f$ is not a sufficient condition for the statement to be true.

I understand the proof completely now and understand I have it correct, thank you for your responses.

  • $\begingroup$ Hint: let $f$ be surjective but not injective. Now look for constants $g\neq h$. $\endgroup$
    – lulu
    Jun 6, 2016 at 1:25
  • $\begingroup$ ... Is my function $f$ injective? I thought it wasn't. I guess I should prove that the function is strictly surjective. $\endgroup$
    – J00S
    Jun 6, 2016 at 1:27
  • 1
    $\begingroup$ Ah, I misread it. Yes, your function works perfectly. $\endgroup$
    – lulu
    Jun 6, 2016 at 1:28
  • $\begingroup$ To generalize a little bit: take any surjective even function $f$ (yours is a good example), and take $g=-h$ (where $g$ is not the zero function). $\endgroup$
    – Clement C.
    Jun 6, 2016 at 1:31
  • $\begingroup$ If $g=-h$, there's no guarantee $f \circ g = f \circ h$ for a general surjection. $\endgroup$
    – M10687
    Jun 6, 2016 at 1:32

3 Answers 3


Let $f: \mathbb{R} \rightarrow [-1,1]$, $f(x)=\sin(x)$. Then let $g(x)=x$, $h(x)=x+2 \pi$. $f$ is surjective and $f \circ h= f \circ g$, but we clearly don't have $h=g$


Consider $f:X\to\{0\}$ where $f(x)=0$ for all $x\in X$. Then, you can specify $g:X\to X$, $h: X\to X$, and $X$ as you like; any such choice (with $|X|\geq 2$) will work.

  • 1
    $\begingroup$ To get $g \not = h$ we'll need $X$ to have at least two points. +1 $\endgroup$ Jun 6, 2016 at 1:55
  • $\begingroup$ @CarlMummert Agreed. $\endgroup$
    – yurnero
    Jun 6, 2016 at 2:06

Let $S$ be the set of students of a class. Let $g(s)$ and $h(s)$ denote the scores obtained by student $s$ in Geography and History respectively. Thus $g,h$ are functions from $S$ to $[0,100]$. Let $f\colon[0,100]\to \{A,B,C,D,E,F\}$ be a function that assigns letter grades to numerical scores.

Now I leave it to you work out a scenario where each student gets the same grade in both the subjects, that is, $f\circ g = f\circ h$. Does that necessarily mean the scores are same in both the subjects for each student?


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .