The crazy way you have to integrate logs
When you learn how to integrate by parts, you’re probably told that a good rule of thumb is that if you have a power of $x$, that’s going to be the thing you differentiate.
That’s a pretty good heuristic((heuristic, n: a big word for ‘rule of thumb’.)), but there are two places it breaks down: one, if you’re doing something that doesn’t have a power of $x$ in (in which case, integrating by parts is unlikely to be the right method - in C4, at least); and second, most commonly, if you have to integrate logs.
Repeat after me: “I don’t know how to integrate logs directly. I know how to differentiate them, though.” You do know how to differentiate $\ln(x)$, right? You get $\frac{1}{x}$.
So, when you have a log in your integral: a) you’re likely to do it by parts, and b) the $\ln$ is the thing you differentiate (the $u$).
So, something like $\int x \ln (x) dx$, you would let $u = \ln(x)$, $\frac{dv}{dx} = x$; you’d differentiate the log to get $\frac{du}{dx} = \frac{1}{x}$ and integrate the $x$ to get $v = \frac{x^2}{2}$. Then, you apply the parts formula ($\int u \frac{dv}{dx} dx = uv - \int v \frac{du}{dx} dx$) to get that the integral is $(\frac{x^2}{2}) \ln(x) - \frac {x}{2} dx = (\frac{x^2}{2}) \ln(x) - \frac{x^2}{4} + c$. Easy.
But Colin, I hear you asking, what about $\ln (x)$ on its own? Surely you can’t integrate that by parts, there’s only one of it!
You’re right, there’s only one of it (and stop calling me Shirley). But you can write it - and this is a dirty, sneaky trick - as $1 \ln (x)$. Then you can integrate it just like before: $u = \ln(x)$, $\frac{dv}{dx} = 1$, so $\frac{du}{dx} = \frac{1}{x}$ and $v = x$. You get the integral to be $x \ln (x) - \int 1 dx = x \ln (x) - x + c$.
The only time I can think of where you might use a different method is when the argument of $\ln$ is something ugly - like $\int x \ln (x^2 + 1)$. In that case, you’re likely to need a substitution… which is a topic for another day.