Integration by parts

Reversed product rule

"Integration by parts" is another important integration technique. It is essentially the product rule running in reverse. In this lecture, we will learn how it works and why it works.

Integration by parts

"Integration by parts" is another important integration technique. It is essentially the product rule running in reverse, and it allows us to turn one integral into a potentially easier integral. In this lecture, we will learn how it works and why it works. We will also look at some advanced applications.

For example, this technique would allow us to compute integrals like \[ \int x e^x dx \quad\quad \int \ln(x) dx \quad\quad \int x^2 \cos(x) dx \ldots \]

Review. Suppose $u$ and $v$ are both differentiable functions of $x$, then the product rule tells us that \[ \frac{d}{dx} (uv) = \frac{du}{dx} v + u \frac{dv}{dx}. \] From this, we can easily derive the corresponding integral version.

Integrating both sides produces \[ uv = \int v \, du + \int u \, dv. \]

Rearranging the terms, we get \[ \int u \, dv = uv - \int v \, du, \] and this is the basis of this "integration by parts" technique.

For two functions $u$ and $v$ of $x$, under the assumption of differentiability of $u$ and integrability of $v$, \[ \int u \, dv = uv - \int v \, du.\]

The idea is that, if we can express an integral as $\int u \, dv$ for some choices of $u$ and $v$, then we can turn that integral into $uv - \int v \, du$ with the hope that we make the "right" choices so that the resulting integral is easier to deal with.

One example

Compute $\int x e^{x} dx.$

We will use $\int u \, dv = uv - \int v \, du.$

Solution. First, note that this integral cannot be computed with substitution. To integrate by parts, we want to choose $u$ and $dv$ so that $\int x e^{3x} dx = \int u \, dv$, yet the integral $\int v \, du$ it produced is simpler.

Choosing the "right" $u,v$ takes some practice, and we will discuss the strategies soon. For now, let's start with a choice and see how to apply it.

Let $\color{red}{u = x}$, and $\color{blue}{dv = e^{x} dx}$, then $\color{red}{du = dx}$, and $\color{blue}{v = \int e^{x} dx = e^{x}}$.

There's no need to include "$+C$" in $v$, as it will be hiding inside the integral we are going to produce, and we don’t have to worry about it until the last step.

Applying integration by parts, the original integral becomes \[ \int u \, dv = uv - \int v \, du = x e^{x} - \int e^{x} dx = x e^{x} - e^{x} + C. \]

Another example

Compute $\int \frac{\ln x}{x^2} dx$.

Again, we use $\int u \, dv = uv - \int v \, du.$

Solution. This integral also cannot be computed with substitution. To apply integration by parts, we want to choose $u$ and $dv$ so that $\int \frac{\ln x}{x^2} dx = \int u \, dv$, yet the integral $\int v \, du$ it produced is simpler. Again, start with a choice and only focus on how to apply this technique.

Let $\color{red}{u = \ln x}$, and $\color{blue}{dv = \frac{1}{x^2} dx}$, then $\color{red}{du = \frac{1}{x} \, dx}$, and $\color{blue}{v = \int \frac{1}{x^2} dx = - \frac{1}{x}}$.

$\displaystyle \int \frac{\color{red}{\ln x}}{\color{blue}{x^2}} dx\;$ $\displaystyle = \int \color{red}{u} \, \color{blue}{dv}\;$ $\displaystyle = \color{red}{u}\color{blue}{v} - \int \color{blue}{v} \, \color{red}{du};$ $\displaystyle = \color{blue}{-} \frac{\color{red}{\ln x}}{\color{blue}{x}} - \int \color{blue}{\left(- \frac{1}{x}\right)} \color{red}{\frac{1}{x} dx}$
$\displaystyle = \; - \frac{\ln x}{x} - \frac{1}{x} + C$

How to choose $u$ and $dv$?

A premise to our success in applying integration by parts is picking the "right" $u$ and $dv$.

Notice that the roles of $u$ and $dv$ are different. Indeed, in the very next step, we will compute \begin{align*} u &\mapsto du & dv &\mapsto v & &\text{and produce} \quad uv - \int v \, du. \end{align*}

  1. Our primary goal is that you know how to compute $\int v \, du$. If that can be done, then your choice is "right".
  2. If the primary goal is not easy to achieve, then we hope $du$ and $v$ are "less complicated" than $u$ and $dv$ that we started with.
  3. When all else fail, try all the different possibilities! One of them is guaranteed to work, if integration by parts is at all possible. The value of trial and error is underappreciated in our modern education.

Revisiting the first example

Let us revisit our very first example \[\int x e^x dx.\]

We have two choices:

  1. $u=x$ and $dv = e^x dx$, or
  2. $u = e^x$ and $dv=x dx$.

\begin{align*} &\text{With} & u=x,\; dv = e^x dx &\longrightarrow \int v du = \color{blue}{ \int e^x dx } \\ &\text{whereas} & u = e^x,\; dv = xdx &\longrightarrow \int v du = \color{red}{ \int \frac{x^2}{2} \, e^x \, dx }. \end{align*}

Clearly, the first choice is preferable. Indeed, the second choice leads to even more complicated integrals. This is why we chose $u = x$ and $dv = e^x \, dx$ and not the other way around.

Using the observation listed above to determine the best strategy for computing the integral $\int x \cos(x) dx$.
Compute \[\int \ln x \, dx.\]

Solution. We only have two choices:

  1. letting $u = 1$ and $dv = \ln x \, dx$
  2. letting $u = \ln(x)$ and $dv = dx$.

For choice (1), we $u=1$, then $du = 0 dx$. But $v = \int dv = \int \ln x \, dx$, which is exactly what we are asked to compute in the first place. So clearly this is leading to nowhere.

For choice (2), \begin{align*} &\text{Let } & \color{red}{u} &= \color{red}{\ln(x)} &&\text{and} & \color{blue}{dv} &= \color{blue}{dx} \\ &\text{then} & \color{red}{du} &= \color{red}{\frac{1}{x} dx} &&\text{and} & \color{blue}{v} &= \color{blue}{x}. \end{align*}

Therefore \[ \int \color{red}{ \ln x} \, \color{blue}{ dx} = \int \color{red}{ u} \color{blue}{ dv} = \color{red}{u}\color{blue}{v} - \int \color{blue}{v} \color{red}{du} = \color{red}{\ln(x)} \color{blue}{ x} - \int \frac{\color{blue}{x}}{\color{red}{x}} \color{red}{dx} = x \ln x - x + C. \]

Recursive applications of integration-by-parts

The technique of integration by parts can be combined with other techniques or be applied recursively.

Compute \[ \int x^2 \, \cos x \, dx \]

Solution. We apply integration by parts

\begin{align*} \text{Let } u &= x^2, & dv &= \cos x \, dx \\ \text{then } du &= 2x \, dx & v &= \sin x \end{align*}

$\displaystyle \int x^2 \cos x dx = x^2 \sin x - \int \sin(x) \, 2x \, dx$ $\displaystyle = x^2 \sin x - 2 \int x \sin x dx$

The resulting integral also requires integration by parts:

\begin{align*} \text{Let } u_2 &= x, & dv_2 &= \sin x \, dx \\ \text{then } du_2 &= dx & v_2 &= -\cos x \end{align*}

Then the original integral is turned into \[ x^2 \sin x - 2 \left( - x \cos x - \int - \cos(x) dx \right) = x^2 \sin x + 2 x \cos x - 2 \sin x + C \]

Going around in circles

Integration by parts may produce integrals that are identical or proportional to the original integral. When this happens, it appears we are running around in circles and won't be able to compute the integral.

However, very often, we can still compute the integral by collecting all the terms involving the target integral in the resulting equation. We will see how this idea could work in the following example.

Compute \[\int e^\theta \cos(\theta) d\theta. \]

Solution. We apply integration by parts.

\begin{align*} \text{Let}\quad u &= \cos(\theta), & dv &= e^{\theta} d\theta. \\ \text{Then}\; du &= -\sin(\theta) d\theta, & v &= e^{\theta}. \end{align*}

\[ \int e^\theta \cos(\theta) d\theta = \int u dv = uv - \int v \, du = \cos(\theta) e^{\theta} + \int e^\theta \sin(\theta) d\theta. \]

Integrating by parts again with $u = \sin(\theta)$ and $dv = e^\theta d\theta$, we get \[ \cos(\theta) e^{\theta} + \int e^\theta \sin(\theta) d\theta = \cos(\theta) e^{\theta} + \left( \sin(\theta) e^\theta - \color{red}{\int e^\theta \cos(\theta) d\theta} \right). \]

The highlighted part is the original integral. To find a way out, notice \[ \color{red}{\int e^\theta \cos(\theta) d\theta} = \cos(\theta) e^{\theta} + \sin(\theta) e^\theta - \color{red}{\int e^\theta \cos(\theta) d\theta}. \]

By moving the highlighted term to the left hand side, we can see that \[ \color{red}{\int e^\theta \cos(\theta) d\theta} = \frac{ \cos(\theta) e^{\theta} + \sin(\theta) e^\theta }{2} + C. \]