$$\def\ans#1{\bbox[border:1px solid green,6pt]{#1}}$$

# Integration by Parts

## Introduction to IBP

As I mentioned in the introduction to u-substitution, all of the methods of integration that we'll see in this course are really just different variations of substitution; remember, the list of functions that we actually know how to integrate is pretty limited, and anything more complicated must be reduced to one of the forms for which we've memorized the integral.

When it comes to integration by parts, as the name suggests, we'll split the integral into two parts. We'll call these parts $$u$$ and $$dv$$, instead of $$u$$ and $$du$$. The key to integration by parts is the following formula (which we'll derive below: $\int u \ dv = uv - \int v \ du.$

Our task, then, is to pick $$u$$ and $$dv$$ carefully, and then figure out what $$du$$ and $$v$$ are so that we can plug everything into the IBP formula and evaluate the integral $$\displaystyle\int v \ du$$, which will be simpler if we've done our job correctly.

Take the following integral, for example (note that if we tried u-substitution on it, we'd quickly get frustrated): $\int x \sin x \ dx$

We're trying to split the integral into two pieces, and of course those two pieces are going to be $$x$$ and $$\sin x$$. The question is which one of them should be $$u$$, and which one should be $$dv$$? We could always try it one way, and if we get stuck, start over and define them the other way. I'll give you a better way to decide in a bit, but for now, I'll just tell you to let $$u=x$$ and $$dv = \sin x \ dx$$. Notice that $$dx$$ will always be part of $$dv$$.

Okay, so we've got $$u$$ and $$dv$$, but we also need $$du$$ and $$v$$. We'll get $$du$$ the same way we did when we did u-substitution, and to get $$v$$, we'll reverse that process. Here's what we end up with:

$\begin{array}{l l}u = x & v = -\cos x\\ du = dx \hspace{0.5in}& dv = \sin x \ dx\end{array}$

Plugging these into the IBP formula gives us a simpler integral that we can evaluate:

\begin{align}\int u \ dv &= uv - \int v \ du\\ \int x \sin x \ dx &= -x\cos x - \int (-\cos x) \ dx\\ &= -x\cos x + \int \cos x \ dx\\ &= \ans{-x\cos x + \sin x + C} \end{align}

Notice what would have happened if we had reversed our decision and picked $$u=\sin x$$ and $$dv = x \ dx$$: $\begin{array}{l l}u = \sin x & v = \dfrac{1}{2}x^2\\ du = \cos x \ dx \hspace{0.5in}& dv = x \ dx\end{array}$ Substituting this into the IBP formula just sets up an even more complicated integral, which is the opposite of what we want. \begin{align}\int u \ dv &= uv - \int v \ du\\ \int x \sin x \ dx &= \dfrac{1}{2}x^2 \sin x - \int \dfrac{1}{2}x^2 \cos x \ dx\end{align}

Clearly, then, it matters which piece we pick to be $$u$$ and which we pick to be $$dv$$. Again, you could try both ways and see which one works, but we'll have a more consistent way to pick them that will cut down on complications.

## Procedure

Here's what we did in that example:

1. Pick $$u$$ and $$dv$$ (more on this in a moment).
2. Find $$du$$ (by differentiating $$u$$ and tacking on $$dx$$) and $$v$$ (by integrating $$dv$$).
3. Plug these four pieces into the formula $\int u \ dv = uv - \int v \ du.$
4. Evaluate the integral $$\int v \ du$$ (this may require u-substitution or even integration by parts again).

### How do you pick $$u$$ and $$dv$$? (LIPTE)

Let's say you don't want to have to try both functions as $$u$$. There's a simple acronym that can help: LIPTE. This stands for all the types of functions that we'll run across. The closer a function is to the top of the list, the more likely we'll be to pick it as $$u$$:

 $$u$$ Logarithmic $$\uparrow$$ Inverse trigonometric Polynomial-like (including things like $$\sqrt{x}=x^{1/2}$$) $$\downarrow$$ Trigonometric $$dv$$ Exponential
So to decide which function should be $$u$$ and which should be $$dv$$, line them up along this scale and see which ends up higher on the list.

### Where does that formula come from?

We used the IBP formula without any idea where it came from. However, as you'll see as you do more examples, integration by parts is usually the way to go when you see the product of two functions (assuming u-substitution doesn't work). Therefore, it shouldn't come as a huge surprise that the formula is based on the Product Rule for differentiation. Specifically, if $$u$$ and $$v$$ are two functions of $$x$$, $\dfrac{d}{dx}[uv] = uv' + vu'$ so, by antidifferentiating,

\begin{align} \int uv' + vu' \ dx &= uv\\ \int uv' \ dx + \int vu' \ dx &= uv\\ \int u\dfrac{dv}{dx} \ dx + \int v \dfrac{du}{dx} \ dx &= uv\\ \int u \ dv + \int v \ du &= uv\\ \int u \ dv &= uv - \int v \ du. \end{align}

While you don't need to know how to derive this formula in order to do problems, it's helpful to at least see that it's based on something reasonable; formulas aren't just dropped from the sky.

## Examples

Use integration by parts to integrate $$\displaystyle\int t^2e^{t} \ dt.$$

#### Solution

Let's use the LIPTE method to pick which function should be $$u$$ and which should be $$dv$$. The two functions we have are $$t^2$$ and $$e^t$$:

 $$u$$ Logarithmic $$\uparrow$$ Inverse trigonometric $$t^2$$ Polynomial-like (including things like $$\sqrt{x}=x^{1/2}$$) $$\downarrow$$ Trigonometric $$e^t$$ $$dv$$ Exponential

Based on this scale, we should define $$u=t^2$$ and $$dv=e^t$$. We now need to find $$du$$ and $$v$$, by differtiating $$u$$ and integrating $$dv$$, respectively:

$\begin{array}{l l}u = t^2 & v = e^t\\ du = 2t \ dt \hspace{0.5in}& dv = e^t \ dt\end{array}$

Now we're ready to plug everything into the formula:

\begin{align}\int u \ dv &= uv - \int v \ du\\ \int t^2 e^t \ dt &= t^2 e^t - \int 2te^t \ dt\end{align}

The next question is: how can we integrate $$2te^t$$? This also won't yield to u-substitution, but let's try doing integration by parts again. Thinking ahead, we can imagine that it might work, because we went from an integral involving $$t^2$$ and the exponential to an integral involving $$t$$ and the exponential, so maybe next time we'll get an integral with just a constant and the exponential, which we can handle!

The trickiest part here is writing it in a way that is clear, so that we don't lose track of what we've already written. To help with this, let's try using $$w$$ and $$dz$$ instead of $$u$$ and $$dv$$, since we already defined those. If you want to use $$u$$ and $$dv$$ again, that's fine, as long as you're careful.

$\begin{array}{l l}w = 2t & z = e^t\\ dw = 2 \ dt \hspace{0.5in}& dz = e^t \ dt\end{array}$

Now, based on the formula, we can go back to the work that we've already done and replace $\int 2te^t \ dt$ with $2te^t - \int 2e^t \ dt.$

\begin{align}\int t^2 e^t \ dt &= t^2 e^t - \int 2te^t \ dt\\ &= t^2 e^t - \left[2te^t - \int 2e^t \ dt\right]\\ &= t^2e^t - 2te^t + \int 2e^t \ dt\\ &= \ans{t^2e^t - 2te^t + 2e^t + C}\end{align} There are some cases like this where we have to carry out integration by parts several times on the same problem. Of course, you can imagine cases where we'd have to do it three or more times; those get tedious, but as long as you keep all the signs straight by being careful with parentheses, you can get through it.

#### Try it yourself:

(click on a problem to show/hide its answer)

1. $$\displaystyle\int x \cos x \ dx$$
2. $$x \sin x + \cos x + C$$

3. $$\displaystyle\int t \sin (2t) \ dt$$
4. $$-\dfrac{1}{2} t \cos (2t) + \dfrac{1}{4} \sin (2t) + C$$

5. $$\displaystyle\int x^2 \sin (\pi x) \ dx$$
6. $$-\dfrac{1}{\pi} x^2 \cos (\pi x) + \dfrac{2}{\pi^2} x \sin (\pi x) + \dfrac{2}{\pi^3} \sin (\pi x) + C$$

Evaluate the following integral: $$\displaystyle\int \dfrac{\ln y}{\sqrt{y}} \ dy.$$

#### Solution

Using LIPTE again, we should define $$u=\ln y$$ and $$dv = \dfrac{1}{\sqrt{y}} \ dy$$. A note of caution here: some students are tempted to define $$dv = \sqrt{y} \ dy$$, but you must be careful. You must define $$u$$ and $$dv$$ in such a way that the function that you're attempting to integrate is exactly $$u$$ times $$dv$$; it can't be $$u$$ divided by $$dv$$ or anything else.

Now we can find $$du$$ and $$v$$, and plug these all into the formula:

$\begin{array}{l l}u = \ln y & v = 2y^{1/2}\\ du = \dfrac{1}{y} \ dy \hspace{0.5in}& dv = \dfrac{1}{\sqrt{y}} \ dy = y^{-1/2} \ dy\end{array}$ \begin{align}\int u \ dv &= uv - \int v \ du\\ \int \dfrac{\ln y}{\sqrt{y}} \ dy &= 2\sqrt{y}\ln y - \int 2y^{1/2} \cdot \dfrac{1}{y} \ dy\\ &= 2\sqrt{y}\ln y - \int 2y^{-1/2} \ dy\\ &= \ans{2\sqrt{y}\ln y - 4\sqrt{y} + C}\end{align}

#### Try it yourself:

(click on a problem to show/hide its answer)

1. $$\displaystyle\int p^5 \ln p \ dp$$
2. $$\dfrac{1}{6} p^6 \ln p - \dfrac{1}{36} p^6 + C$$

3. $$\displaystyle\int e^{-\theta} \cos (2 \theta) \ d\theta$$
4. $$-\dfrac{1}{5}e^{-\theta}\cos(2\theta) + \dfrac{2}{5}e^{-\theta}\sin(2\theta) + C$$

Evaluate the following integral: $$\displaystyle\int \ln x \ dx.$$

#### Solution

Whenever I show this one to my students, somebody always instictively jumps to saying that the integral of $$\ln x$$ is $$\dfrac{1}{x}$$. Be careful: the derivative of $$\ln x$$ is $$\dfrac{1}{x}$$. Up to this point, we've never seen the integral of $$\ln x$$.

It doesn't look like there are two functions here, but let's try integration by parts anyway (since it doesn't look like u-substitution will get us anywhere). Thinking in terms of LIPTE, the logarithmic function should clearly by $$u$$, but what can we define as $$dv$$? Well, all that's left after we let $$u=\ln x$$ is $$dx$$, so let's try setting $$dv = dx$$. Finding $$du$$ and $$v$$: $\begin{array}{l l}u = \ln x & v = x\\ du = \dfrac{1}{x} \ dx \hspace{0.5in}& dv = dx\end{array}$

When we plug these into the formula, we do get something that we can integrate: \begin{align}\int u \ dv &= uv - \int v \ du\\ \int \ln x \ dx &= x \ln x - \int x \cdot \dfrac{1}{x} \ dx\\ &= x \ln x - \int 1 \ dx\\ &= \ans{x \ln x - x + C}\end{align}

If you like, you can memorize the integral of the natural log function, but if not, you can always remember that we find it using integration by parts, and you can re-derive it if you need it.

#### Try it yourself:

(click on the problem to show/hide the answer)

$$\displaystyle\int (\ln x)^2 \ dx$$
$$x (\ln x)^2 - 2x \ln x + 2x + C$$

Evaluate the following integral: $$\displaystyle\int_0^1 \dfrac{y}{e^{2y}} \ dy.$$

#### Solution

This one is a definite integral, but just like we did with definite integrals using u-substitution, we'll start by dropping the limits of integration, do the indefinite integral, and then come back at the end (make sure you don't forget to!) and use limits with the Fundamental Theorem.

Use LIPTE again to pick $$u$$ and $$dv$$, and use those to find $$du$$ and $$v$$: $\begin{array}{l l}u = y & v = -\dfrac{1}{2}e^{-2y}\\ du = dy \hspace{0.5in}& dv = \dfrac{1}{e^{2y}} dy = e^{-2y} \ dy\end{array}$

Now plug these into the formula and integrate \begin{align}\int u \ dv &= uv - \int v \ du\\ \int \dfrac{y}{e^{2y}} \ dy &= -\dfrac{y}{2e^{2y}} - \int -\dfrac{1}{2}e^{-2y} \ dy\\ &= -\dfrac{y}{2e^{2y}} - \dfrac{1}{4}e^{-2y}\end{align}

Therefore, $\int \dfrac{y}{e^{2y}} \ dy = -\dfrac{y}{2e^{2y}} - \dfrac{1}{4e^{2y}},$ so plugging in the limits of integration: \begin{align}\int _0^1 \dfrac{y}{e^{2y}} \ dy &= -\dfrac{y}{2e^{2y}} - \dfrac{1}{4e^{2y}} \Bigg|_0^1\\ &= \left(-\dfrac{1}{2e^2} - \dfrac{1}{4e^2}\right) - \left(-\dfrac{0}{2e^0} - \dfrac{1}{4e^0}\right)\\ &= \ans{-\dfrac{1}{2e^2}-\dfrac{1}{4e^2}+\dfrac{1}{4}} = \dfrac{e^2-3}{4e^2}\end{align}

###### A Tricky Example

Evaluate the following integral: $$\displaystyle\int e^x \sin x \ dx.$$

#### Solution

You've been warned: this is a tricky example. Let's start the same way we have on all of these so far: pick $$u$$ and $$dv$$ using LIPTE as our guide, then find $$du$$ and $$v$$: $\begin{array}{l l}u = \sin x & v = e^x\\ du = \cos x \ dx \hspace{0.5in}& dv = e^x dx\end{array}$

When we plug these into the formula, we'll find that the resulting integral is one for which we'll need to use integration by parts again, just like in Example 1 above. \begin{align}\int u \ dv &= uv - \int v \ du\\ \int e^x \sin x \ dx &= e^x \sin x - \int e^x \cos x \ dx\end{align}

Like we did in that example, we'll define $$w$$ and $$dz$$ to do the second integration by parts: $\begin{array}{l l}w = \cos x & z = e^x\\ dw = -\sin x \ dx \hspace{0.5in}& dz = e^x dx\end{array}$

Using the formula again, we can go back to where we were and replace $$\int e^x \cos x \ dx$$: \begin{align}\int e^x \sin x \ dx &= e^x \sin x - \int e^x \cos x \ dx\\ &= e^x \sin x - \left[e^x \cos x - \int -e^x \sin x \ dx\right]\\ &= e^x \sin x - e^x \cos x - \int e^x \sin x \ dx \end{align}

At this point, you may be getting frustrated, thinking "But that integral is the one we started with! We're just going in circles!" This is where the trickiness comes in: because that integral is the one we started with, we can solve for it, just like we would solve for a variable: \begin{align}\int e^x \sin x \ dx &= e^x \sin x - e^x \cos x - \int e^x \sin x \ dx\\ \int e^x \sin x \ dx + \int e^x \sin x \ dx &= e^x \sin x - e^x \cos x\\ 2\int e^x \sin x \ dx &= e^x \sin x - e^x \cos x \ (+C)\\ \int e^x \sin x \ dx &= \ans{\dfrac{e^x \sin x - e^x \cos x + C}{2}} \end{align}

Admittedly, this type of integral doesn't arise very often, but it's a fun one to wrap up with.

#### Try it yourself:

(click on a problem to show/hide its answer)

1. $$\displaystyle\int x^4 (\ln x)^2 \ dx$$
2. $$\dfrac{1}{5} x^5 (\ln x)^2 - \dfrac{2}{25}x^5 \ln x + \dfrac{2}{125} x^5 + C$$

3. $$\displaystyle\int \cos x \cdot \ln(\sin x) \ dx$$
4. $$\sin x \cdot \ln (\sin x) - \sin x + C$$