# Disprove: $f\circ g = f \circ h \implies g=h$ for a surjective function $f$

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.

• Hint: let $f$ be surjective but not injective. Now look for constants $g\neq h$. – lulu Jun 6 '16 at 1:25
• ... Is my function $f$ injective? I thought it wasn't. I guess I should prove that the function is strictly surjective. – J00S Jun 6 '16 at 1:27
• Ah, I misread it. Yes, your function works perfectly. – lulu Jun 6 '16 at 1:28
• 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). – Clement C. Jun 6 '16 at 1:31
• If $g=-h$, there's no guarantee $f \circ g = f \circ h$ for a general surjection. – M10687 Jun 6 '16 at 1:32

## 3 Answers

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.

• To get $g \not = h$ we'll need $X$ to have at least two points. +1 – Carl Mummert Jun 6 '16 at 1:55
• @CarlMummert Agreed. – yurnero Jun 6 '16 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?