\(x^4+4x^3-2x^2-12x+9\)
\(=x^4+3x^3+x^3+3x^2-5x^2-15x+3x+9\)
\(=x^3\left(x+3\right)+x^2\left(x+3\right)-5x\left(x+3\right)+3\left(x+3\right)\)
\(=\left(x+3\right)\left(x^3+x^2-5x+3\right)\)
\(=\left(x+3\right)\left(x^3+3x^2-2x^2-6x+x+3\right)\)
\(=\left(x+3\right)\left[x^2\left(x+3\right)-2x\left(x+3\right)+\left(x+3\right)\right]\)
\(=\left(x+3\right)\left(x+3\right)\left(x^2-2x+1\right)\)
\(=\left(x+3\right)^2\left(x-1\right)^2\)