Integration by Parts

It is easy to compute the integral exdx\int{{e}}^{{x}}{d}{x}, but how to handle integrals like xexdx\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: udv=uvvdu\int{u}{d}{v}={u}{v}-\int{v}{d}{u}.

Proof

Using the product rule, we have that (f(x)g(x))=f(x)g(x)+f(x)g(x){\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: (f(x)g(x))dx=(f(x)g(x)+f(x)g(x))dx\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(x)g(x)=f(x)g(x)dx+f(x)g(x)dx{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 f(x)g(x)dx=f(x)g(x)f(x)g(x)dx\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(x){u}={f{{\left({x}\right)}}} and v=g(x){v}={g{{\left({x}\right)}}}, we have that du=f(x)dx{d}{u}={f{'}}{\left({x}\right)}{d}{x} and dv=g(x)dx{d}{v}={g{'}}{\left({x}\right)}{d}{x}, and the above formula can be rewritten using the substitution rule as udv=uvvdu\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 xexdx\int{x}{{e}}^{{x}}{d}{x}.

Let u=x{u}={x} and dv=exdx{d}{v}={{e}}^{{x}}{d}{x}. Then, du=(x)dx=dx{d}{u}={\left({x}\right)}'{d}{x}={d}{x}, and v=exdx=ex{v}=\int{{e}}^{{x}}{d}{x}={{e}}^{{x}}.

So, xexdx=(x)u(exdx)dv=(x)u(ex)v(ex)v(dx)du=xexex+C\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{u} and v{v}, because a wrong choice will only complicate the integral.

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

So, xexdx=(ex)u(xdx)dv=(ex)u(12x2)v(12x2)v(exdx)du\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 12x2exdx\int\frac{{1}}{{2}}{{x}}^{{2}}{{e}}^{{x}}{d}{x} is more difficult to evaluate than the integral we started with.

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

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

So, x2cos(x)dx=x2sin(x)2xsin(x)dx=x2sin(x)2xsin(x)dx\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 xsin(x)dx\int{x}{\sin{{\left({x}\right)}}}{d}{x}:

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

So, (x)u(sin(x)dx)dv=(x)u(cos(x))v(cos(x))v(dx)du=xcos(x)+cos(x)dx=\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}=

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

Finally, x2cos(x)dx=x2sin(x)2xsin(x)dx=x2sin(x)2(xcos(x)+sin(x)+C)=\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)}=

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

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

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

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

Therefore, (ln(x))u(dx)dv=(ln(x))u(x)v(x)v(1xdx)du=\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}}}=

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

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

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

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

Therefore, exsin(x)dx=excos(x)cos(x)exdx=excos(x)+excos(x)dx\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=ex{u}={{e}}^{{x}} and dv=cos(x)dx{d}{v}={\cos{{\left({x}\right)}}}{d}{x}; then, du=(ex)dx=exdx{d}{u}={\left({{e}}^{{x}}\right)}'{d}{x}={{e}}^{{x}}{d}{x}, and v=cos(x)dx=sin(x){v}=\int{\cos{{\left({x}\right)}}}{d}{x}={\sin{{\left({x}\right)}}}.

So, excos(x)dx=exsin(x)exsin(x)dx\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 exsin(x)dx\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}, which is where we had started.

However, since exsin(x)dx=excos(x)+excos(x)dx\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

exsin(x)dx=excos(x)+(exsin(x)exsin(x)dx)\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 exsin(x)dx\int{{e}}^{{x}}{\sin{{\left({x}\right)}}}{d}{x}.

This equation can be rewritten as 2exsin(x)dx=ex(sin(x)cos(x)){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: exsin(x)dx=12ex(sin(x)cos(x))+C\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.sinn(x)dx=1ncos(x)sinn1(x)+n1nsinn2(x)dx\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 n2{n}\ge{2} is an integer.

Let u=sinn1(x){u}={{\sin}}^{{{n}-{1}}}{\left({x}\right)} and dv=sin(x)dx{d}{v}={\sin{{\left({x}\right)}}}{d}{x}; then,du=(sinn1)dx=(n1)sinn2(x)(sin(x))dx=(n1)sinn2(x)cos(x)dx{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=sin(x)dx=cos(x){v}=\int{\sin{{\left({x}\right)}}}{d}{x}=-{\cos{{\left({x}\right)}}}.

So, sinn(x)dx=sinn1sin(x)dx=cos(x)sinn1(x)cos(x)(n1)sinn2(x)cos(x)dx=\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(x)sinn1(x)+(n1)sinn2(x)cos2(x)dx=-{\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 cos2(x)=1sin2(x){{\cos}}^{{2}}{\left({x}\right)}={1}-{{\sin}}^{{2}}{\left({x}\right)}, it can be stated that(n1)sinn2(x)cos2(x)dx=(n1)sinn2(x)(1sin2(x))dx={\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}=

=(n1)sinn2(x)dx(n1)sinn2sin2(x)dx=={\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}=

=(n1)sinn2(x)dx(n1)sinn(x)dx={\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,

sinn(x)dx=cos(x)sinn1(x)+(n1)sinn2(x)dx(n1)sinn(x)dx\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 sinn(x)dx\int{{\sin}}^{{n}}{\left({x}\right)}{d}{x}.

It can be rewritten as nsinn(x)dx=cos(x)sinn1(x)+(n1)sinn2(x)dx{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 sinn(x)dx=1ncos(x)sinn1(x)+n1nsinn2(x)dx\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: abudv=uvababvdu{\int_{{a}}^{{b}}}{u}{d}{v}={u}{v}{{\mid}_{{a}}^{{b}}}-{\int_{{a}}^{{b}}}{v}{d}{u}.

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

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

So, 01tan1(x)dx=xtan1(x)0101xx2+1dx={\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}=

=(1tan1(1)0tan1(0))01xx2+1dx=π401xx2+1dx={\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 01xx2+1dx{\int_{{0}}^{{1}}}\frac{{x}}{{{{x}}^{{2}}+{1}}}{d}{x}, we use the substitution rule: let t=x2+1{t}={{x}}^{{2}}+{1}; then,dt=(x2+1)dx=2xdx{d}{t}={\left({{x}}^{{2}}+{1}\right)}'{d}{x}={2}{x}{d}{x}, or xdx=12dt{x}{d}{x}=\frac{{1}}{{2}}{d}{t}.

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

So, 01xx2+1dx=121t12dt=12[lnt]12=12(ln(2)ln(1))={\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)}=

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

Finally, we can see that 01tan1(x)=π401xx2+1dx=π412ln(2){\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)}}}.