How to integrate $\int_a^b (x-a)(x-b)\,dx=-\frac{1}{6}(b-a)^3$ in a faster way?

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.


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$.


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)$.