The Technique of 'Integration by Parts'

We know that differentiating a sum or difference can be accomplished by differentiating each term and combining the results, and that a similar result holds for integrals: $$\left[f(x) + g(x)\right]' = f'(x) + g'(x) \quad \text{ and } \quad \int \left[f(x) \pm g(x)\right]\,dx = \int f(x)\,dx \pm \int g(x)\,dx$$ However, differentiating a product was more complicated, as seen below $$\left[f(x)g(x)\right]' = f(x)g'(x) + g(x)f'(x)$$ One might wonder if there is a corresponding rule for dealing with integrals of products. Let's see if we can't forge a connection between these two ideas. Recalling that integration will in a sense "undo" differentiation. As such, $$\int \left[f(x)g(x)\right]'\,dt = f(x)g(x) + C$$ Applying the product rule to the integrand on the left and then splitting performing the integration term by term, we have $$\int \left[f(x)g(x)\right]'\,dx = \int \left[f(x)g'(x) + g(x)f'(x)\right]\,dx = \int f(x)g'(x)\,dx + \int g(x)f'(x)\,dx$$ Consequently, $$\int f(x)g'(x)\,dx + \int g(x)f'(x)\,dx = f(x)g(x) + C$$ Of course, we can subtract the $C$ from both sides and then "bury" it into either of the integrals on the left -- as each, when found, would contribute a similar arbitrary constant term. With this simplification, we have

$$\int f(x)g'(x)\,dx + \int g(x)f'(x)\,dx = f(x)g(x)$$

which we can solve for $\int f(x)g'(x)\,dx$, to discover $$\int f(x)g'(x)\,dx = f(x)g(x) - \int g(x)f'(x)\,dx$$ Note that the expression to the left of the equals sign is an integral of a product -- although it does presume that the second factor $g'(x)$ is the derivative of some function $g(x)$.

We can make the formula above a bit easier to remember if we express it in the language of differentials. Let $u=f(x)$ and $v = g(x)$. Then we have as differentials $du = f'(x)\,dx$ and $dv = g'(x)\,dx$. With these substitutions, we can express the formula above as $$\int u\,dv = uv - \int v\,du$$ Using the formula immediately above along with careful selection of the functions to play the role of $u$ and $v$ so that the integral on the right side is easy to evaluate (or at least "easier" than the original integral) is known as the technique of integrating by parts.

Of course, this provides us a way to then find definite integrals as well: $$\int_a^b u\,dv = uv\,\Big|_a^b - \int_a^b v\,du$$ Importantly, note that we are not doing a $u$-substitution here, so one should not change the limits of integration.

The following examples demonstrate this technique applied to several integrals. Note that some of them require its application more than once. Still others require combining the results of multiple applications of this technique.

Question

Find $\displaystyle{\int xe^x\,dx}$


Solution

Upon seeing that we are integrating a product (and not seeing anything else that immediately works), we consider applying integration by parts.

In doing so, we must decide which factor should play the role of $u$ and which should play the role of $dv$. Whichever we pick, note that we'll need to differentiate $u$ to find $du$, and integrate $dv$ to find $v$, as these appear in on the right side of the integration by parts formula $\int u\,dv = uv - \int v\,du$.

Let us choose $u=x$ and $dv = e^x\, dx$, and then find $du = dx$ and $v = e^x$, respectively.

A quick word should be said about $v$. Note that $\int dv = \int e^x\,dx = e^x + C$, but we just said $v = e^x$. You might be wondering what happened to the "$+C$". Recall that when we argued the integration by parts formula, we said $v = g(x)$ but our only presumption was that $g'(x)$ was the derivative of $g(x)$, so that we would have $dv = g'(x)\,dx$. As any antiderivative of $g'(x)$ will then work as our $g(x)$, we pick the simplest one -- the one where the constant that could be added is zero.

Returning to our problem, let us now plug in $u=x$, $du = dx$, $dv = e^x\,dx$ and $v=e^x$ into the integration by parts formula, to see that $$\int xe^x\,dx = x e^x - \int e^x\,dx$$ Note how our choice of who would be $u$ and who would be $dv$ made the integral on the right side easier to find. Had we instead chosen $u = e^x$ and $dv = x$, the integral on the right would have been more complicated. Indeed, we would have then had to find $\frac{1}{2} \int x^2 e^x\,dx$, which looks worse than the integral with which we started!

Using our first choice of $u$ and $dv$ however, the integral on the right that results is trivial to evaluate, and we arrive at our answer: $$\int xe^x\,dx = x e^x - e^x + C$$

Question

Find $\displaystyle{\int \ln(x)\,dx}$


Solution

In this problem, it is easy to overlook that we are still integrating a product -- but we are!

Taking $u=\ln x$ and $dv = dx$, we see that $du = \frac{1}{x}\, dx$ and $v = x$.

We might be concerned that $du$ seems more complicated than $u$ here, as this often means the integral on the right side of the integration by parts formula $\int u\,dv = uv - \int v\,du$ will be more complicated too. However, we catch a break here. Note how when we find $v\,du$, the factor of $x$ cancels, leaving only $\int dx$, the simplest of all integrals to find: $$\begin{array}{rcl} \displaystyle{\int \ln(x)\,dx} &=& \displaystyle{x\ln(x) - \int x \cdot \frac{1}{x}\,dx}\\ &=& \displaystyle{x\ln(x) - \int dx}\\ &=& \displaystyle{x\ln(x) - x + C} \end{array}$$

Question

Find $\displaystyle{\int x^2 e^{-2x}\,dx}$


Solution

Note that the derivative of $x^2$ is $2x$, which is "simpler" than $x^2$ in the sense that the exponent has gone down. The integral of $x^2$ on the other hand would be $\frac{1}{3}x^3$, which has a higher exponent.

Considering $e^{-2x}$, both integrating or differentiating this expression results in something of about the same complexity (i.e., either $-2e^{-2x}$ or $-\frac{1}{2}e^{-2x}$; both are just constant multiples of $e^{-2x}$).

As such, we choose $u = x^2$ and $dv = e^{-2x}\,dx$ so that the integral $\int v\,du$ on the right side of the integration by parts formula overall gets simpler than the current integral under consideration. With $du = 2x\,dx$ and $v = -\frac{1}{2}e^{-2x}$, our integration by parts formula $\int u\,dv = uv - \int v\,du$ becomes: $$\int x^2 e^{-2x}\,dx = -\frac{1}{2}x^2e^{-2x} + \int x e^{-2x}\,dx$$ Alas, we are not done! Note how the integral with which we are left on the right side looks very similar to the one found in our first example. Yes, you guessed it -- we're going to need to use integration by parts again!

As we did in our first example, we again take $u = x$, which means $du = dx$. This leaves $dv = e^{-2x}\,dx$. We used this same $dv$ a minute ago, and so integrating it still leads to the same $v = -\frac{1}{2}e^{-2x}$. Thus, with this new $u$ and $dv$ in mind, we can keep going with our previous calculation, replacing the integral on the right with the expression in brackets below: $$\begin{array}{rcl} \displaystyle{\int x^2 e^{-2x}\,dx} &=& \displaystyle{-\frac{1}{2}x^2e^{-2x} + \int x e^{-2x}\,dx}\\ &=& \displaystyle{-\frac{1}{2}x^2e^{-2x} + \left[-\frac{1}{2}xe^{-2x} + \int \frac{1}{2}e^{-2x}\,dx\right]}\\ &=& \displaystyle{-\frac{1}{2}x^2e^{-2x} -\frac{1}{2}xe^{-2x} + \frac{1}{2}\int e^{-2x}\,dx}\\ &=& \displaystyle{-\frac{1}{2}x^2e^{-2x} -\frac{1}{2}xe^{-2x} - \frac{1}{4} e^{-2x} + C} \end{array}$$ At this point, we have found the integral sought, although we might clean it up a bit by factoring some common factors to obtain $$\int x^2 e^{-2x}\,dx = -\frac{1}{4e^{2x}}(2x^2 + 2x + 1) + C$$

Question

Evaluate $\displaystyle{\int_0^{\pi/2} x\cos(x)\,dx}$


Solution

Apart from now dealing with a definite integral, note the other difference between this problem and those seen in the previous examples is that we now have $\cos(x)$ as one of the factors of the product we are integrating.

Both $\cos(x)$ and our earlier encountered $e^x$ share something in common -- they don't really get any more complicated upon either differentiation or integration. It doesn't impact this problem, but the function $\sin(x)$ shares this property too.

When integrating by parts a product where one of the factors is one of these functions, and the other factor gets simpler upon differentiation (like both the $x$ in our very first example and the one here), that factor frequently makes a good choice for $u$, while the cosine, sine, or exponential function then makes a good choice for $dv$.

With that in mind, let us choose $u = x$, which means $du = dx$. That leaves $dv = \cos(x)\,dx$, which upon integration gives us $v = \sin(x)$. Plugging all this into the integration by parts formula $\int u\,dv = uv - \int v\,du$, we have $$\begin{array}{rcl} \displaystyle{\int_0^{\pi/2} x \cos(x)\,dx} &=& \displaystyle{x\sin(x)\Big|_0^{\pi/2} - \int_0^{\pi/2} \sin(x)\,dx}\\ &=&\displaystyle{x\sin(x)\Big|_0^{\pi/2} + \cos(x)\Big|_0^{\pi/2}}\\ &=&\displaystyle{\left[\frac{\pi}{2}\sin\left(\frac{\pi}{2}\right) - 0\cdot\sin\left(0\right)\right] + \left[\cos\left(\frac{\pi}{2}\right) - \cos(0)\right]}\\ &=&\displaystyle{\frac{\pi}{2} - 1} \end{array}$$

Question

Find $\displaystyle{\int e^x \sin(x)\,dx}$


Solution

In this example, recall that both $e^x$ and $\sin(x)$ don't get appreciably worse when integrated or differentiated. So let's just pick $u=e^x$, noting that then $du = e^x\,dx$. This leaves $dv = \sin(x)\,dx$, which upon integrating, tells us $v = -\cos(x)$.

Plugging these into our integration by parts formula, we have $$\begin{array}{rcl} \displaystyle{\int e^x \sin(x)\,dx} &=& \displaystyle{-e^x \cos(x) - \int (-\cos(x)) e^x\,dx}\\ &=& \displaystyle{-e^x \cos(x) + \int e^x \cos(x)\,dx} \end{array}$$ Granted, the integral we created on the right side is no better than the one with which we started! Usefully however, it is no worse! Look what happens if we do integration by parts one more time..

This time, let $u = e^x$ so again we have $du = e^x\,dx$. This now leaves $dv = \cos(x)\,dx$, leading to $v = \sin(x)$. Now, we replace the integral on the right above with the expression in brackets below: $$\begin{array}{rcl} \displaystyle{\int e^x \sin(x)\,dx} &=& \displaystyle{-e^x \cos(x) + \int e^x \cos(x)\,dx}\\ &=& \displaystyle{-e^x \cos(x) + \left[ e^x \sin(x) - \int e^x \sin(x)\,dx \right]} \end{array}$$ I know what you are thinking -- we are working in circles! The integral we have on the right now is not only no better than the one with which we started, it is exactly the same integral! This, however, is a wonderful occurrence! Since they are exactly the same value, we can treat it just like some unknown value appearing twice in an equation and solve for it! All we need do is add this integral to both sides and then divide both sides by $2$ to arrive at our solution, as seen below $$\begin{array}{rcl} \displaystyle{\int e^x \sin(x)\,dx} &=& \displaystyle{-e^x \cos(x) + e^x \sin(x) - \int e^x \sin(x)\,dx}\\ \displaystyle{2\int e^x \sin(x)\,dx} &=& \displaystyle{-e^x \cos(x) + e^x \sin(x)} + 2C\\ \displaystyle{\int e^x \sin(x)\,dx} &=& \displaystyle{-\frac{1}{2}e^x \cos(x) + \frac{1}{2}e^x \sin(x) + C} \end{array}$$ A word should be said about the weird $2C$ term that appeared in the second step above. Note that our final integral must have an arbitrary constant term added to it. Calling this "$+C$" as is our habit, that means that twice the integral, as seen on the left, would then have associated with it twice that arbitrary constant (i.e., the "$+2C$" term). It really doesn't matter too much though. Twice an arbitrary constant is still an arbitrary constant. The important thing is to make sure your final expression for the integral you seek has a $+C$ attached to it!

As one final, important observation about this example -- note that after choosing $u=e^x$ for our first application of integration by parts, we needed to use $u=e^x$ again in the second application of integration by parts. If we had used $u=\cos(x)$ with $du = -\sin(x)\,dx$ instead, leaving $dv = e^x\,dx$, yielding $v = e^x$, we would have gotten this very unhelpful equation: $$\int e^x \sin(x)\,dx = -e^x \cos(x) + \left[e^x \cos(x) + \int e^x \sin(x)\,dx \right]$$ Why is it unhelpful you ask? Try solving for the integral by subtracting it from both sides -- we end up $0=0$. Definitely not helpful!

Question

Find $\displaystyle{\int \sec^3(x)\,dx}$


Solution

This one can be tricky! First, note that $\sec^3(x)$ when differentiated gets significantly worse (i.e., $3\sec^2(x) \cdot \sec(x)\tan(x) = 3\sec^3(x)\tan(x))$, so choosing $u=\sec^3(x)$ is probably a bad idea. Of course, using $dv=\sec^3(x)\,dx$ doesn't help either, as we would need to know the answer to the problem to even find $v$.

The trick is to rewrite $\sec^3(x)$ as a product of two factors: $$\int \sec^3(x)\,dx = \int \sec(x) \cdot \sec^2(x)\,dx$$ Now notice that $\sec^2(x)$ is easy to integrate and results in something simple -- so let's choose $dv = \sec^2(x)\,dx$, leaving $u = \sec(x)$ which means $du = \sec(x)\tan(x)\,dx$. Crossing our fingers that this turns out okay when we plug it all into the integration by parts formula $\int u\,dv = uv - \int v\,du$, we get $$\int \sec^3(x) = \sec(x)\tan(x) - \int \sec(x)\tan^2(x)\,dx$$ Hmmm.. Now what? The integral on the right looks worse -- but wait! There is a nice relationship between $\tan^2(x)$ and $\sec^2(x)$. One of the Pythagorean identities tells us that $\tan^2(x) = \sec^2(x) - 1$. We can thus make a substitution in our integral to discover $$\int \sec^3(x) = \sec(x)\tan(x) - \int \sec(x)(\sec^2(x) - 1)\,dx$$ and then expand this product and split our integral into two pieces, one of which is identical to the integral we hoped to find (and we know what to do when that happens!) $$\begin{array}{rcl} \displaystyle{\int \sec^3(x)} &=& \displaystyle{\sec(x)\tan(x) - \int (\sec^3(x) - \sec(x))\,dx}\\ &=& \displaystyle{\sec(x)\tan(x) - \int\sec^3(x)\,dx + \int \sec(x)\,dx} \end{array}$$ Adding $\int \sec^3(x)\,dx$ to both sides, so that we might solve for this integral, we find $$2\int \sec^3(x)\,dx = \sec(x)\tan(x) + \int\sec(x)\,dx$$ We see we are very close. Indeed, if we know $\int\sec(x)\,dx = \ln\left|\sec(x)+\tan(x)\right| + C$, we can make this substitution and divide both sides by $2$ to reveal $$\int \sec^3(x)\,dx = \frac{1}{2}\sec(x)\tan(x) + \frac{1}{2}\ln\left|\sec(x)+\tan(x)\right| + C$$

 


: Don't remember $\int \sec(x)\,dx$? Rewrite it as follows, and let $u = \tan(x) + \sec(x)$: $$\int \sec(x)\,dx = \int \sec(x) \cdot \frac{\tan(x) + \sec(x)}{\tan(x) + \sec(x)}\,dx = \int \frac{\sec(x)\tan(x) + \sec^2(x)}{\tan(x)+\sec(x)}\,dx = \int \frac{1}{u}\,du = \ln |u| + C$$       Writing this back in terms of $x$, we get the desired result: $\int \sec(x)\,dx = \ln|\tan(x) + \sec(x)| + C$

Question

Find $\displaystyle{\int \textrm{arctan}(x)\,dx}$


Solution

This example illustrates that sometimes finding an integral by applying one technique (like integrating by parts) leads to another.

Taking a cue from what we did in using integration by parts on $\int \ln(x)\,dx$, let us choose $u = \textrm{arctan}(x)$, which means $du = \frac{1}{1+x^2}$. This leaves $dv = dx$, so we have $v = x$. Plugging all of these into our integration by parts formula, $\int u\,dv = uv - \int v\,du$, we have $$\int \textrm{arctan}(x)\,dx = x\,\textrm{arctan}(x) - \int \frac{x}{1+x^2}\,dx$$ Trying to force integration by parts on the integral that remains on the right side will likely be frustrating -- especially when we realize this integral can be found quite simply with the technique of $u$-substitution!

Suppose $u = 1 + x^2$. Then, $du = 2x\,dx$ or equivalently, $\frac{1}{2}\,du = x\,dx$.

Now we can rewrite the integral on the right as $$\int \frac{x}{1+x^2}\,dx = -\frac{1}{2}\int \frac{1}{u}\,du = -\frac{1}{2}\ln|u| + C$$ Thus, $$\int \textrm{arctan}(x)\,dx = x\,\textrm{arctan}(x) - \frac{1}{2}\ln|1+x^2| + C$$