Let $$y=\frac{7+6\tan x-\tan^2x}{1+\tan^2x}$$ for all values of $x\ne\frac{\pi}{2}$ Then find the maximum and minimum values of $y$.
I cross multiplied and got a quadratic whose discriminant has to be $\ge0$ because $\tan x \in \mathbb{R}\:\: \forall x \in \mathbb{R}-\{\frac{\pi}{2}\}$
After, putting the discriminant $\ge0$, I got the equation $$y^2+6y-15\le0$$ According to this, the minimum value should be $$-3-2\sqrt6\approx-8$$ and the maximum should be $$2\sqrt6-3\approx2$$ But the answer given of maximum value is $8$ and that of minimum is $-2$. Where am I wrong$?$
Any help is greatly appreciated.
We can proceed by $t=\tan x$ to obtain
$$y(t)=\frac{7+6t-t^2}{1+t^2} \implies y'(t)=\frac{-2(3t^2+8t-3)}{(1+t^2)^2}=0\implies t=\frac13,-3$$
which leads to $y(1/3)=8$ and $y(-3)=-2$ which are the maximum and the minimum since $\lim_{t\to \pm \infty} y(t) =-1$.
Using your way we have
$$y=\frac{7+6t-t^2}{1+t^2} \implies (y+1)t^2-6t+(y-7)=0$$
and then
$$36-4(y+1)(y-7)\ge 0 \iff y^2-6y-16\le 0 \iff (y-8)(y+2)\le 0$$