# If $f:\mathbb{R} \to \mathbb{Z}$, why can't we have that $g \circ f$?

In the lecture notes for a course I'm taking, it is stated that:

Unlike multiplication however, we can't reverse order. First of all, in general it doesn't even make sense to reverse composition. For example, if we have $f:\mathbb{R} \to \mathbb{Z}$ defined by $f(x) =\left \lfloor x \right \rfloor$ and $g:\mathbb{R} \to \mathbb{R}$ defined by$g(x) = x^2$. Then $f \circ g$ makes perfect sense since the codomain of $g$ and the domain of $f$ are equal (both are $\mathbb{R}$), but we can't technically do $g \circ f$, since the codomain of $f$ is $\mathbb{Z}$ and the domain of $g$ is $\mathbb{R}$.

I'm confused by the reasoning for this. Since the implication is $(g\circ f):\mathbb{R} \to \mathbb{Z}$, and we have that $f:\mathbb{R} \to \mathbb{Z}$ is true, why is it that $(g \circ f)$ is not true as well?

• I don't agree with this lecture notes, since $\,\text{Im}(f)\subset \text{Dom}(g)\,$ ... – DonAntonio Jun 4 '13 at 21:59

We can form $g\circ f$ only by (silently) inserting a third function, namely the inclusion $\iota\colon \mathbb Z\to\mathbb R$, i.e. strictly we can only form $g\circ\iota\circ f$: $$\mathbb R\stackrel f\longrightarrow\mathbb Z\stackrel \iota\longrightarrow \mathbb R\stackrel g\longrightarrow \mathbb R.$$ Alternatively, we can consider the restriction of $g$ to $\mathbb Z\subseteq \mathbb R$, that is $g|_{\mathbb Z}\colon\mathbb Z\to\mathbb R$, $x\mapsto x^2$. Then we can form $g|_{\mathbb Z}\circ f$: $$\mathbb R\stackrel f\longrightarrow\mathbb Z\stackrel {g|_{\mathbb Z}}\longrightarrow \mathbb R.$$ (Well, it's not really an alternative as one may define the restriction via $\iota$).
• Following Hagen von Eitzen's suggestion, here is an example that might be instructive: suppose $m$ is the function $\Bbb P\to\Bbb P$ (where $\Bbb P$ is the set of all people) that takes each person to their mother, and then suppose $h$ is the function $\Bbb P\to\Bbb R$ that takes each person to their height in meters. Then $h\circ m$ is straightforward; it's the function $\Bbb P\to\Bbb R$ that gives the height of a person's mother. But $m\circ h$ makes no sense at all, since it's the mother of a person's height, and all you can say about that is "What?" – MJD Jun 4 '13 at 22:10