# Integration by parts: how you do it, and why it works

Integration by parts is one of the two important integration methods to learn in C4 (the other is substitution ((“What about function-derivative!?” That’s a special case of substitution.)) ). In this article, I want to run through when you do it, how you do it, and why it works, just in case you’re interested.

### When you use integration by parts

Integration by parts is most useful:

- When substitution doesn’t look promising; or
- When integrating two things multiplied together; or
- When you have a logarithm knocking around; or
- When you can’t think what else to do.

The last one of those doesn’t always work, but it can be worth a shot in an exam if you’re completely out of other ideas.

### How you integrate by parts

To integrate by parts, you always start with a product: two things multiplied together. A typical example:

$\int xe^x\d x$

There are two things there: an $x$ and and $e^x$. You’re going to call these $u$ and $v^\prime$ (($\d v/\d x$ is more ideal, but saving space beats proper notation here)) - the question is, which way around?

The rule is, you usually want $u$ to be something that gets simpler when you differentiate it. In C4, that means:

- If you have a $\ln$ anywhere, that will be $u$; otherwise
- If you have an $x$ or an $x^n$ anywhere, that will be $u$.

Here, we don’t have a $\ln$, but we have an $x$, so we’ll let $u = x$ and $v^\prime = e^x$.

We need $u^\prime$, which we get by differentiating $u$, so $u^\prime = 1$; we get $v$ by integrating $v^\prime$ with respect to $x$, getting $v^\prime = e^x$. (You don’t need a constant of integration right here).

If you look in the formula book, you’ll see something like $\int u \frac{\d v}{\d x}~\d x = uv - \int v \frac{\d u}{\d x}~\d x$, which is your template for how to proceed. You started with what’s on the left hand side, so now you need to figure out the right.

$uv$ is easy enough - that’s $xe^x$. The other term is harder: $\int vu^\prime~\d x = \int (e^x)(1)~\d x$… oh, wait, it’s not actually that hard. It’s just $e^x + c$. That gives a final answer:

$\int xe^x~\d x = xe^x - (e^x + c)$

You can tidy that up a bit - there’s a factor of $e^x$ in the first two terms, and you can finagle the constant to be nicer, so you end up with $e^x(x-1) + C$. Lovely!

(If you’re not sure, you can differentiate it back using the product rule to check it gives the original *integrand* $xe^x$. It does.)

Another example, in less excruciating detail: let’s find $\int 4x \ln(x)~\d x$

Here, we have a $\ln$, so that’s going to be $u$; that makes $u^\prime = \frac 1x$.

$v^\prime$ is clearly $4x$, making $v = 2x^2$.

Now apply the parts formula: $\int u \frac{\d v}{\d x}~\d x = uv - \int v \frac{\d u}{\d x}~\d x$

The terms on the right hand side are $uv = 2x^2 \ln (x)$ and $\int vu^\prime~\d x = \int 2x^2 \times \frac 1x~\d x$, or - more reasonably - $\int 2x~\d x = x^2 + c$.

Putting it together, $\int x\ln(x)~\d x = 2x^2 \ln(x) - (x^2 + c)$, or (with some tidying up) $x^2(2 \ln(x) - 1) + C$. Again, you can check it using the product rule.

### But where does the integration by parts formula come from?

I thought you’d never ask.

You notice how you checked both of these with the product rule? That’s not a coincidence. Let’s start there:

$\frac{\d}{\d x}(uv) = u \frac{\d v}{\d x} + v\frac{\d u}{\d x}$

If you integrate both sides with respect to $x$, you get:

$uv = \int u \frac{\d v}{\d x}~\d x + \int v \frac{\d u}{\d x}~\d x$

See where it’s going? Take the second term on the right over to the left, and you have:

$uv - \int v \frac{\d u}{\d x}~\d x = \int u \frac{\d v}{\d x}~\d x$, or

$\int uv^\prime~\d x = uv - \int vu^\prime~\d x$, as required.

See? It all fits together quite neatly.