\[(3x + 9) + \left( - x^{2} - 15x - 40 \right) =\]
\[= 3x + 9 - x^{2} - 15x - 40 =\]
\[= - x^{2} - 12x - 31.\]