Integration by substitution vs. polynomial expansion first....different results?? I came across a textbook problem that showed an integral solved with the substitution method:
$$\int_a^b(b-x)^2dx = \left(-\frac{(b-x)^3}{3}\right)\Biggl\vert_a^b$$
I then attempted to solve the same definite integral by expanding out the polynomial first and then integrating.  Step 1 I got this:
$$\int_a^b(b^2 - 2bx +x^2)dx$$
Next, I integrated each part of the polynomial and got this:
$$=(b^2x - bx^2 + \frac{x^3}{3})\Biggl\vert_a^b$$
I must have done something wrong here since these results are not equivalent.  Where am I missing something?  Thanks for your help!
 A: Not sure why you think the results are not equivalent.
If you evaluate the first, you get
\begin{align*}
\left.\left(-\frac{(b-x)^3}{3}\right)\right|_a^b &= -\frac{(b-b)^3}{3} + \frac{(b-a)^3}{3}\\
&= \frac{1}{3}b^3 - b^2a + ba^2 - \frac{1}{3}a^3.
\end{align*}
On the other hand, if you evaluate your second expression, you get
\begin{align*}
 \left.\left(b^2x-bx^2 +\frac{x^3}{3}\right)\right|_a^b &= b^3 - b^3 + \frac{b^3}{3} - b^2a + ba^2 - \frac{a^3}{3}\\
&= \frac{1}{3}b^3 - b^2a + ba^2 -\frac{1}{3}a^3,
\end{align*}
Exactly the same answer. Just because they look different at first glance does not mean they are different.
A: $$I(x)=\int(b-x)^2dx$$
Let $u=b-x$. Therefore $dx=-du$
$$I(x)=-\int u^2du=\frac{-1}{3}u^3+C=\frac{-1}{3}(b-x)^3+C$$
Thus:
$$I(b)-I(a)=\frac{-1}{3}((b-b)^3-(b-a)^3)=\frac{(b-a)^3}{3}$$
A: If you pretend that
$$\int_a^b(b^2 - 2bx +x^2)\ dx = \left(-\frac{b^3}3 +  b^2x - bx^2 + \frac{x^3}{3}\right)\Biggl\vert_a^b$$
by setting the integration constant to $-\frac{b^3}3$, you should see that the two approaches give the same result.
A: It's your first integral which is wrong, use a substitution $u=b-x$ to transform the integral:
$$\int_{a}^{b}(b-x)^{2}dx=\int_{0}^{b-a}u^{2}du$$
If you go through the algebra, this is the same as your second integral.
