Questions about domain and range of composite functions 
Let $f: \mathbb R \to \mathbb Z, \ g: \mathbb R \setminus \{0\} \to \mathbb  R$ be defined by $f(x) = \lfloor x\rfloor, g(x) = \displaystyle{\frac 1x}$. Note that in this case, $g \circ f$ is not defined ($\color{red}{\text{why?}}$). However, $f \circ g: \mathbb R \setminus \{0\} \to \mathbb Z$ is defined. You can $\color{blue}{\text{verify}}$ that the composite is given by $$(f \circ g)(x) = \left\lfloor\frac 1x\right\rfloor =\begin{cases}0 \text{ if } x \in (1, \infty) \\  n \text{ if } x \in \color{orange}{\left(\frac{1}{n + 1},\frac 1n\right]_{n \in \mathbb N}} \\  -(n + 1) \text{ if } x \in \color{orange}{\left(-\frac 1n, -\frac{1}{n + 1}\right]_{n \in \mathbb N}} \\ -1 \text{ if } x \in (-\infty, -1)\end{cases}$$


How do we know that we have defined $(f \circ g)(x)$ for all $x \in \mathbb R \setminus \{0\}$? $\color{green}{\text{Recall }\bigcup_n [1/n,1) = (0,1)}.$

My questions:

*

*Answer to the $\color{red}{\text{question in red}}$ above: $g \circ f$ is not defined as $0$ in the range of $f$, but not in the domain of $g$. Is that correct?


*$\color{blue}{\text{Suggestion in blue}}$ above. I'll only consider one branch to see if I can do it. Suppose $\displaystyle{-\frac 1n < x \le -\frac{1}{n + 1}}$. Then $\displaystyle{-n > \frac 1x \ge  -(n + 1)} \iff \left\lfloor \frac 1x \right\rfloor = -(n + 1)$ by definition of $\lfloor \cdot \rfloor?$


*$\color{green}{\text{Hint in green}}$ above. If $x \in \mathbb Q$, then $g(x) \in \mathbb N.$ If $x 
\in \mathbb N$, then $g(x) \ne 0$. Is this what the mysterious(?) $\color{green}{\text{hint in green}}$ above alluding to?


*How do they know the given partition of the domain of $f \circ g$ covers all the necessary cases? In particular, how did they know to choose the $\color{orange}{\text{intervals in orange}}$?
Thanks.
 A: Red and Blue: They look good to me.
Green: You're given a piecewise function that's defined and equal to $f \circ g$ on $(-\infty, -1) \cup (-\frac 1n, -\frac{1}{n + 1})_{n \in \mathbb N} \cup (\frac{1}{n + 1},\frac{1}{n})_{n \in \mathbb N}\cup (1, \infty)$, but how are you sure that these intervals make up all of $\mathbb{R}/\{0\}$?
If you can show that your piecewise function has been defined on $[1/n,1)_{n \in \mathbb N}$, the hint will tell you that you've indeed defined it on $(0,1)$. From there, proving that the function is defined on all of $\mathbb{R}/\{0\}$ is straightforward.
Orange: I believe it takes a bit of intuition and trial and error. That's what I would have done at least. The value of $\left\lfloor x \right\rfloor$ seems to change if and only if $x$ "crosses" an integer, which means that $\left\lfloor\frac{1}{x}\right\rfloor$ should change whenever $x$ "crosses" $\frac{1}{n}$ for some $n$. This suggests for us to use the partition that was given. Now all we need to do is figure out the details (endpoints) and verify if it works.
