Integration by Parts

It is easy to compute the integral $$$\int{{e}}^{{x}}{d}{x}$$$, but how to handle integrals like $$$\int{x}{{e}}^{{x}}{d}{x}$$$?
In general, if you have under the integral sign a product of functions that can be easily integrated separately, you should use integration by parts.

Formula for integration by parts: $$$\int{u}{d}{v}={u}{v}-\int{v}{d}{u}$$$.

Proof

Using the product rule, we have that $$${\left({f{{\left({x}\right)}}}{g{{\left({x}\right)}}}\right)}'={f{'}}{\left({x}\right)}{g{{\left({x}\right)}}}+{f{{\left({x}\right)}}}{g{'}}{\left({x}\right)}$$$.

Integrating both sides gives: $$$\int{\left({f{{\left({x}\right)}}}{g{{\left({x}\right)}}}\right)}'{d}{x}=\int{\left({f{'}}{\left({x}\right)}{g{{\left({x}\right)}}}+{f{{\left({x}\right)}}}{g{'}}{\left({x}\right)}\right)}{d}{x}$$$.

This can be rewritten as $$${f{{\left({x}\right)}}}{g{{\left({x}\right)}}}=\int{f{'}}{\left({x}\right)}{g{{\left({x}\right)}}}{d}{x}+\int{f{{\left({x}\right)}}}{g{'}}{\left({x}\right)}{d}{x}$$$ or $$$\int{f{{\left({x}\right)}}}{g{'}}{\left({x}\right)}{d}{x}={f{{\left({x}\right)}}}{g{{\left({x}\right)}}}-\int{f{'}}{\left({x}\right)}{g{{\left({x}\right)}}}{d}{x}$$$.

If we take $$${u}={f{{\left({x}\right)}}}$$$ and $$${v}={g{{\left({x}\right)}}}$$$, we have that $$${d}{u}={f{'}}{\left({x}\right)}{d}{x}$$$ and $$${d}{v}={g{'}}{\left({x}\right)}{d}{x}$$$, and the above formula can be rewritten using the substitution rule as $$$\int{u}{d}{v}={u}{v}-\int{v}{d}{u}$$$.

As can be seen, integration by parts corresponds to the product rule (just like the substitution rule corresponds to the chain rule).

In fact, every differentiation rule has a corresponding integration rule, because these processes are the inverse of each other.

Example 1. Evaluate $$$\int{x}{{e}}^{{x}}{d}{x}$$$.

Let $$${u}={x}$$$ and $$${d}{v}={{e}}^{{x}}{d}{x}$$$. Then, $$${d}{u}={\left({x}\right)}'{d}{x}={d}{x}$$$, and $$${v}=\int{{e}}^{{x}}{d}{x}={{e}}^{{x}}$$$.

So, $$$\int{x}{{e}}^{{x}}{d}{x}=\int\overbrace{{\left({x}\right)}}^{{u}}\overbrace{{\left({{e}}^{{x}}{d}{x}\right)}}^{{{d}{v}}}=\overbrace{{\left({x}\right)}}^{{u}}\overbrace{{\left({{e}}^{{x}}\right)}}^{{v}}-\int\overbrace{{\left({{e}}^{{x}}\right)}}^{{v}}\overbrace{{\left({d}{x}\right)}}^{{{d}{u}}}={x}{{e}}^{{x}}-{{e}}^{{x}}+{C}$$$.

Note that it is very important to choose appropriate $$${u}$$$ and $$${v}$$$, because a wrong choice will only complicate the integral.

For example, assume that, instead of choosing $$${u}={x}$$$ and $$${d}{v}={{e}}^{{x}}{d}{x}$$$ in the above example, we choose $$${u}={{e}}^{{x}}$$$ and $$${v}={x}{d}{x}$$$. Then, $$${d}{u}={\left({{e}}^{{x}}\right)}'{d}{x}={{e}}^{{x}}{d}{x}$$$, and $$${v}=\int{x}{d}{x}=\frac{{{x}}^{{2}}}{{2}}$$$.

So, $$$\int{x}{{e}}^{{x}}{d}{x}=\int\overbrace{{\left({{e}}^{{x}}\right)}}^{{u}}\overbrace{{\left({x}{d}{x}\right)}}^{{{d}{v}}}=\overbrace{{\left({{e}}^{{x}}\right)}}^{{u}}\overbrace{{\left(\frac{{1}}{{2}}{{x}}^{{2}}\right)}}^{{v}}-\int\overbrace{{\left(\frac{{1}}{{2}}{{x}}^{{2}}\right)}}^{{v}}\overbrace{{\left({{e}}^{{x}}{d}{x}\right)}}^{{{d}{u}}}$$$.

Although this equation is true, the integral $$$\int\frac{{1}}{{2}}{{x}}^{{2}}{{e}}^{{x}}{d}{x}$$$ is more difficult to evaluate than the integral we started with.

Example 2. Evaluate $$$\int{{x}}^{{2}}{\cos{{\left({x}\right)}}}{d}{x}$$$.

Notice that $$${{x}}^{{2}}$$$ becomes simpler when differentiated. Therefore, let $$${u}={{x}}^{{2}}$$$ and $$${d}{v}={\cos{{\left({x}\right)}}}{d}{x}$$$. Then, $$${d}{u}={\left({{x}}^{{2}}\right)}'{d}{x}={2}{x}{d}{x}$$$, and $$${v}=\int{\cos{{\left({x}\right)}}}{d}{x}={\sin{{\left({x}\right)}}}$$$.

So, $$$\int{{x}}^{{2}}{\cos{{\left({x}\right)}}}{d}{x}={{x}}^{{2}}{\sin{{\left({x}\right)}}}-\int{2}{x}{\sin{{\left({x}\right)}}}{d}{x}={{x}}^{{2}}{\sin{{\left({x}\right)}}}-{2}\int{x}{\sin{{\left({x}\right)}}}{d}{x}$$$.

We've obtained a simpler integral, but still it is not obvious. Therefore, we apply integration by parts once more to the integral $$$\int{x}{\sin{{\left({x}\right)}}}{d}{x}$$$:

let $$${u}={x}$$$ and $$${d}{v}={\sin{{\left({x}\right)}}}{d}{x}$$$; then, $$${d}{u}={\left({x}\right)}'{d}{x}={d}{x}$$$, and $$${v}=\int{\sin{{\left({x}\right)}}}{d}{x}=-{\cos{{\left({x}\right)}}}$$$.

So, $$$\int\overbrace{{\left({x}\right)}}^{{u}}\overbrace{{\left({\sin{{\left({x}\right)}}}{d}{x}\right)}}^{{{d}{v}}}=\overbrace{{\left({x}\right)}}^{{u}}\overbrace{{\left(-{\cos{{\left({x}\right)}}}\right)}}^{{v}}-\int\overbrace{{\left(-{\cos{{\left({x}\right)}}}\right)}}^{{{v}}}\overbrace{{\left({d}{x}\right)}}^{{{d}{u}}}=-{x}{\cos{{\left({x}\right)}}}+\int{\cos{{\left({x}\right)}}}{d}{x}=$$$

$$$=-{x}{\cos{{\left({x}\right)}}}+{\sin{{\left({x}\right)}}}+{C}$$$.

Finally, $$$\int{{x}}^{{2}}{\cos{{\left({x}\right)}}}{d}{x}={{x}}^{{2}}{\sin{{\left({x}\right)}}}-{2}\int{x}{\sin{{\left({x}\right)}}}{d}{x}={{x}}^{{2}}{\sin{{\left({x}\right)}}}-{2}{\left(-{x}{\cos{{\left({x}\right)}}}+{\sin{{\left({x}\right)}}}+{C}\right)}=$$$

$$$={{x}}^{{2}}{\sin{{\left({x}\right)}}}+{2}{x}{\cos{{\left({x}\right)}}}-{2}{\sin{{\left({x}\right)}}}+{C}_{{1}}$$$ where $$${C}_{{1}}=-{2}{C}$$$.

Example 2 shows that in some cases we need to apply integration by parts more than once.

Example 3. Evaluate $$$\int{\ln{{\left({x}\right)}}}{d}{x}$$$.

Here, there is only one choice for $$${u}$$$ and $$${v}$$$, namely $$${u}={\ln{{\left({x}\right)}}}$$$ and $$${d}{v}={d}{x}$$$; so,$$${d}{u}={\left({\ln{{\left({x}\right)}}}\right)}'{d}{x}=\frac{{1}}{{x}}{d}{x}$$$, and $$${v}=\int{d}{x}={x}$$$.

Therefore, $$$\int\overbrace{{\left({\ln{{\left({x}\right)}}}\right)}}^{{u}}\overbrace{{\left({d}{x}\right)}}^{{{d}{v}}}=\overbrace{{\left({\ln{{\left({x}\right)}}}\right)}}^{{u}}\overbrace{{\left({x}\right)}}^{{v}}-\int\overbrace{{\left({x}\right)}}^{{v}}\overbrace{{\left(\frac{{1}}{{x}}{d}{x}\right)}}^{{{d}{u}}}=$$$

$$$={x}{\ln{{\left({x}\right)}}}-\int{d}{x}={x}{\ln{{\left({x}\right)}}}-{x}+{C}$$$.

Example 4. Evaluate $$$\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}$$$.

Neither $$${{e}}^{{x}}$$$ nor $$${\sin{{\left({x}\right)}}}$$$ become simpler when differentiated, but we try choosing $$${u}={{e}}^{{x}}$$$ and $$${v}={\sin{{\left({x}\right)}}}{d}{x}$$$.

Then, $$${d}{u}={\left({{e}}^{{x}}\right)}'{d}{x}={{e}}^{{x}}{d}{x}$$$, and $$${v}=\int{\sin{{\left({x}\right)}}}{d}{x}=-{\cos{{\left({x}\right)}}}{d}{x}$$$.

Therefore, $$$\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}=-{{e}}^{{x}}{\cos{{\left({x}\right)}}}-\int-{\cos{{\left({x}\right)}}}{{e}}^{{x}}{d}{x}=-{{e}}^{{x}}{\cos{{\left({x}\right)}}}+\int{{e}}^{{x}}{\cos{{\left({x}\right)}}}{d}{x}$$$.

The integral obtained is not simpler than the original one, but it is not more difficult either. So, we apply integration by parts once more: let $$${u}={{e}}^{{x}}$$$ and $$${d}{v}={\cos{{\left({x}\right)}}}{d}{x}$$$; then, $$${d}{u}={\left({{e}}^{{x}}\right)}'{d}{x}={{e}}^{{x}}{d}{x}$$$, and $$${v}=\int{\cos{{\left({x}\right)}}}{d}{x}={\sin{{\left({x}\right)}}}$$$.

So, $$$\int{{e}}^{{x}}{\cos{{\left({x}\right)}}}{d}{x}={{e}}^{{x}}{\sin{{\left({x}\right)}}}-\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}$$$.

We've obtained the initial integral! It seems that we obtained nothing because we've arrived at $$$\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}$$$, which is where we had started.

However, since $$$\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}=-{{e}}^{{x}}{\cos{{\left({x}\right)}}}+\int{{e}}^{{x}}{\cos{{\left({x}\right)}}}{d}{x}$$$, it can be stated that

$$$\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}=-{{e}}^{{x}}{\cos{{\left({x}\right)}}}+{\left({{e}}^{{x}}{\sin{{\left({x}\right)}}}-\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}\right)}$$$.

This can be regarded as an equation with the unknown variable $$$\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}$$$.

This equation can be rewritten as $$${2}\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}={{e}}^{{x}}{\left({\sin{{\left({x}\right)}}}-{\cos{{\left({x}\right)}}}\right)}$$$.

Dividing by 2 and adding the constant of integration yields the final answer: $$$\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}=\frac{{1}}{{2}}{{e}}^{{x}}{\left({\sin{{\left({x}\right)}}}-{\cos{{\left({x}\right)}}}\right)}+{C}$$$.

Example 5. Prove the reduction formula.$$$\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}=-\frac{{1}}{{n}}{\cos{{\left({x}\right)}}}{{\sin}}^{{{n}-{1}}}{\left({x}\right)}+\frac{{{n}-{1}}}{{n}}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{d}{x}$$$, where $$${n}\ge{2}$$$ is an integer.

Let $$${u}={{\sin}}^{{{n}-{1}}}{\left({x}\right)}$$$ and $$${d}{v}={\sin{{\left({x}\right)}}}{d}{x}$$$; then,$$${d}{u}={\left({{\sin}}^{{{n}-{1}}}\right)}'{d}{x}={\left({n}-{1}\right)}{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{\left({\sin{{\left({x}\right)}}}\right)}'{d}{x}={\left({n}-{1}\right)}{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{\cos{{\left({x}\right)}}}{d}{x}$$$, and $$${v}=\int{\sin{{\left({x}\right)}}}{d}{x}=-{\cos{{\left({x}\right)}}}$$$.

So, $$$\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}=\int{{\sin}}^{{{n}-{1}}}{\sin{{\left({x}\right)}}}{d}{x}=-{\cos{{\left({x}\right)}}}{{\sin}}^{{{n}-{1}}}{\left({x}\right)}-\int{\cos{{\left({x}\right)}}}{\left({n}-{1}\right)}{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{\cos{{\left({x}\right)}}}{d}{x}=$$$

$$$=-{\cos{{\left({x}\right)}}}{{\sin}}^{{{n}-{1}}}{\left({x}\right)}+{\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{{\cos}}^{{2}}{\left({x}\right)}{d}{x}$$$.

Since $$${{\cos}}^{{2}}{\left({x}\right)}={1}-{{\sin}}^{{2}}{\left({x}\right)}$$$, it can be stated that$$${\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{{\cos}}^{{2}}{\left({x}\right)}{d}{x}={\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{\left({1}-{{\sin}}^{{2}}{\left({x}\right)}\right)}{d}{x}=$$$

$$$={\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{d}{x}-{\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{{\sin}}^{{2}}{\left({x}\right)}{d}{x}=$$$

$$$={\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{d}{x}-{\left({n}-{1}\right)}\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}$$$.

Therefore,

$$$\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}=-{\cos{{\left({x}\right)}}}{{\sin}}^{{{n}-{1}}}{\left({x}\right)}+{\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{d}{x}-{\left({n}-{1}\right)}\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}$$$.

This is an equation with an unknown variable $$$\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}$$$.

It can be rewritten as $$${n}\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}=-{\cos{{\left({x}\right)}}}{{\sin}}^{{{n}-{1}}}{\left({x}\right)}+{\left({n}-{1}\right)}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{d}{x}$$$.

So, finally, we have that $$$\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}=-\frac{{1}}{{n}}{\cos{{\left({x}\right)}}}{{\sin}}^{{{n}-{1}}}{\left({x}\right)}+\frac{{{n}-{1}}}{{n}}\int{{\sin}}^{{{n}-{2}}}{\left({x}\right)}{d}{x}$$$.

The last question in this section is how to calculate definite integrals with the help of integration by parts. In fact, it is very easy: just combine integration by parts with the Newton-Leibniz formula: $$${\int_{{a}}^{{b}}}{u}{d}{v}={u}{v}{{\mid}_{{a}}^{{b}}}-{\int_{{a}}^{{b}}}{v}{d}{u}$$$.

Example 6. Calculate $$${\int_{{0}}^{{1}}}{{\tan}}^{{-{1}}}{\left({x}\right)}{d}{x}$$$.

Let $$${u}={{\tan}}^{{-{1}}}{\left({x}\right)}$$$ and $$${d}{v}={d}{x}$$$; then, $$${d}{u}={\left({{\tan}}^{{-{1}}}{\left({x}\right)}\right)}'{d}{x}=\frac{{1}}{{{{x}}^{{2}}+{1}}}{d}{x}$$$, and $$${v}=\int{d}{x}={x}$$$.

So, $$${\int_{{0}}^{{1}}}{{\tan}}^{{-{1}}}{\left({x}\right)}{d}{x}={x}{{\tan}}^{{-{1}}}{\left({x}\right)}{{\mid}_{{0}}^{{1}}}-{\int_{{0}}^{{1}}}\frac{{x}}{{{{x}}^{{2}}+{1}}}{d}{x}=$$$

$$$={\left({1}\cdot{{\tan}}^{{-{1}}}{\left({1}\right)}-{0}\cdot{{\tan}}^{{-{1}}}{\left({0}\right)}\right)}-{\int_{{0}}^{{1}}}\frac{{x}}{{{{x}}^{{2}}+{1}}}{d}{x}=\frac{\pi}{{4}}-{\int_{{0}}^{{1}}}\frac{{x}}{{{{x}}^{{2}}+{1}}}{d}{x}$$$.

To calculate $$${\int_{{0}}^{{1}}}\frac{{x}}{{{{x}}^{{2}}+{1}}}{d}{x}$$$, we use the substitution rule: let $$${t}={{x}}^{{2}}+{1}$$$; then,$$${d}{t}={\left({{x}}^{{2}}+{1}\right)}'{d}{x}={2}{x}{d}{x}$$$, or $$${x}{d}{x}=\frac{{1}}{{2}}{d}{t}$$$.

Since $$${x}$$$ is changing from 0 to 1, it can be stated that $$${t}$$$ is changing from $$${2}\cdot{0}={0}$$$ to $$${2}\cdot{1}={2}$$$.

So, $$${\int_{{0}}^{{1}}}\frac{{x}}{{{{x}}^{{2}}+{1}}}{d}{x}={\int_{{1}}^{{2}}}\frac{{1}}{{t}}\frac{{1}}{{2}}{d}{t}=\frac{{1}}{{2}}{{\left[{\ln}{\left|{t}\right|}\right]}_{{1}}^{{2}}}=\frac{{1}}{{2}}{\left({\ln{{\left({2}\right)}}}-{\ln{{\left({1}\right)}}}\right)}=$$$

$$$=\frac{{1}}{{2}}{\left({\ln{{\left({2}\right)}}}-{0}\right)}=\frac{{1}}{{2}}{\ln{{\left({2}\right)}}}$$$.

Finally, we can see that $$${\int_{{0}}^{{1}}}{{\tan}}^{{-{1}}}{\left({x}\right)}=\frac{\pi}{{4}}-{\int_{{0}}^{{1}}}\frac{{x}}{{{{x}}^{{2}}+{1}}}{d}{x}=\frac{\pi}{{4}}-\frac{{1}}{{2}}{\ln{{\left({2}\right)}}}$$$.