Integral of $x^n \log(x)$

Posted on Jul 11, 2020

This integral turns out to be easier than you might think. First of all, note that we have to use integration by parts. Integration by parts is defined as follows:

$$\int uv'\, dx = uv - \int u'v\, dx$$

When computing $\int x^{n} \log(x)\, dx$, we will want to differentiate $x^n$ and integrate $\log(x)$. Therefore, we choose $u = x^n$ and $v' = \log(x)$. First of all, note that the integral of $\log(x)$ is $x\log(x) - x$, and it follows that $v = x\log(x) - x$. By differentiation, we find that $u' = nx^{n-1}$.

Using integration by parts, we have

$$\int x^{n} \log(x)\, dx = x^n (x\log(x) - x) - \int (nx^{n-1})(x\log(x) - x)\,dx.$$

Note that the second term on the right-hand side can be simplified tremendously! We factor:

$$\int x^{n} \log(x)\, dx = x^{n+1} \log(x) - x^{n+1} - \int nx^{n}\log(x) - nx^{n}\,dx.$$

We bring $n$ in front of the rightmost integral and we split it:

$$\underbrace{\int x^{n} \log(x)\, dx}_{\text{These two integrals...}} = x^{n+1} \log(x) - x^{n+1} - n\underbrace{\int x^{n}\log(x)\,dx}_{\text{... are identical}} + n\int x^{n}\,dx.$$

We add $n\int x^{n}\log(x)\,dx$ on both sides and we compute the rightmost integral, which is trivial:

$$\int x^{n} \log(x)\, dx + n\int x^{n}\log(x)\,dx = x^{n+1} \log(x) - x^{n+1} + \frac{n}{n+1} x^{n+1}.$$

We factor on both sides:

$$(n+1)\int x^{n} \log(x)\, dx = x^{n+1} \left(\log(x) - 1 + \frac{n}{n+1}\right)$$

Finally, we have:

$$\int x^{n} \log(x)\, dx = \frac{x^{n+1}}{n+1} \left(\log(x) - \frac{1}{n+1}\right) + C$$

Never forget the constant!