4  Integration by Parts

SageMath Spotlight

  • Integration (Section 2.8)
    • integral(f(x), x)
    • integral(f(x), x, a, b)

4.1 Introduction

In Calculus I, we learned about \(u\)-substitution (Section 1.3.3.1) as the chain rule in reverse. When we spot a function and its derivative being multiplied in an integral, we can transform the integral into a form that is easier to compute: \[ \int f'(u) \frac{\mathop{}\!\mathrm{d}u}{\mathop{}\!\mathrm{d}x} \mathop{}\!\mathrm{d}x = \int f'(u) \mathop{}\!\mathrm{d}u = f(u). \] Here we are making use of the differential form \(\mathop{}\!\mathrm{d}u = \frac{\mathop{}\!\mathrm{d}u}{\mathop{}\!\mathrm{d}x} \mathop{}\!\mathrm{d}x\) (Stewart et al. 2020, 3.10, pp. 256).

In this lecture, we introduce integration by parts as the integral form of the product rule (Section 1.2.4). If we rewrite the product rule as \[ f(x) g'(x) = \frac{\mathop{}\!\mathrm{d}\left(f(x) g(x)\right)}{\mathop{}\!\mathrm{d}x} - f'(x) g(x), \] then integrating both sides gives \[ \int f(x) g'(x) \mathop{}\!\mathrm{d}x = f(x) g(x) - \int f'(x) g(x) \mathop{}\!\mathrm{d}x. \] If we write \(u = f(x)\) and \(v = g(x)\) and use the differential forms \(\mathop{}\!\mathrm{d}u = f'(x) \mathop{}\!\mathrm{d}x\) and \(\mathop{}\!\mathrm{d}v = g'(x) \mathop{}\!\mathrm{d}x\), respectively, this becomes the more commonly written form:

Integration by Parts (Stewart et al. 2020, 7.1, pp. 486)

\[ \int u \mathop{}\!\mathrm{d}v = u v - \int v \mathop{}\!\mathrm{d}u. \]

The name of the game, given an integral to be evaluated by this method, is to choose \(u\) and \(\mathop{}\!\mathrm{d}v\) in such a way that the left-hand side is the original problem to be solved and the right-hand side is an integral we know how to compute. There are several new classes of functions which integration by parts allows us to integrate—the main trick is to learn how to pick \(u\) and \(\mathop{}\!\mathrm{d}v\) effectively. Indeed, choosing the wrong \(u\) and \(\mathop{}\!\mathrm{d}v\) can quickly make the problem much harder! We will consider several examples, then describe a more general rule of thumb.

Basic Examples

Example 4.1 (\(\int x \cos x \mathop{}\!\mathrm{d}x\)) By taking \(u = x\) and \(\mathop{}\!\mathrm{d}v = \cos x \mathop{}\!\mathrm{d}x\), so that \(\mathop{}\!\mathrm{d}u = \mathop{}\!\mathrm{d}x\) and \(v = \sin x\), we have \[ \int x \cos x \mathop{}\!\mathrm{d}x = x \sin x - \int \sin x \mathop{}\!\mathrm{d}x = x \sin x + \cos x + C. \] We can check our work with SageMath:

integral(x*cos(x), x)
x*sin(x) + cos(x)

On the other hand, if we had chosen \(u = \cos x\) and \(\mathop{}\!\mathrm{d}v = x \mathop{}\!\mathrm{d}x\), then we would have \(\mathop{}\!\mathrm{d}u = -\sin x \mathop{}\!\mathrm{d}x\) and \(v = \tfrac{1}{2} x^2\), and integration by parts gives \[ \begin{aligned} \int x \cos x \mathop{}\!\mathrm{d}x & = \tfrac{1}{2} x^2 \cos x - \int { \tfrac{1}{2} x^2 \left(-\sin x \mathop{}\!\mathrm{d}x \right)} \\ & = \tfrac{1}{2} x^2 \cos x + \tfrac{1}{2} \int x^2 \sin x \mathop{}\!\mathrm{d}x. \end{aligned} \] This is worse than what we started with! \(u\) should get simpler when we differentiate it.

Example 4.2 (\(\int x^2 e^{3x} \mathop{}\!\mathrm{d}x\)) By taking \(u = x^2\) and \(\mathop{}\!\mathrm{d}v = e^{3x} \mathop{}\!\mathrm{d}x\), so that \(\mathop{}\!\mathrm{d}u = 2x \mathop{}\!\mathrm{d}x\) and \(v = \tfrac{1}{3} e^{3x}\), we have \[ \begin{aligned} \int x^2 e^{3x} \mathop{}\!\mathrm{d}x & = \tfrac{1}{3} x^2 e^{3x} - \int{ \left( \tfrac{1}{3} e^{3x} \right) \left( 2x \mathop{}\!\mathrm{d}x \right) } \\ & = \tfrac{1}{3} x^2 e^{3x} - \tfrac{2}{3} \int x e^{3x} \mathop{}\!\mathrm{d}x \end{aligned} \] The right-hand side is still not directly integrable, but note that it is simpler than what we started with—the polynomial degree has dropped. Sometimes we need to integrate by parts more than once! Once again, taking \(u = x\) and \(\mathop{}\!\mathrm{d}v = e^{3x} \mathop{}\!\mathrm{d}x\), we have \[ \begin{aligned} \int x e^{3x} \mathop{}\!\mathrm{d}x & = \tfrac{1}{3} x e^{3x} - \int{ \left( \tfrac{1}{3} e^{3x} \right) \mathop{}\!\mathrm{d}x} \\ & = \tfrac{1}{3} x e^{3x} - \tfrac{1}{9} e^{3x} + C \end{aligned} \] Having integrated \(x e^{3x}\), we substitute to complete the original problem: \[ \begin{aligned} \int x^2 e^{3x} \mathop{}\!\mathrm{d}x & = \tfrac{1}{3} x^2 e^{3x} - \tfrac{2}{3} \left( \tfrac{1}{3} x e^{3x} - \tfrac{1}{9} e^{3x} + C \right) \\ & = \tfrac{1}{3} x^2 e^{3x} - \tfrac{2}{9} x e^{3x} + \tfrac{2}{27} e^{3x} + C'. \end{aligned} \]

Remark 4.1. Note that we have introduced a new variable, \(C' = - \tfrac{2}{3} C\), in order to simplify the final result. This is common practice, often referred to as absorbing into our integration constant—we aren’t changing the answer, since \(C\) is meant to be able to stand for any real number. In fact, it is common practice to simply write \(C\) (not \(C'\)) when doing this sort of absorption, and we shall do so in the coming sections!

More Surprising Examples

Example 4.3 (\(\int \ln x \mathop{}\!\mathrm{d}x\)) This is one of my favorite examples of integration by parts, because it doesn’t seem obvious that there is a product to be studied at all! We choose \(u = \ln x\) and \(\mathop{}\!\mathrm{d}v = \mathop{}\!\mathrm{d}x\), so \(\mathop{}\!\mathrm{d}u = \tfrac{1}{x} \mathop{}\!\mathrm{d}x\) and \(v = x\), in order to compute \[ \begin{aligned} \int \ln x \mathop{}\!\mathrm{d}x & = x \ln x - \int{ x \left( \tfrac{1}{x} \mathop{}\!\mathrm{d}x \right)} \\ & = x \ln x - \int \mathop{}\!\mathrm{d}x \\ & = x \ln x - x + C. \end{aligned} \]

Example 4.4 (\(\int \tan^{-1} x \mathop{}\!\mathrm{d}x\)) Using a similar approach (recalling the derivatives of inverse trigonometric functions, Section 1.2.6.2, made possible via implicit differentiation), we take \(u = \tan^{-1} x\) and \(\mathop{}\!\mathrm{d}v = \mathop{}\!\mathrm{d}x\), so that \(\mathop{}\!\mathrm{d}u = \tfrac{1}{1+x^2} \mathop{}\!\mathrm{d}x\) and \(v = x\). Then we have: \[ \int \tan^{-1} x \mathop{}\!\mathrm{d}x = x \tan^{-1} x - \int \frac{x}{1+x^2} \mathop{}\!\mathrm{d}x. \] To proceed, we conclude with substitution: \(w = 1+x^2\), so that \(\mathop{}\!\mathrm{d}w = 2x \mathop{}\!\mathrm{d}x\). Hence: \[ \begin{aligned} \int \tan^{-1} x \mathop{}\!\mathrm{d}x & = x \tan^{-1} x - \frac{1}{2} \int \frac{1}{w} \mathop{}\!\mathrm{d}w \\ & = x \tan^{-1} x - \frac{1}{2} \ln{\vert{}w\vert{}} + C \\ & = x \tan^{-1} x - \frac{1}{2} \ln(x^2+1) + C. \\ \end{aligned} \]

integral(arctan(x), x)
x*arctan(x) - 1/2*log(x^2 + 1)

4.2 L.I.P.E.T.

As we have seen in Example 4.1, we must be careful when choosing \(u\) and \(\mathop{}\!\mathrm{d}v\). In general, we want \(u\) to be a function that gets simpler (or at least no more complicated) when differentiated, and \(\mathop{}\!\mathrm{d}v\) to be a function that is easy to integrate.

To help make this choice, we will use the LIPET rule of thumb. When deciding which part of the integrand should be \(u\), pick according to the following order:

  • Logarithmic functions (\(\ln x, \log_2 x, \dots\)) are the best choice for \(u\)
  • Inverse trigonometric functions (\(\sin^{-1} x, \tan^{-1} x, \dots\))
  • Polynomial functions (\(x^2, 3x^5-4, \dots\))
  • Exponential functions (\(e^x, 2^x, \dots\))
  • Trigonometric functions (\(\sin x, \cos x, \dots\)) when nothing else remains!

Whatever is left over (along with the \(\mathop{}\!\mathrm{d}x\)) becomes our \(\mathop{}\!\mathrm{d}v\). Note that some practicioners prefer the acronym LIATE (replacing “Polynomial” with “Algebraic”).

Compare these priorities for \(u\) in our previous examples:

  • In \(\int x \cos x \mathop{}\!\mathrm{d}x\), we had a Polynomial (\(x\)) and a Trig function (\(\cos x\)). We chose \(u = x\).
  • In \(\int x^2 e^{3x} \mathop{}\!\mathrm{d}x\), we had a Polynomial (\(x^2\)) and an Exponential (\(e^{3x}\)). We chose \(u = x^2\).
  • In \(\int \ln x \mathop{}\!\mathrm{d}x\), we had a Logarithm (\(\ln x\)) and a hidden Polynomial (\(1\)). We chose \(u = \ln x\).

LIPET is an excellent heuristic, but it is just a rule of thumb! As you evaluate more complicated integrals, you may occasionally find situations where deviating from LIPET is necessary, but it should be your first instinct.