I want to find all subsets of $\Bbb R$ that is the range of some function$$f:Q^{-1}(\Bbb R\setminus\{0\})\to\Bbb R,f(x)=\frac{P(x)}{Q(x)}$$where $P,Q$ are coprime real polynomials.
From a discussion, the conclusion is below ($a,b$ are any real numbers, $a<b$.)
| range | example |
|---|---|
| $\Bbb R$ | $f(x)=x$ |
| $\Bbb R\setminus\{a\}$ | $f(x)=\frac1x,a=0$ |
| $\{a\}$ | $f(x)=a$ |
| $[a,b]$ | $f(x)=\frac{2x}{x^2+1},a=-1,b=1$ |
| $(a,b]$ or $[a,b)$ | $f(x)=\frac1{x^2+1},a=0,b=1$ |
| $[a,\infty)$ or $(-\infty,a]$ | $f(x)=x^2,a=0$ |
| $(-\infty,a]\cup[b,\infty)$ | $f(x)=\frac{x^2+1}{2x},a=-1,b=1$ |
| $(-\infty,a)\cup[b,\infty)$ or $(-\infty,a]\cup(b,\infty)$ | $f(x)=\frac{1}{x\left(1-x\right)},a=0,b=4$ |
These are all possible range of $f$ since $f$ extends to a continuous function $\Bbb{RP}^1\to\Bbb{RP}^1$.
For $f(x)=\frac1{x^2+1}$, the range is an interval $(0,1]$ that doesn't contain one endpoint $0$, because it is the limit of $f(x)$ as $x\to\pm\infty$. But a finite open interval doesn't contain two endpoints, for a rational function $f(x)$, $\lim_{x\to+\infty}f(x)$ and $\lim_{x\to-\infty}f(x)$ cannot be two different finite numbers, so the range of $f$ cannot be a finite open interval.
The question is to find all subsets of $\Bbb R$ that is the range of some rational functions of 2 variables$$f:Q^{-1}(\Bbb R\setminus\{0\})\to\Bbb R,f(x,y)=\frac{P(x,y)}{Q(x,y)}$$ where $P,Q$ are coprime real polynomials of 2 variables.
The list will contain the above list, but there is more: In 1D case, we showed the range cannot be finite open interval, but in 2D case, the range of $\frac1{1+x^2}-\frac1{1+y^2}$ is a finite open interval $(-1,1)$.
All your $1$-D examples would work for $2$-D since we can just ignore the dependence on $y$. But if do need $y$ in the polynomials, then we can slightly tweak your examples to get the following:
I believe you can generalise to any dimension using your examples.