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$.