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?)

What you have proved is that for any real number $x$ there exists $x$ such that $y(x^{2}+3x+2)=x^{2}-1$. To say that $y$ is in the range of $f$ you have to make sure that the point $x$ you get belongs to the domain of $f$. For $y=-2$ and $y=1$ it does not. 
The argument using the discriminant is incomplete since the solution you got does not give $f(x)=y$ for the two exceptional values of $y$: it involves division  by $0$. 
