# Is this composition of polynomial correct?

Suppose $p(x)=x^2+5x+3$ and $q(x)=3x^3-3x+7$. Write the expression $(q \circ p)(x)$ as a sum of terms, each which is a constant times the power of $x$.

Here is my work for the problem:
$(q\circ p)(x)=3(x^2+5x+3)^3-3(x^2+5x+3)+7$
$(q\circ p)(x)=3(x^6+125x^3+27)-3x^2-15x-9+7$
$(q\circ p)(x)=3x^6+375x^3+81-3x^2-15x-2$
$(q\circ p)(x)=3x^6+375x^3-3x^2-15x+79$

Did I do something wrong while working with this problem? The final answer I got wasn't in the multiple choice answers. I went over this problem 3 times and cannot find what I am doing wrong.

-
Your understanding of composition is fine; it’s just your algebra that went astray. See @Jasper’s answer. –  Brian M. Scott Sep 27 '12 at 20:42

The mistake you made is assuming that $(a+b+c)^3=a^3+b^3+c^3$. Note that $(a+b+c)(a+b+c)=a^2+ab+ac+ba+b^2+bc+ca+cb+c^2$. Simplify and multiply by $a+b+c$ again to get the cube. Alternatively you can rewrite $q(x)=3x(x^2-1)+7$ and work from there.
Is there a shortcut to multiply this out? I did $(a+b+c)^2$ first then multiplied that by $(a+b+c)$ again. It was very long and messy. –  Kot Sep 27 '12 at 20:45
As Jasper noted you did wrong here: $$...=3(x^2+5x+3)^3...$$ $$...=3(x^6+125x^3+27)-...$$ In fact $$(a+b+c)^3=a^3 + 3a^2b + 3a^2c + 3ab^2 + 6abc + 3ac^2 + b^3 + 3b^2c + 3bc^2 + c^3$$ we have $q(p(x))=3x^6+45x^5+252x^4+645x^3+753x^2+390x+79$