# Example of an injective function $g$ and function $f$ such that $g\circ f$ is not injective

Give an example of a function $g$ which is injective, but for which its composition with $f$ is not, namely $g\circ f$.

I suspect that $f(x)=0$ and $g(x)=x$ will do, am I right?

• Almost there, but you must specify domains and ranges. – Gyu Eun Lee Jul 13 '13 at 3:40

Generalizing your example, let $g$ be any injective function with domain $B$. Take $f$ to be a constant function from any set $A$ containing two or more elements to $B$. For example, suppose $a_1,a_2$ are distinct elements in $A$ and $b \in B$. Define $f : A \rightarrow B$ by the formula $f(x)=b$ and note that $( g \circ f)(a_1)=g(b)=(g \circ f)(a_2)$ but $a_1 \neq a_2$.
Depends on the domain and codomain of those functions: if $f$ and $g$ are both functions from $\{0\}$ to itself, then $g\circ f=f=g$ certainly is injective. (But almost certainly, you intended something like $f,g:\mathbb{R}\to\mathbb{R}$, in which case your answer is correct.)
Let $g(x)=x^3$ and $f(x)=x^2$.