<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] The derivative is not correct, unfortunately.
Given that $x^2+2x+1 = (x+1)^2$, observe that if we let $g(x) = (x+1)^2$ and $f(x) = x^2-3x+2$ we have $$\begin{align}{dy\over dx} &= {g(x)f'(x) - f(x)g'(x) \over g^2(x)}\\ &= {(x+1)^2(2x-3) - (x^2-3x+2)2(x+1) \over (x+1)^4}\\ &= {(x+1)(2x-3)-2(x^2-3x+2) \over(x+1)^3}\\&= {2x^2-3x+2x-3 -2x^2+6x-4\over(x+1)^3}\\ &= {5x - 7\over(x+1)^3}. \end{align}$$
Now we set the numerator and the denominator equal to $0$ to find the points of the function where we have global maxima and global minima.
</s>