<s>[INST] To find the range of $f(x)=\frac {x^2-1}{x^2+3x+2}$, the "discriminant method" doesn't work—why and how can we fix it? Define $f: \mathbb R \setminus \{-1,-2\} \rightarrow \mathbb R $ by $$f(x)=\frac {x^2-1}{x^2+3x+2}$$
To find the range of $f$, we use the "discriminant method" (used in e.g. 1, 2, 3):


*

*Write $y=\frac {x^2-1}{x^2+3x+2}$.

*If $x^2+3x+2\neq0$ (or $x\neq -1,-2$), then we may cross-multiply to get: $$y(x^2+3x+2)=x^2-1.$$

*Rearrange: $(y-1)x^2+3yx+2y+1=0$.

*Check discriminant: $(3y)^2-4(y-1)(2y+1)=y^2+4y+4=(y+2)^2$ which is non-negative for all $y \in \mathbb R$.

*Conclude: The range of $f$ is $\mathbb R$.


The above though is incorrect. It turns out that the range of $f$ is $\mathbb R \setminus \{-2,1\}$. What went wrong above?
(Can we fix the above argument? In particular what do we need to add so that we can discover also that $-2$ and $1$ are not in the range of $f$ while every other real number is? Or is this argument always invalid?)
 [/INST] With $y = 1$, note your equation has a $0$ coefficient for $x^2$, so it's not a quadratic any more. Instead, you have
$$\begin{equation}\begin{aligned}
3yx + 2y + 1 & = 0 \\
3x + 3 & = 0 \\
x & = -1
\end{aligned}\end{equation}\tag{1}\label{eq1A}$$
However, $x = -1$ is one of the excluded values, which means that $y = 1$ must be as well.
With $y \neq 1$, you get with the quadratic equation that
$$\begin{equation}\begin{aligned}
x & = \frac{-3y \pm (y + 2)}{2(y - 1)} \\
x(2(y - 1)) & = -3y \pm (y + 2)
\end{aligned}\end{equation}\tag{2}\label{eq2A}$$
Consider the case where $x = -2$. You then get
$$-4(y - 1) = -3y \pm (y + 2) \tag{3}\label{eq3A}$$
Thus you have that $-4y + 4 = -3y - y - 2 = -4y - 2$, which is not possible, or that $-4y + 4 = -3y + y + 2 = -2y + 2 \implies y = 1$, which has already been discounted.  Also, consider the case where $x = -1$, you have $-2y + 2 = -3y + y + 2 = -2y + 2$, which is always true, or that $-2y + 2 = -3y - y - 2 = -4y - 2 \implies y = -2$. Actually, using $y = -2$ in \eqref{eq3A} gives $-6x = 6 \implies x = -1$, which confirms this value of $y$ is not allowed either, meaning since there are no other restrictions on the values of $y$, the range of $f$ is $\mathbb R \setminus \{-2,1\}$.
For another way to solve this, note you have
$$x^2 - 1 = (x + 1)(x - 1) \tag{4}\label{eq4A}$$
$$x^2 + 3x + 2 = (x + 1)(x + 2) \tag{5}\label{eq5A}$$
Thus, for $R \setminus \{-1,-2\}$, you get
$$\begin{equation}\begin{aligned}
f(x) & = \frac{x^2-1}{x^2+3x+2} \\
& = \frac{(x + 1)(x - 1)}{(x + 1)(x + 2)} \\
& = \frac{x-1}{x+2} \\
& = \frac{x + 2 - 2 - 1}{x + 2} \\
& = 1 + \frac{-3}{x + 2}
\end{aligned}\end{equation}\tag{6}\label{eq6A}$$
Since $\frac{-3}{x + 2} \neq 0$, you have $f(x) \neq 1$. Also, since $x \neq -1$, you also have
$$\frac{-3}{x + 2} \neq \frac{-3}{-1 + 2} = -3 \tag{7}\label{eq7A}$$
which means $f(x) \neq 1 + (-3) = -2$ as well.
Since $\frac{-3}{x+2}$ has a range of all other real values (which I'll leave to you to show), this means that $f(x)$ does as well, apart from the previously mentioned $1$ and $-2$ so, once again, the range of $f$ is $\mathbb R \setminus \{-2,1\}$.
</s>