<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] $$y-1=\dfrac{2t-3}{t^2-t+2}$$
Let $z=3-2t\implies5\ge z\ge1$
$$\dfrac4{1-y}+4=4+\dfrac {z^2-4z+11}z=z+\dfrac{11}z\ge2\sqrt{z\cdot\dfrac{11}z}$$ which is attained if $z^2=11$
$$y\ge?$$
Now for $5\ge a>b\ge1,$
$$a+11/a-(b+11/b)=\dfrac{(a+b-11)(a-b)}{ab}<0$$
So, $z+\dfrac{11}z$ will be maximum for the the minimum value of $z$ which is $=1$ here
Can you take it from here?
</s>