How to integrate $\int_a^b (x-a)(x-b)\,dx=-\frac{1}{6}(b-a)^3$ in a faster way? $\displaystyle \int_a^b (x-a)(x-b)\,dx=-\frac{1}{6}(b-a)^3$
$\displaystyle \int_a^{(a+b)/2} (x-a)(x-\frac{a+b}{2})(x-b)\, dx=\frac{1}{64}(b-a)^4$ 
Instead of expanding the integrand, or doing integration by part, is there any faster way to compute this kind of integral?
 A: If you would like a geometric argument (that can be better visualized for your first integral), note that 
$\int_a^b (x - a)(x - b)\, dx = -\int_a^b\int_{x - b}^0\int_0^{x - a} 1 \, dzdydx$
Which is negative the volume of a pyramid with base area $(b - a)^2/2$ and height $b -a$. Therefore the value of your integral is $-(b - a)^3/6$.
A: If you're looking for elementary methods there's not going to be a faster one than expanding the integral or using integration by parts. For another solution you could remember the formula, and I think the following heuristic is a good mnemonic for that:
We know that $\int_a^b(x-a)(x-b)\,dx$ is a polynomial of degree $3$ in "the variables $a$ and $b$", so if we fix $b$ we might think of $\int_a^b(x-a)(x-b)\,dx$ as a polynomial $p(a)$ of degree $3$. To determine $p(a)$ notice that for $a$ close to $b$ we have
$$
\int_a^b(x-a)(x-b)\,dx\approx (b-a)(b-a)(a-b).
$$
This is a terrible estimate, but it tells us that $p(a)$ must have a zero of order $3$ in $b$, so $p(a)=C(b-a)^3$ for some $C$, which we can determine by calculating $p(a_0)$ for a suitable choice of $a_0$. For example
$$
Cb^3=p(0)=\int_0^bx(x-b)\,dx=\frac{b^3}{3}-\frac{b^3}{2}=-\frac{b^3}{6}.
$$
For the second integral the same procedure works. In that case this other terrible estimate
$$
\int_a^{\frac{a+b}{2}}(x-a)\left(x-\frac{a+b}{2}\right)(x-b)\,dx\approx\left(a-\frac{a+b}{2}\right)(b-a)\left(a-\frac{a+b}{2}\right)(a-b)
$$
tells us that $p(a)$ must have a zero of order $4$ in $b$, and calculating $p(0)$ (for example) again determines $p(a)$.
A: You can first get rid of the integration bounds by the linear transform $a+(b-a)t$:
$$\int_a^b (x-a)(x-b)\,dx=(b-a)^3\int_0^1t(t-1)\,dt.$$
Mentally expanding the polynomial, the integral is $\frac13-\frac12=-\frac16$.
For the other case, $a+(b-a)t/2$:
$$ \int_a^{(a+b)/2} (x-a)(x-\frac{a+b}{2})(x-b)\, dx=\frac{(b-a)^4}{16}\int_0^1t\left(t-1\right)(t-2)\,dt.$$
Also mentally, $(\frac14-1+1)$$\frac1{16}=\frac1{64}$.

Also, using a remark by @mickep, Newton's formula applies and
$$\int_0^1t(t-1)\,dt=\frac16\left(0-4\frac12\frac12+0\right)=-1,$$
$$\int_0^1t(t-1)(t-2)\,dt=\frac16\left(0+4\frac12\frac12\frac32+0\right)=\frac14.$$
A: Hint. One may use the fact that
$$
4uv=(u+v)^2-(u-v)^2 \tag1
$$ giving
$$
\begin{align}
4\int_a^b (x-a)(x-b)\:dx=4\int_a^b \left(x-\frac{a+b}2\right)^2\:dx-\int_a^b (b-a)^2\:dx \tag2
\end{align}
$$ which is easier to evaluate.
Then, one has $$
\begin{align}
&4\int_a^b (x-a)(x-b)\left(x-\frac{a+b}2\right)\:dx
\\\\&=\int_a^b \left[4\left(x-\frac{a+b}2\right)^2- (b-a)^2\right]\left(x-\frac{a+b}2\right)\:dx
\\\\&=4\int_a^b \left(x-\frac{a+b}2\right)^3\:dx- (b-a)^2\int_a^b\left(x-\frac{a+b}2\right)\:dx\tag3
\end{align}
$$ which is easier to evaluate.
A: You can do this with substitution and Cavalieri's formula:
$$
    \int_0^1 u^n \,du = \frac{1}{n+1}
$$
For the first one, let $u= \frac{x-a}{b-a}$.  Then $x = (b-a)u +a$, which means $x-a = (b-a)u$ and $x-b = (b-a)(u-1)$.  Also $dx=(b-a)\,du$.  So
\begin{align*}
    \int_a^b (x-a)(x-b)\,dx 
    &= (b-a)^3 \int_0^1 u (u-1)\,du
    = (b-a)^3 \int_0^1 (u^2 - u) \\
    &= (b-a)^3 \left(\frac{1}{3}-\frac{1}{2}\right) 
     = -\frac{1}{6}(b-a)^3
\end{align*}
For the second one, let $u= \frac{2}{a-b}\left(x-\frac{a+b}{2}\right)$.  Then:
\begin{align*}
    x-a &= \frac{a-b}{2}(u-1) \\
    x-b &= \frac{a-b}{2}(u+1) \\
    x - \frac{a+b}{2} &= \frac{a-b}{2}u \\
    dx  &= \frac{a-b}{2}\,du
\end{align*}
So
\begin{align*}
    \int_a^{(a+b)/2} (x-a)\left(x-\frac{a+b}{2}\right)(x-b)\,dx
    &= \left(\frac{a-b}{2}\right)^4\int_1^0(u-1)u(u+1)\,du 
     = -\frac{(b-a)^4}{16}\int_0^1 (u^3-u)\,du \\
    &= -\frac{(b-a)^4}{16}\left(\frac{1}{4}-\frac{1}{2}\right)
     = -\frac{1}{64}(b-a)^4
\end{align*}
This has less integration, but it took some time to get the substitution right.
A: One way is to use Simpson's rule.
Without it, one could argue what is faster, but: 
If $A=(a+b)/2$ and $D=(b-a)/2$, then your first integrand is
$$
(x-A+D)(x-A-D)=(x-A)^2-D^2.
$$
Thus
$$
\begin{aligned}
\int_a^b (x-a)(x-b)\,dx &=\frac{1}{3}\bigl((b-A)^3-(a-A)^3\bigr)-2D^3\\
&=\frac{1}{3}\bigl(D^3+D^3)-2D^3=-\frac{1}{6}(b-a)^3.
\end{aligned}
$$
For the second one you write the integrand as
$$
\bigl((x-A)^2-D^2\bigr)(x-A)=(x-A)^3-D^2(x-A)
$$
and do a similar calculation. I leave that to you.
