# Integration by Parts
Integration by parts is used to undo [[The Derivative Product Rule]]. It boils down to the following formula
$\int u \,dv = uv - \int v \, du$
(where $u$ and $v$ are functions of $x$)
^aftqxa
By freely defining what parts of an expression correspond to $u$ and $dv$, we can simplify the integration process of the whole expression by picking $dv$ that can be easily integrated.
The devil is in the detail is a mnemonic which can be used to memorize the tactic used to pick $dv$.
- When picking $dv$ use the following in decreasing order of preference:
- $e$xponential functions
- trigonometric functions
- algebraic functions (polynomials)
- inverse trigonometric functions
- logarithms
You can simplify the process by writing a 2x2 table whose first column contains $u$ and $v$ and the second column contains $du$ and $dv$. You then fill it in clockwise order.
## Example
Integrate $\int x^2 \sin x\, dx$.
Define $u = x^2$ and $dv = \sin x\, dx$
| $u=x^2$ | $du = 2x\, dx$ |
| ------------- | ----------------- |
| $v = -\cos x$ | $dv = \sin x\, dx$ |
![[Integration by Parts#^aftqxa]]
$\int x^2 \sin x \, dx= -x^2\cos x + 2\int x\cos x\, dx$
Define $u=x$ and $dv=\cos x \, dx$:
| $u=x$ | $du=dx$ |
| ---------- | ------------------- |
| $v=\sin x$ | $dv = \cos x \, dx$ |
$\int x \cos x \, dx = x\sin x - \int \sin x \, dx = x\sin x +\cos x + C$
$\int x^2 \sin x\, dx = -x^2 \cos x + 2 (x\sin x + \cos x) + C$
## The LIDI Method
Instead of writing out the $u$ and $v$ explicitly like in the example above, a slightly faster approach is advocated by Neil Does Maths called the LIDI method.
Split the integral into first and second parts (the first corresponding to $u$ and second to $v$) and write out four brackets like:
$I =(L)(I)-\int (D)(I)$
LIDI corresponds to:
- L - leave the first part
- I - integrate the second part
- D - differentiate the first part
- I - integrate the second part
So applying it to the example above we simply write:
$
\begin{align}
\int x^2\sin x \, dx &= (x^2) (-\cos x) - \int (2x) (-\cos x \, dx) \\
&= -x^2 \cos x +2\int x \cos x \, dx \\
&= -x^2 \cos x +2\left[ (x)(\sin x)-\int(1)(\sin x \, dx) \right] \\
&= -x^2 \cos x +2(x\sin x+\cos x) + C
\end{align}
$
## Proof
Start with the product rule:
![[The Derivative Product Rule#^a1ucyf]]
but express it a bit differently ($u$ and $v$ will replace $f$ and $g$ for common naming consistency):
$
\frac d {dx} \bigg[uv \bigg] = \frac {du} {dx}v + u\frac{dv}{dx}
$
Integrate both sides with respect to $x$:
$
\int \frac d {dx} \bigg[uv \bigg] dx = \int \frac {du} {dx}v \, dx + \int u\frac{dv}{dx} \, dx
$
The left hand side is just $uv$ because we're reversing the derivative. On the right side $dx$ cancel out. After rewriting we get:
$
\begin{gather}
uv = \int v \, du + \int u \,dv \\
\int u \, dv = uv - \int v \,du
\end{gather}
$