TITLE: Integral of $(\log x)^3$ (Spivak's Calculus, Chapter 19, Problem 3v)
QUESTION [5 upvotes]: $$\int (\log x)^3\,dx$$

I solved the problem by applying integration by parts twice:
First, I write the integrand as $(\log x)^2\cdot\log x$, and then I set $u=(\log x)^2 \Rightarrow du=\frac{2\log x}{x}dx$ and $dv=\log x\,dx \Rightarrow v=x\log x-x$:
$$\begin{align}\int (\log x)^2\cdot\log x\,dx&=x(\log x)^3-x(\log x)^2-\left(\int \frac{2\log x}{x}(x\log x-x)\,dx\right)\\&=x(\log x)^3-x(\log x)^2-\left(\int 2(\log x)^2\,dx-\int 2\log x\,dx\right)\\&=x(\log x)^3-x(\log x)^2-2\int (\log x)^2\,dx+\underbrace{\int 2\log x\,dx}_{=\,2x\log x-2x} \end{align}$$
Now, the integral of $(\log x)^2$ needs to be solved by integration by parts. I set $u=\log x\Rightarrow du=\frac{dx}{x}$ and $dv=\log x\,dx\Rightarrow v=x\log x-x$:
$$\begin{align}\int (\log x)^2\,dx&=x(\log x)^2-x\log x-\left(\int \frac{x\log x-x}{x}\,dx\right)\\&=x(\log x)^2-x\log x-\left(\int \log x\,dx-\int dx\right)\\&=x(\log x)^2-x\log x-(x\log x-2x)\\&=x(\log x)^2-2x\log x+2x\end{align}$$
Substituting the result of $\int (\log x)^2\,dx$ into the solution:
$$\begin{align}\int (\log x)^2\cdot\log x\,dx&=x(\log x)^3-x(\log x)^2-2(\overbrace{x(\log x)^2-2x\log x+2x}^{\,=\int\,(\log x)^2dx})+2x\log x-2x\\&=x(\log x)^3-x(\log x)^2-2x(\log x)^2+4x\log x-4x+2x\log x-2x\\&=x(\log x)^3-3x(\log x)^2+6x\log x-6x\end{align}$$
Therefore $$\int (\log x)^3\,dx=x(\log x)^3-3x(\log x)^2+6x\log x-6x$$
(I omitted the annoying $+C$ in my calculations)
My question is: Is there any more elegant and quicker solution?

REPLY [3 votes]: I wouldn't necessarily call this quicker or more elegant, but it's certainly an alternative solution, and those are always nice to know.
This one uses Feynman's trick of differentiating under the integral sign after introducing an arbitrary parameter (as mentioned in a recent episode of the TV show "The Big Bang Theory", if you're into that sort of thing).
Start off with the substitution $y = \log x$, making the integral $\displaystyle \int y^3 e^y dy$.
Introduce $\displaystyle I(n,y) = \int e^{ny} dy$ and observe that the original integral is $\displaystyle \frac{\partial^3}{{\partial n}^3} I(n,y)$ evaluated at $n=1$.
All that remains is to work that out.
Start with $\displaystyle I(n,y) = \frac{1}{n}e^{ny} + c$ and evaluate the third partial derivative wrt $n$.
You'll end up with the same answer. Algebraically, I'm not sure if it saves any more work, but I find repeated differentiation slightly easier than repeated integration by parts.  In any case, I thought you might like this slightly unconventional approach.