# Give examples of two functions $$f : N \to Z$$ and $$g: Z \to Z$$ such that $$g\;o\;f$$ is injective but $$g$$ is not injective.

(Hint : Consider f(x) = x and g(x) = |x|).

Toolbox:
• A function $f: X \rightarrow Y$ where for every $x1, x2 \in X, f(x1) = f(x2) \Rightarrow x1 = x2$ is called a one-one or injective function.
• A function$f : X \rightarrow Y$ is said to be onto or surjective, if every element of Y is the image of some element of X under f, i.e., for every $y \in Y$, there exists an element x in X such that $f(x) = y$.
• Given two functions $f:A \to B$ and $g:B \to C$, then composition of $f$ and $g$, $gof:A \to C$ by $gof (x)=g(f(x))\;for\; all \;x \in A$
• $=>x=y$
Lets define a function $f:N \to Z$ as $f(x)=x$ and $g:Z \to Z$ as $g(x)=|x|$
$\textbf {Step 1: Example function such that g is not injective}$
We observe that for $-1 \in Z$ $g(-1)=|-1|=1$ and since $g(1)=|1|=1$, we can see that since $-1 \neq 1$, $g$ is not injective.
$\textbf {Step 2: Testing if gof is injective}$
Now, $gof(x)=g(fx)=g(x)=|x|$ and $gof(y)=g(f(y))=g(y)=|y|$
$\Rightarrow$ $|x|=|y|$, and since $x,y \in N$, both are positive. Therefore $x=y$.
Hence, $gof$ is injective.

edited Mar 20, 2013