simplify the expression

3(x-2)-9(x^2+7x+4)-5(x+8)

first, get rid of the parens:

3(x-2)-9(x^2+7x+4)-5(x+8)
3x - 6 - 9x^2 - 63x - 36 - 5x - 40

Now collect like powers of x:

-9x^2 + (3-63-5)x + (-6-36-40)
-9x^2 - 65x - 82