Topology: Question on the inverse set

Excerpt from "Topology Without Tears" (Sidney Morris). In the above example, how is it that $$f^{-1}((1,3)) = (2,3]$$ ? Here is my understanding, kindly correct the misconceptions. The inverse for $$(2,4]$$ is not defined. The inverse is as below. $$f^{-1}(y)=\begin{cases} y+1 & \text { if } y \le 2\\ 2y-5 & \text{ if } y \gt 4\\ \end{cases}$$ So, if I have to find out for example, $$f^{-1}(2\frac{1}{2})$$, how do I do it? When does $$f^{-1}(y)$$ give me $$3$$ (to justify the $$3$$ in $$(2,3]$$ ) ?

The inverse image $$f^{-1}(S)$$ refers to the set $$\{x \in \Bbb{R} : f(x) \in S\}$$ This would mean that $$f^{-1}(\{2\frac{1}{2}\}) = \emptyset$$ We also have, $$f^{-1}(1, 3) = \{x \in S : 1 < f(x) < 3\},$$ which is true precisely for $$2 < x \le 3$$. There's no requirement that there be some $$x$$ such that $$f(x) = 2.5$$; just so long as it's less than $$3$$.
• If $$x>3$$ we have that $$f(x) = \frac{1}{2}(x+5) > \frac{1}{2} \cdot 8 = 4$$ and so $$f(x) \notin (1,3)$$.
• If $$2< x \le 3$$ we have that $$f(x)=x-1 \in (1,2] \subseteq (1,3)$$ and
• If $$x \le 2$$, $$f(x)=x-1 \le 1$$,so $$f(x) \notin (1,3)$$
Hence $$f^{-1}((1,3) = \{x: f(x) \in (1,3) \} = (2,3]$$, as we covered all options for $$x$$.
Inverse image is not "image under a (non-existent) inverse function". For example: if $$f: \mathbb{R} \to \mathbb{R}$$ is the function that is constant with value $$2$$, then $$f^{-1}(\{2\}) = \mathbb{R}$$ and $$f^{-1}(\{1\}) = \emptyset$$. We are talking about inverse images of sets, not of points.