# Motivating example What do we do about an expression like $\int x \sin(x)\;\mathrm{d}x$? We can't do a $u$ substitution because if we substitute $u=x$ we just get $\int u \sin(u) \;\mathrm{d}u$ (which doesn't do anything) and if we substitute $u=\sin(x)$ we get $ \begin{align*} u &= \sin(x)\\ \text{so}~\mathrm{d}u &= -\cos(x)\;\mathrm{d}x\\ \text{thus}~\int x\sin(x)\;\mathrm{d}x &= \int -u\cos(x)\;\mathrm{d}u \end{align*} $ ...which if anything is worse because it doesn't even get rid of the $x$! Are we stuck? No! We just need a new tool in our arsenal and that is called _integration by parts_. # Derivation of the formula Suppose we want to integrate some composite expression $f(x)g(x)$ and we know the antiderivative of $g$, which is $G$. The formula for integration by parts is derived from the product rule for derivatives as follows $ \begin{align*} \frac{\mathrm{d}}{\mathrm{d}x} f(x)G(x) &= f(x)G’(x)+ G(x)f’(x)x &\text{Start with the product rule for derivatives}\\ \int \frac{\mathrm{d}}{\mathrm{d}x} f(x)G(x)\;\mathrm{d} x&= \int \biggl(f(x)G’(x)+ G(x)f’(x)\biggr) \;\mathrm{d} x &\text{Integrate both sides}\\ f(x)G(x) &= \int \biggl(f(x)g(x)+ G(x)f’(x)\biggr) \;\mathrm{d} x &\text{Simplify and rename }G'~\text{to}~g\\\ f(x)G(x) &= \int f(x)g(x) \;\mathrm{d} x+ \int G(x)f’(x) \;\mathrm{d} x&\text{Split the integral}\\ \int f(x)g(x) \;\mathrm{d} x&= f(x)G(x) - \int f'(x)G(x) \;\mathrm{d} x &\text{Rearrange so}~\int f(x)g(x) \mathrm{d}x~\text{is the subject}\\ \end{align*} $ This is the formula for integration by parts. $\int f(x)g(x) \;\mathrm{d} x = f(x)G(x) - \int f'(x)G(x) \;\mathrm{d} x\tag{1}$ From this it follows that if we have a composite expression that does not immediately lend itself to integration by substitution, we can use integration by parts so long as we have one half we know how to differentiate (to give us $f'$) and one half we know how to integrate(to give us $G$). ## Worked example the long way Say we want to solve $\int x \sin(x)\;\mathrm{d}x$ then. We know that $ \begin{align*} \frac{\mathrm{d}}{\mathrm{d}x} x &= 1\\ \text{and}~\int \sin(x)\;\mathrm{d}x &= -\cos(x) + c \end{align*} $ So let's make $x$ our $f(x)$ and $\sin(x)$ our $g(x)$ (ie $G(x) = -\cos(x)$). Plugging these into the formula at (1), we have $ \begin{align*} \text{Since}~f(x) &= x,\\ f'(x) &= 1\\ \text{and as}~ g(x) &= \sin(x),\\ G(x) &= -\cos(x).\\ \text{Thus}~\int x \sin(x)\;\mathrm{d}x &= x(-\cos(x)) - \int 1 (-\cos(x))\; \mathrm{d}x\\ &= -x\cos(x) + \int \cos(x)\; \mathrm{d}x\\ &= -x\cos(x) + \sin(x)+c \end{align*} $ ...and we are done. Note: - as always with an indefinite integral don't forget to add the constant of integration $c$ when all the integrals are gone from the RHS. - You can already see that getting the signs correct on the $-\int f'(x)G(x)\;\mathrm{d}x$ term is a minefield. The DI method (below) was the only way I could do this at all reliably. ## Actually doing integration by parts: The DI method Since it is frequently the case that we need to apply integration by parts multiple times eg in the above to obtain $\int f'(x)G(x) \mathrm{d} x,$a very useful method, known as the DI method or tabular method is explained here: ![](https://www.youtube.com/watch?v=2I-_SV8cwsw) There are 3 stop conditions to remember in the DI/Tabular method: #### Stop condition 1: When the derivative is zero For this one, let's do $\int x \sin x\;\mathrm{d}x$ the DI way. We'll choose to differentiate $x$ and integrate $\sin x$. It still works if we choose the other way round it just wouldn't illustrate the stop condition when the derivative is zero if we did that. Step 1 is to write the derivatives and integrals down starting with the original expression until we hit the stop condition $ \begin{array}{ccc} & D & I \\ & x & \sin x\\ & 1 & -\cos x\\ & 0 & -\sin x\\ \end{array}\\ $ Now to the left add a column of signs which alternate on each row starting with $+$. $ \begin{array}{ccc} & D & I \\ + & x & \sin x\\ - & 1 & -\cos x\\ + & 0 & -\sin x\\ \end{array}\\ $ Step 2 is to write out the integral. Since we hit a 0 derivative we can just write it out in one shot. If we terminated for one of the other reasons we'd still have further work to do. In this case we start with the "D" column at the top and multiply terms going down diagonally. So the first term is $+ x (-\cos x)$ and the second term is $-1 (-\sin x)$. And we're done. $\begin{align*} \int x \sin x \;\mathrm{d}x &= -x \cos x + \sin x + c \end{align*} $ #### Stop condition 2: When we can integrate the product of a row to make things terminate Consider $\int x^4 \ln x \;\mathrm{d}x.$ Let's start by deciding we will differentiate $\ln x$ and integrate $x^4$. $ \begin{array}{ccc} & D & I \\ + & \ln x & x^4\\ - & \frac{1}{x} & \frac{1}{5}x^5\\ \end{array}\\ $ Now notice two things at this point. For both the expression we want to differentiate and the one we want to integrate we can do this, however it will never stop. Your spidey sense should be tingling knowing that can't be the answer. However, we can integrate the product of this row. $ \begin{align*} & \int - \frac{1}{x}\left(\frac{1}{5}\right)x^5\\ &= -\frac{1}{5} \int \frac{x^5}{x}\\ &= -\frac{1}{5} \int x^4\\ &= -\frac{1}{5}\left(\frac{1}{5}\right) x^5 + c\\ &= -\frac{1}{25} x^5 + c\\ \end{align*} $ We're now ready to write down our result. The first term is the product of the terms on the diagonal $\ln x (\frac{1}{5}x^5)$ and our second term is the integral of the second row ($-\frac{1}{25} x^5 + c$) therefore $\int x^4 \ln x \;\mathrm{d}x = \frac{1}{5}x^5\ln x -\frac{1}{25} x^5 + c$ #### Stop condition 3: When there is a term to integrate which is a linear multiple of the original integrand. This happens with trig functions which alternate between $\sin$ and $\cos$ each time you integrate or differentiate. When this happens you need to write the integral and then use algebra to solve. Let's do an example $\int \cos(x) \sin(2x)\;\mathrm{d}x$ It should be pretty obvious that it's not going to make any difference which one we choose to differentiate and which to integrate. Let's differentiate $\sin 2x$ and integrate $\cos x$ but you could equally do it the other way round. $ \begin{array}{ccc} & D & I \\ + & \sin 2x & \cos x\\ - & 2 \cos 2x & \sin x\\ + & -4 \sin 2x & - \cos x\\ \end{array}\\ $ Oookay Houston, we have a problem. It's clearly just going to alternate from here. Not only that, but the previous approach we took with $x^4 \ln x$ won't work because if we integrate the row we just have the original problem (with some coefficients). Or will it? Let's write down what we have including the integral of the last row. $ \begin{align*} \int \cos(x) \sin(2x)\;\mathrm{d}x &= \sin(2x)\sin(x) +2\cos(2x)\cos(x) + \int(-4\sin(2x))\left(-\cos(x)\right)\;\mathrm{d}x\\ &= \sin(2x)\sin(x) -2\cos(2x)\cos(x) + 4\int\cos(x)\sin(2x)\;\mathrm{d}x\\ \end{align*} $ Now notice that the last term on the right-hand side is a scalar multiple of the thing on the left-hand side. So we can just subtract it to get it over to the left like we would with any normal algebraic term. $ \begin{align*} - 3\int \cos(x) \sin(2x)\;\mathrm{d}x &= \sin(2x)\sin(x) +2\cos(2x)\cos(x)\\ \int \cos(x) \sin(2x)\;\mathrm{d}x &= -\frac{1}{3}\left(\sin(2x)\sin(x) +2\cos(2x)\cos(x)\right) +c \end{align*} $ ...and we're sort of done. Now notice that we will often be able to apply trig identities etc to simplify this expression further if we want to. Here if we pull one $\cos(2x)\cos(x)$ out of the parentheses we could apply an angle sum identity if we wanted to. ### A note about notation Note that the formula for integration by parts is often given in Leibniz notation as $\int u \;\mathrm{d}v = uv - \int v \;\mathrm{d}u.$ As is often the case with Leibniz notation, this risks obscuring some important details about how the technique is used, so Lagrange notation may be more helpful even if it appears more complex. ymmv. ## Choosing $f'$ and $G$: "LIATE" etc It's easy to see from the formula that from a pure maths fundamentalism point of view it makes no difference which expression you choose to differentiate and which you integrate, however when doing this technique a bit it becomes apparent that there are good and less good choices if you want an easy life. If using the actual formula for integration by parts, some people recommend the acronym "LIATE" to define the ordering that you should choose based on whether your expression is a logarithm, an "index" (ie $x^n$), a trigonometric function, an algebraic function or $e$ to the power of something. However when using the DI method this doesn't give you the best choices for easy integrating. Generally I would say just do a few and it becomes obvious, but here are heuristics: 1. If you only know how to integrate 1 half then the decision is made for you. Do it that way. 2. If you have a positive exponent, it can be good to make this the thing you differentiate because then you know it will decrease to zero and terminate after a few rounds 3. If you have a term with $e$ or a trigonometric function it usually doesn't matter which side it goes on but if you have a trig function on the integration side you need to know the stop condition 3 thing above where you use algebra to solve 4. if you have a $\ln$ it's going to be easier to differentiate but not impossible to integrate. ## External resources [Page by Gil Strang on integration by parts](https://math.libretexts.org/Bookshelves/Calculus/Calculus_(OpenStax)/07%3A_Techniques_of_Integration/7.01%3A_Integration_by_Parts) [Some exercises](https://math.libretexts.org/Courses/Monroe_Community_College/MTH_211_Calculus_II/Chapter_7%3A_Techniques_of_Integration/7.1%3A_Integration_by_Parts/7.1E%3A_Exercises_for_Integration_by_Parts) ## Exercises to try - $\int x e^x\;\mathrm{d}x$ - $\int x\cos⁡(x) \;\mathrm{d}x$ - $\int x\sin(x)\;\mathrm{d}x$ - $\int \ln(x)\;\mathrm{d}x$ <= this is a famous exercise for integration by parts that everyone should do at least once. If you're annoyed that it isn't a composite expression, notice that $\ln x = 1\cdot \ln x$. (Everyone usually gives this hint). - $\int x^2 e^x \;\mathrm{d}x$ - $\int \cos(x)\sin⁡(3x)  \;\mathrm{d}x$ - $\int x^4\ln⁡(3x)  \;\mathrm{d}x$ - $\int x^2\sin⁡(x)  \;\mathrm{d}x$ - $\int x^2\cos⁡(x)  \;\mathrm{d}x$