Task B-4.3. (20 points) What are the minimum and maximum of the function

$$
y=\frac{\sin ^{2} x-\sin x+1}{\sin ^{2} x+\sin x+1}
$$

For which $x \in[0,2 \pi]$ does the function take its minimum, and for which its maximum value?
Solution. Note that the denominator is equal to $\left(\sin x+\frac{1}{2}\right)^{2}+\frac{3}{4}>0$ so $y$ is defined for every real number $x$. We get

$$
(y-1) \sin ^{2} x+(y+1) \sin x+y-1=0
$$

For this quadratic equation, in terms of $\sin x$, to have real solutions, its discriminant must be non-negative, i.e.,

$$
D=(y+1)^{2}-4(y-1)^{2} \geq 0 \quad \text { i.e., } \quad(3-y)(3 y-1) \geq 0
$$

From this, we get $\frac{1}{3} \leq y \leq 3$, or $y_{\min }=\frac{1}{3}, y_{\max }=3$.

If we substitute $y=\frac{1}{3}$ into (1), we get the quadratic equation $(\sin x-1)^{2}=0$, i.e., $\sin x=1$, so the minimum on $x \in[0,2 \pi]$ is achieved at $x=\frac{\pi}{2}$. Similarly, for $y=3$, we get $(\sin x+1)^{2}=0$, whose only solution is $\sin x=-1$, so the maximum is achieved at $x=\frac{3 \pi}{2}$.