a) ĐKXĐ: \(x\notin\left\{0;-1;1\right\}\)
Ta có: \(P=\left(\frac{\left(x-1\right)^2}{3x+\left(x-1\right)^2}-\frac{1-2x^2+4x}{x^3-1}\right):\frac{x^2+x}{x^3+x}\)
\(=\left(\frac{\left(x-1\right)^2}{3x+x^2-2x+1}-\frac{-2x^2+4x+1}{\left(x-1\right)\left(x^2+x+1\right)}\right):\frac{x\left(x+1\right)}{x\left(x^2+1\right)}\)
\(=\left(\frac{\left(x-1\right)^2}{x^2+x+1}-\frac{-2x^2+4x+1}{\left(x-1\right)\left(x^2+x+1\right)}\right):\frac{x+1}{x^2+1}\)
\(=\left(\frac{\left(x-1\right)^3}{\left(x-1\right)\left(x^2+x+1\right)}-\frac{-2x^2+4x+1}{\left(x-1\right)\left(x^2+x+1\right)}\right):\frac{x+1}{x^2+1}\)
\(=\left(\frac{x^3-3x^2+3x-1+2x^2-4x-1}{\left(x-1\right)\left(x^2+x+1\right)}\right):\frac{x+1}{x^2+1}\)
\(=\frac{x^3-x^2-x-2}{\left(x-1\right)\left(x^2+x+1\right)}:\frac{x+1}{x^2+1}\)
\(=\frac{x^3-2x^2+x^2-2x+x-2}{\left(x-1\right)\left(x^2+x+1\right)}:\frac{x+1}{x^2+1}\)
\(=\frac{x^2\left(x-2\right)+x\left(x-2\right)+\left(x-2\right)}{\left(x-1\right)\left(x^2+x+1\right)}\cdot\frac{x^2+1}{x+1}\)
\(=\frac{\left(x-2\right)\left(x^2+x+1\right)}{\left(x-1\right)\left(x^2+x+1\right)}\cdot\frac{x^2+1}{x+1}\)
\(=\frac{\left(x-2\right)\left(x^2+1\right)}{\left(x-1\right)\left(x+1\right)}\)
\(=\frac{x^3+x-2x^2-2}{x^2-1}\)