# Creating a composite function that is injective with an injective and a non-injective part

Find an example of functions $f:A\to B$ and $g:B\to C$ such that $f$ and $g\circ f$ are both injective, but $g$ is not injective.

So If I understand this correctly,

1. Need a function $f$ that is injective and that will also make $g$ injective when plugged in during $g\circ f$.
2. Need a function $g$ that is not injective on its own
3. The range of $f$ must be a subset of the domain of $g$

I tried thinking along the lines of using variations of $f(x)=x$ and $g(x)=x^2$ but all those leave my composite function as non injective

I've also been using $x\in\Bbb R$ so as to keep the range of $f$ and domain of $g$ the same.

Any suggestions of where to go with this? Thank you

Edit: Thank you everyone the answers were very helpful in understanding the problem and concepts better

• The range of f must be the domain of g No. Range of $f$ needs only be a subset of the domain of $g$. – dxiv Dec 4 '17 at 5:20
• ah so the range of $f$ could be just natural numbers or something like that while the domain of $g$ is the real numbers? – mathminutemaid Dec 4 '17 at 5:22
• Yes. See more at Domain, Co-Domain & Range of a Function for example. – dxiv Dec 4 '17 at 5:24
• It's worth noting that if "the range of $f$ is the domain of $g$" then $g$ being non-injective is enough to make the composite function non-injective. This is easy to see, take $a,b\in \text{Dom}(g)$ such that $g(a)=g(b)$. They are witnesses to the fact that $g$ is not injective. Since range of $f$ is the domain of $g$ there exist, $x,y$ such that $f(x)=a$ and $f(y)=b$ than $(g\circ f)(x)=g(f(x))=g(a)=g(b)=g(f(y))=(g\circ f)(y)$ and so $g\circ f$ is not injective. – DRF Dec 4 '17 at 7:33

Hint. Let's take $g:{\Bbb R}\to{\Bbb R}$ with $g(x)=x^2$ as you suggested - a good, simple, well-known function which is not one-to-one. Suppose we want $f:{\Bbb R}\to{\Bbb R}$ also.

To say $g\circ f$ is one-to-one means: if you know the value of $g(f(x))$ then you know the value of $x$ - that is, know it for sure, with only one possibility. So, suppose the value of $g(f(x))$ is given. We have $$g(f(x))=(f(x))^2\ ;$$ a good way to proceed from here would be [1] find the value of $f(x)$, then [2] find the value of $x$. Step [2] is easy as $f$ is supposed to be one-to-one. The problem is that step [1] would usually give you two values of $f(x)$.

But now suppose, for example, that $f(x)$ is always positive. Then step [1] gives a definite value of $f(x)$ and all is OK.

So - can you think of a (well known) one-to-one function $f:{\Bbb R}\to{\Bbb R}$ for which $f(x)$ is always a positive number?

Hope this doesn't sound too long-winded but I am hoping to illustrate how you can think about this kind of problem.

• Good answer. And now I shall spoil it: Most people will think of the function $f:x\mapsto e^x$, and then the composition becomes $x\mapsto (e^x)^2 = e^{2x}$ which is a familiar injective function. – Jeppe Stig Nielsen Dec 4 '17 at 8:31
• Additionally, I like the fact that we take $A=B=C=\mathbb{R}$ here. Some other examples may make you think that such examples occur only because you pick one of the sets "artificially" small (when in fact there is a natural continuation to all of $\mathbb{R}$). – Jeppe Stig Nielsen Dec 4 '17 at 8:38
• @JeppeStigNielsen what do you mean by $A=B=C=\mathbb{R}$? The trick is that the range of $e^x$ is $(0,\infty)$ if it were $\mathbb{R}$ it wouldn't work. – DRF Dec 4 '17 at 13:00
• @DRF The sets from the question, where $f:A\to B$ and $g:B\to C$. I know $f$ cannot be surjective, because then the failure of $g$ to be injective would lead to the composition $g\circ f$ failing to be injective as well. I think David already explained that in his answer. But if you compare to Parcly Taxel's answer, where $f(x)=x$, one could ask why this $f$ is restricted to the domain $A = \left[ 0,\infty \right)$. We could also just take $A=\{ 0\}$ and $B=\{ 0,1\}$, you know. I know every example is essentially the same. I just think it is more elegant to have $A=B=C=\mathbb{R}$. – Jeppe Stig Nielsen Dec 4 '17 at 21:33

Take $f:[0,\infty)\to\Bbb R$ with $f(x)=x$ and $g:\Bbb R\to[0,\infty)$ with $g(x)=|x|$. Then $f$ is injective and $g$ is not, while $g\circ f:[0,\infty)\to[0,\infty)$ is the identity function and is therefore injective.

• So in this case $g$(x) isn't injective because $R$ can't map fully onto [0,∞) right – mathminutemaid Dec 4 '17 at 5:28
• @mathminutemaid Actual reason: $g(-1)=g(1)=1$. – Parcly Taxel Dec 4 '17 at 5:29
• R has plenty of injective maps to $[0, \infty)$, it's just that g is injective on the subset which f characterizes and not all of R – Jason Carr Dec 4 '17 at 5:30
• Yeah, I deleted my comment and downvote again. Sorry for the rubbish. – Jeppe Stig Nielsen Dec 4 '17 at 8:44

$g:B\to C$ being non-injective means that there are distinct $b,b'\in B$ with $g(b)=g(b')$. All you need is to ensure that the image of $f$ never contains both values $b$ and $b'$ at the same time (maybe neither).

Example.

Choose $g(x)=x^2$, then the injectivity violating pairs are $(x,-x)$ for $x>0$. Just make sure that if $f(x)=y$, then there is no $x'$ with $f(x')=-y$, e.g. choose

$$f(x)=e^x$$

which is injective and will only assume positive values. Note that here $A=C=\Bbb R$ and $B=(0,\infty)$.