Đặt \(x^2+1=a\)
Ta có: \(\dfrac{1}{x^2-x+1}-\dfrac{x^2+2}{x^2+1}+1\)
\(=\dfrac{1}{a-x}+\dfrac{a+1}{a}+1\)
\(=\dfrac{a}{a\left(a-x\right)}+\dfrac{\left(a+1\right)\left(a-x\right)}{a\left(a-x\right)}+\dfrac{a\left(a-x\right)}{a\left(a-x\right)}\)
\(=\dfrac{a+a^2-ax+a-x+a^2-ax}{a\left(a-x\right)}\)
\(=\dfrac{2a^2+2a-2ax-x}{a\left(a-x\right)}\)
\(=\dfrac{2\left(x^2+1\right)^2+2\left(x^2+1\right)-2x\left(x^2+1\right)-x}{\left(x^2+1\right)\left(x^2+1-x\right)}\)
\(=\dfrac{2\left(x^4+2x^2+1\right)+2x^2+2-2x^3-2x-x}{\left(x^2+1\right)\left(x^2-x+1\right)}\)
\(=\dfrac{2x^4+4x^2+2+2x^2+2-2x^3-3x}{\left(x^2+1\right)\left(x^2-x+1\right)}\)
\(=\dfrac{2x^4-2x^3+6x^2-3x+4}{\left(x^2+1\right)\left(x^2-x+1\right)}\)