<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] $$y = \frac{x^2 - 3x + 2}{x^2 + 2x + 1} = 1 - \frac{5x-1}{(x+1)^2}$$
\begin{align*}
\frac{dy}{dx} &= \frac{d}{dx} \left[ \frac{1-5x}{(x+1)^2} \right] \\
&= \frac{-5\cdot(x+1)^2-(1-5x)\cdot 2(x+1)}{(x+1)^4} \\
&= \frac{-5\cdot(x+1)-2(1-5x)}{(x+1)^3} \\
&= \frac{-5x-5-2+10x}{(x+1)^3} \\
&= \frac{5x-7}{(x+1)^3}
\end{align*}
$$\frac{dy}{dx} = 0 \Longleftrightarrow x=\frac{7}{5} $$
</s>