<s>[INST] Range of $f(x) = \frac{\sin^2 x + \sin x - 1}{\sin^2 x - \sin x + 2} $ Here's what I did :
$$\text{Let }\quad y = \frac{\sin^2 x + \sin x - 1}{\sin^2 x - \sin x + 2} $$
$$\text{Let } \sin^2x=t$$
$$\Rightarrow\  (y-1)t^2-(y+1)t+2y+1=0 $$
$$\text{Since } t= \sin x\text{ is real,} $$
$$\text{Discriminant} \geqslant 0 $$
$$ \Rightarrow (y+1)^2-4(y-1)(2y+1) \geqslant 0$$
$$ \Rightarrow\ -7y^2+6y+5 \geqslant 0$$
$$\Rightarrow\  7y^2-6y-5 \leqslant 0$$
$$\Rightarrow \ y\in\left[\frac{3-2\sqrt{11}}{7},\frac{3+2\sqrt{11}}{7}\right] $$
But the correct answer (according to wolfram) is
$$y \in \left[\frac{3-2\sqrt{11}}{7},\frac{1}{2}\right] $$
Please guide me how I should proceed further .
 [/INST] Note that to find the maximum value of the range you can just simply reason as follows: 
Max($\sin^2(x)) = 1$ = Max($\sin(x)$). Hence the max is
$$y_{\text{max}} = \frac{1+1-1}{1-1+2} = \frac{1}{2}$$
</s>