a: \(x^3-1+\left(x-1\right)\left(x+2\right)\)
\(=\left(x-1\right)\left(x^2+x+1\right)+\left(x-1\right)\left(x+2\right)\)
\(=\left(x-1\right)\left(x^2+x+1+x+2\right)\)
\(=\left(x-1\right)\left(x^2+2x+3\right)\)
b: \(4x^2-2x+\left(2x+1\right)\left(2x-1\right)\)
\(=2x\left(2x-1\right)+\left(2x+1\right)\left(2x-1\right)\)
\(=\left(2x-1\right)\left(2x+2x+1\right)\)
\(=\left(2x-1\right)\left(4x+1\right)\)