### 15.4.5 Integration by Parts

We already know how to differentiate the product of two functions (see Section 15.3.3: Product & Quotient Rules), but what about integrating them?

##### Question 15.4.19 Suppose we want to find $\int x \cos x \dif x$, so we’re looking to find a function that has the derivative $x\cos x$. Any ideas?

1. Our first thought might be ‘$\frac{\dif}{\dif x} \sin x = \cos x$ so maybe something like $x\sin x$ might work.’ See if that works, and if it doesn’t then modify it so that it does. Show assumed knowledge

2. What about a definite integral? Find $\int_0^{\pi/2} x\cos x\dif x$ Show answer

What we just did is called integration by parts, which is commonly used to integrate the product of two functions. Let’s work on a general formula which we can apply to any two functions.

##### Question 15.4.20 You can apply any operation to both sides of an equation as long as you do the same thing to each side; this works for integration as well as differentiation. By integrating both sides of the product rule, show that $\int f’(x)g(x) \dif x = f(x)g(x) - \int f(x) g’(x) \dif x.$ Show answer

Whenever we use integration by parts there is a choice of which function to regard as $f’(x)$ and which as $g(x)$. When we integrated $x\cos x$ above, we used $f’(x) = \cos x$ and $g(x) = x$ which was a good choice because that makes $f(x)g’(x) = \sin x$ which is easily integrable. If we had done it the other way and made $f’(x) = x$ and $g(x) = \cos x$ then $f(x)g’(x) = -\frac{1}{2}x^2 \sin x$ which is much harder to integrate. You must make the choice so that $f(x)g’(x)$ is easily integrable.

When I use integration by parts, I think of it as ‘integrate one function, then differentiate the other’ (integrate $f’(x)$ to get $f(x)$ then differentiate $g(x)$ to get $g’(x)$). For example, with $x\cos x$ you integrate the $\cos x$ part, leaving the $x$ part unchanged, to get $x \sin x$, then you write ‘$-\int$’, then you differentiate the $x$ part, leaving the $\sin x$ unchanged, to get $f(x)g’(x) = 1\sin x$. Putting it all together gives $\int x\cos x \dif x = x\sin x - \int 1\sin x \dif x.$ If you can ‘integrate one function, then differentiate the other’ in your head then you can check if the result is easily integrable to see if you made the right choice before you write anything down.

##### Question 15.4.21 Now let’s try applying the formula we derived to find $\int x\ln x \dif x$. Show answer

When doing a definite integral, you can just sub the limits in as usual after finding the indefinite integral, like so: $\int_a^b f’(x)g(x) \dif x = \left[ f(x)g(x) - \int f(x)g’(x)\dif x \right]_a^b$ or what’s usually more convenient is to apply the limits separately to the two parts: $\int_a^b f’(x)g(x) \dif x = \left. f(x)g(x) \right|_a^b - \int_a^b f(x)g’(x)\dif x$

##### Question 15.4.22 Find $\int_0^2 x e^x \dif x$. Show answer

Remember:
The formula for integration by parts, with indefinite integrals: $\int f’(x)g(x)\dif x=f(x)g(x) - \int f(x)g’(x)\dif x$

And with definite integrals: $\int_a^b f’(x)g(x)\dif x=\left.f(x)g(x)\right|_a^b - \int_a^bf(x)g’(x)\dif x$ Show practice questions

Now for some applications of integration by parts which will require some ingenuity.

##### Question 15.4.23 Find $\int\ln x\dif x$. Show hint

##### Question 15.4.24 Find $\int x^2\cos x\dif x$. Show hint

##### Question 15.4.25 Find $\int\e^{x}\cos x\dif x$. Show hint

##### Question 15.4.26 Find $\int \e^{\sqrt{x}}\dif x$. Show hint