Find the range of $\displaystyle f(x) = \frac{x^2+x-1}{x^2-x+2}$ subjected to $-1 \leq x\leq 1$.
Plan
\begin{align} y = \frac{x^2+x-1}{x^2-x+2}&\implies yx^2-yx+2y=x^2+x-1\\&\implies(y-1)x^2-(y+1)x+(2y+1)=0.\end{align}
For $y=1$, we have $x=3/2$.
For $y\neq 1$,
$$(y+1)^2-4(y-1)(2y+1)\geq 0$$
$$y^2+2y+1-4(2y^2-y-1)\geq 0$$
$$7y^2-6y-5\leq 0$$
$$y\in \bigg[\frac{3-2\sqrt{21}}{7},\frac{3+2\sqrt{21}}{7}\bigg]$$
But the solution is $\displaystyle \bigg[\frac{3-2\sqrt{21}}{7},\frac{1}{2}\bigg]\cup \{1\}$.
Help me please.
I will propose an alternative solution using calculus (as this tag has been added by OP).
Rewrite $$f(x)=\frac{x^2+x-1}{x^2-x+2}=1+\frac{2x-3}{x^2-x+2}$$ and note that $f$ is defined in the interval $[-1,1]$.
Now we find the stationary points. Thus $$f'(x)=\frac{2(x^2-x+2)-(2x-3)(2x-1)}{(x^2-x+2)^2}=0\implies2x^2-6x-1=0$$ giving the stationary points $x_+,x_-=\frac12(3\pm\sqrt{11})$.
Checking using $f''$ or a nature table reveals that $f$ is at its maximum at $x=x_+$ and is at its minimum at $x=x_-$. However, only $x_-$ is contained within the interval $[-1,1]$, but we know that in the interval $(x_-,x_+)$, $f$ is strictly increasing.
Therefore, the range of $f$ in said interval is simply $$[f(x_-),f(1)]=\left[1+\frac{2\cdot\frac{3-\sqrt{11}}2-3}{\frac{(3-\sqrt{11})^2}4-\frac{3-\sqrt{11}}2+2},1+\frac{2(1)-3}{1^2-1+2}\right]=\left[\frac{3-2\sqrt{11}}7,\frac12\right].$$
Here is a plot which verifies this.