<s>[INST] What is wrong in my $f'(x)$? We have $f:\mathbb{R}\rightarrow\mathbb{R}, f(x)=\frac{x^2-x+1}{x^2+x+1}$ and we need to find $f'(x)$.
Here is all my steps:
$$\begin{align}f'(x)&=\frac{(2x-1)(x^2+x+1)-(x^2-x+1)(2x+1)}{(x^2+x+1)^2}\\&=\frac{(2x-1)(x^2+1)-(2x+1)(x^2+1)}{(\cdots)^2}\\&=\frac{(x^2+1)(2x-1-2x-1)}{(\cdots)^2}\\&=\frac{2(1-x)(1+x)}{(\cdots)^2},\forall x\in\mathbb{R}\end{align}$$

But in my book they say that $f'(x)=\frac{2(x-1)(x+1)}{(x^2+x+1)^2}$. What is wrong in my method ?

 [/INST] $$\begin{align}
(2x-1)(x^2+x+1)-(x^2-x+1)(2x+1) & =(2x-1)(x^2+1)+2x^2-x-((2x+1)(x^2+1)-2x^2-x)\\
& = (x^2+1)(2x-1-2x-1)+2x^2-x+2x^2+x\\
& = -2(x^2+1)+4x^2
\end{align}$$
</s>