<s>[INST] Find Minima and Maxima of $ y = \frac{x^2-3x+2}{x^2+2x+1}$ $$ y = \frac{x^2-3x+2}{x^2+2x+1}$$
I guess I made some mistakes cause after taking the first derivative and simlifying I have
$$y = \frac{2x^3-4x^2+5}{(x+1)^2}$$
but then numerator has complex roots. which should not be, IMO
 [/INST] Hint.  Write it as:
$$ y = \frac{x^2+2x+1-5(x+1)+6}{(x+1)^2}=1 -\frac{5}{x+1}+\frac{6}{(x+1)^2}$$
The latter is a quadratic in $w=\frac{1}{x+1}\,$ with easy to determine extrema: $\;y=1-5w+6w^2\,$.
</s>