a)\(-3x\left(x+2\right)^2+\left(x+3\right)\left(x-1\right)\left(x+1\right)-\left(2x-3\right)^2\)
\(=-3x.\left(x^2+2.x.2+2^2\right)+\left(x^2+x+3x-3\right).\left(x+1\right)-\left(2x\right)^2-2.2.x.\left(-3\right)+\left(-3\right)^2\)
\(=-3x.\left(x^2+4x+4\right)+\left(x^2+\left(x+3x\right)-3\right).\left(x+1\right)-4x+12x+9\)
\(=-3x.\left(x^2+4x+4\right)+\left(x^2+4x-3\right)\left(x+1\right)-4x+12x+9\)
\(=-3x^3-12x^2-12x+x^3+4x^2-3x+x^2+4x-3-4x+12x+9\)
\(=\left(-3x^3-x^3\right)+\left(-12x^2+4x^2+x^2\right)+\left(-12x-3x+4x-4x+12x\right)+\left(-3+9\right)\)
\(=-2x^3-7x^2-3x+6\)
b)\(\left(x-3\right)\left(x+3\right)\left(x+2\right)-\left(x-1\right)\left(x^2-3\right)-5x\left(x+4\right)^2-\left(x-5\right)^2\)
\(=\left(x.\left(x+3\right)-3\left(x+3\right)\right)\left(x+2\right)-\left(x.\left(x^2-3\right)-1\left(x^2-3\right)\right)-5x\left(x+4\right)^2-\left(x-5\right)^2\)
\(=\left(x.x+x.3-3.x+\left(-3\right).3\right)\left(x+2\right)-\left(x.x^2+x.\left(-3\right)-1.x^2+\left(-1\right).\left(-3\right)\right)-5x.x+\left(-5x\right).4-x^2-2x5+5^2\)
\(=\left(x^2+3x-3x-9\right)\left(x+2\right)-x^3-3x-x^2+3-5x^2-20x-x^2-10x+25\)
\(=\left(x^2+\left(3x-3x\right)-9\right)\left(x+2\right)-x^3-3x-x^2+3-5x^2-20x-x^2-10x+25\)
\(=\left(x^2-9\right)\left(x+2\right)-x^3-3x-x^2+3-5x^2-20x-x^2-10x+25\)
\(=x^3+2x^2-9x-15-x^3-3x-x^2+3-5x^2-20x-x^2-10x+25\)
\(=\left(x^3-x^3\right)+\left(2x^2-x^2-5x^2-x^2\right)+\left(-9x-3x-20x-10x\right)+\left(-18+3+25\right)\)
\(=-5x^2-42x+10\)