$$\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?
$\endgroup$ 13 Answers
$\begingroup$Let $x = e^y$, $dx = e^y \, dy$, giving $$\int (\log x)^3 \, dx = \int y^3 e^y \, dy.$$ Now use tabular integration: $$\begin{array}{|cc|c|} \hline y^3 & e^y & + \\ 3y^2 & e^y & - \\ 6y & e^y & + \\ 6 & e^y & - \\ \hline \end{array}$$ to obtain $$\int y^3 e^y \, dy = y^3 e^y - 3y^2 e^y + 6y e^y - 6 e^y + C.$$ Substituting back for $x$ gives the desired result.
Another example of tabular integration: compute $$\int (x^4 + x^2) e^{-3x} \, dx.$$ We write $$\begin{array}{|cc|c|} \hline x^4 + x^2 & -\frac{1}{3}e^{-3x} & + \\ 4x^3 + 2x & \frac{1}{9} e^{-3x} & - \\ 12x^2 + 2 & -\frac{1}{27} e^{-3x} & + \\ 24x & \frac{1}{81} e^{-3x} & - \\ 24 & -\frac{1}{243} e^{-3x} & + \\ \hline \end{array}$$ to get $$\begin{align*} \int (x^4 + x^2) e^{-3x} \, dx &= -\frac{1}{3}(x^4 + x^2)e^{-3x} - \frac{1}{9}(4x^3 + 2x)e^{-3x} - \frac{1}{27}(12x^2 + 2)e^{-3x} \\ &\quad - \frac{1}{81}(24x)e^{-3x} - \frac{24}{243}e^{-3x} + C \\ &= -\frac{e^{-3x}}{81} (27x^4 + 36x^3 + 63x^2 + 42x + 14) + C. \end{align*}$$
$\endgroup$ 1 $\begingroup$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.
$\endgroup$ $\begingroup$Yes, there is (But I guess is the same amount of work). Put $z = \log x $. Then, your integral becomes
$$ \int z^3 e^z dz $$
You can also use integration by parts to solve this problem. However, I would like to show you another technique. Write
$$ \int z^3 e^z dz = (Az^3 + Bz^2 + Cz + D)e^z $$
Apply fundamental theorem of calculus and the product rule and find the coeficients $A,B,C,D$. In general, if you have an integral of the form
$$ \int P_n(x) e^x dx $$
where $P_n(x) $ is a polynomial of degree $n$, you assume that the integral will have the following form:
$$ Q_n(x) e^x $$
where again $Q_n$ is a polynomial of degree $n$. Again, apply fundamental theorem of calculus to obtain your coefficients.
$\endgroup$