Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

Integration by parts, step by step

The formula for integration by parts, how to choose u and dv, worked examples checked by differentiation, and how to ask Hilberon for a verified derivation.

Guides9 min read
  • Integration,
  • Calculus

Integration by parts turns the integral of a product into another integral, which is often easier. It is the product rule for derivatives, read backwards.

The formula

Let uu and vv be differentiable functions of xx. The product rule says

ddx(uv)=u′v+uv′.\frac{d}{dx}\bigl(uv\bigr) = u'v + uv'.

Integrate both sides. With du=u′ dxdu = u'\,dx and dv=v′ dxdv = v'\,dx, this reads

uv=∫v du+∫u dv,uv = \int v\,du + \int u\,dv,

and moving one integral to the other side gives the formula:

∫u dv=uv−∫v du.\int u\,dv = uv - \int v\,du.

To use it, split the integrand into two factors. One is uu, which you differentiate to get dudu. The other, with dxdx, is dvdv, which you integrate to get vv. The formula then trades the integral you have for ∫v du\int v\,du.

A picture of the formula

For a definite integral, the same identity is a statement about areas.

A rising curve from (u1, v1) to (u2, v2). Below it, down to the u axis, lies the integral of v du; to its left, across to the v axis, the integral of u dv. Together they fill the rectangle u2 v2 less the small rectangle u1 v1.
Figure 1.

As uu and vv both grow along a curve from (u1,v1)(u_1, v_1) to (u2,v2)(u_2, v_2), the region under the curve is ∫u1u2v du\int_{u_1}^{u_2} v\,du and the region to its left is ∫v1v2u dv\int_{v_1}^{v_2} u\,dv. Together they fill the large rectangle less the small one, so ∫v1v2u dv=u2v2−u1v1−∫u1u2v du\int_{v_1}^{v_2} u\,dv = u_2 v_2 - u_1 v_1 - \int_{u_1}^{u_2} v\,du.

Choosing u and dv

The formula is always true, but it helps only when ∫v du\int v\,du is easier than the integral you began with. Two conditions guide the choice:

  • dvdv must be something you can integrate.
  • uu should become simpler when you differentiate it.

A polynomial loses a degree with each derivative, while exe^x, sin⁡x\sin x and cos⁡x\cos x keep their form when you integrate them. So for xexx e^x or xcos⁡xx\cos x, let uu be the polynomial.

A common rule of thumb, LIATE, orders the candidates for uu: logarithms, inverse trigonometric functions, algebraic functions such as polynomials, trigonometric functions, exponentials. Take uu from the class that comes first. It is a guide, not a law: when the new integral looks harder than the old one, swap the roles.

A first example

Take ∫xex dx\int x e^x\,dx. Let u=xu = x and dv=ex dxdv = e^x\,dx. Then du=dxdu = dx and v=exv = e^x, and

∫xex dx=xex−∫ex dx=xex−ex+C=ex(x−1)+C.\int x e^x\,dx = x e^x - \int e^x\,dx = x e^x - e^x + C = e^x(x - 1) + C.

Check the answer by differentiating it:

ddx[ex(x−1)]=ex(x−1)+ex=xex.\frac{d}{dx}\Bigl[e^x(x - 1)\Bigr] = e^x(x - 1) + e^x = x e^x.

One constant is enough

We wrote v=exv = e^x without a constant of integration. A constant kk added to vv would change nothing but the constant of the answer, since u(v+k)−∫(v+k) du=uv−∫v du+ku−∫k duu(v + k) - \int (v + k)\,du = uv - \int v\,du + ku - \int k\,du and ∫k du=ku+c\int k\,du = ku + c. So one + C+\,C at the end is enough.

A second example

Take ∫xcos⁡x dx\int x\cos x\,dx. Let u=xu = x and dv=cos⁡x dxdv = \cos x\,dx. Then du=dxdu = dx and v=sin⁡xv = \sin x:

∫xcos⁡x dx=xsin⁡x−∫sin⁡x dx=xsin⁡x+cos⁡x+C.\int x\cos x\,dx = x\sin x - \int \sin x\,dx = x\sin x + \cos x + C.

Check:

ddx[xsin⁡x+cos⁡x]=sin⁡x+xcos⁡x−sin⁡x=xcos⁡x.\frac{d}{dx}\bigl[x\sin x + \cos x\bigr] = \sin x + x\cos x - \sin x = x\cos x.

The other choice

With the roles swapped, u=cos⁡xu = \cos x and dv=x dxdv = x\,dx, we get du=−sin⁡x dxdu = -\sin x\,dx and v=x2/2v = x^2/2:

∫xcos⁡x dx=x22cos⁡x+∫x22sin⁡x dx.\int x\cos x\,dx = \frac{x^2}{2}\cos x + \int \frac{x^2}{2}\sin x\,dx.

The equation is true, but the new integral has x2x^2 where the old one had xx. It is harder, not easier, and that is the sign to swap the roles back.

A factor you cannot see

The integrand ln⁡x\ln x is a product too: ln⁡x\ln x times 11. For x>0x > 0, take u=ln⁡xu = \ln x and dv=dxdv = dx. Then du=dx/xdu = dx/x and v=xv = x:

∫ln⁡x dx=xln⁡x−∫x⋅1x dx=xln⁡x−x+C.\int \ln x\,dx = x\ln x - \int x\cdot\frac{1}{x}\,dx = x\ln x - x + C.

The derivative of xln⁡x−xx\ln x - x is ln⁡x+1−1=ln⁡x\ln x + 1 - 1 = \ln x, as it should be.

When the integral comes back

Let I=∫exsin⁡x dxI = \int e^x\sin x\,dx. With u=sin⁡xu = \sin x and dv=ex dxdv = e^x\,dx:

I=exsin⁡x−∫excos⁡x dx.I = e^x\sin x - \int e^x\cos x\,dx.

Integrate by parts again, with u=cos⁡xu = \cos x and dv=ex dxdv = e^x\,dx, so that du=−sin⁡x dxdu = -\sin x\,dx:

∫excos⁡x dx=excos⁡x+∫exsin⁡x dx=excos⁡x+I.\int e^x\cos x\,dx = e^x\cos x + \int e^x\sin x\,dx = e^x\cos x + I.

The integral you started with has come back. Substitute: I=exsin⁡x−excos⁡x−II = e^x\sin x - e^x\cos x - I, so 2I=ex(sin⁡x−cos⁡x)2I = e^x(\sin x - \cos x) and

∫exsin⁡x dx=ex(sin⁡x−cos⁡x)2+C.\int e^x\sin x\,dx = \frac{e^x(\sin x - \cos x)}{2} + C.

Check: the derivative of ex(sin⁡x−cos⁡x)e^x(\sin x - \cos x) is ex(sin⁡x−cos⁡x)+ex(cos⁡x+sin⁡x)=2exsin⁡xe^x(\sin x - \cos x) + e^x(\cos x + \sin x) = 2e^x\sin x, and half of that is the integrand.

With limits

For a definite integral, the formula keeps its bounds:

∫abu dv=[uv]ab−∫abv du.\int_a^b u\,dv = \Bigl[uv\Bigr]_a^b - \int_a^b v\,du.

The bracket is u2v2−u1v1u_2 v_2 - u_1 v_1 in the picture above, with (u1,v1)(u_1, v_1) the values at aa and (u2,v2)(u_2, v_2) the values at bb. With the first example:

∫01xex dx=[xex]01−∫01ex dx=e−(e−1)=1.\int_0^1 x e^x\,dx = \Bigl[x e^x\Bigr]_0^1 - \int_0^1 e^x\,dx = e - (e - 1) = 1.

Asking Hilberon

In the solver, the second example is written as a query: the integrand, then the variable.

integrate(x*cos(x), x)
Open in the solver
∫xcos⁡(x) dx\int x \cos(x) \, dx
The Hilberon solver with the integral of x cos x written in the editor, and its syntax, integrate(x*cos(x), x), shown under it
Figure 2.

The Open in the solver button writes the query into the editor. Nothing runs until you evaluate it.

The answer comes with the methods that produced it and, when the engine certified it, how it was checked. The Steps button under the answer shows the derivation: numbered lines, each with a caption that names the method and its key choices, such as Integration by parts · u=xu = x, dv=ex dxdv = e^x\,dx.

For ∫xex dx\int x e^x\,dx the first step says: “Integrate by parts with u=xu = x and dv=ex dxdv = e^x\,dx. Then du=1 dxdu = 1\,dx and v=exv = e^x, so ∫u dv=uv−∫v du\int u\,dv = uv - \int v\,du.” The Why? button beside the caption holds that sentence, the reason for the method (“The integrand is a product, and integrating by parts trades it for an integral of v duv\,du”), the rule's formula and the piece of the problem the step worked on.

A derivation is shown only when it passes a check. For an integral, the check is the one we did by hand above: the derivative of the result must equal the integrand. The derivation ends with that sentence, “Checked: the derivative of the result equals the integrand.” When no derivation passes, the answer is shown as computed by the engine, with no textbook derivation. Hilberon does not show a wrong step.

Signed in, you can also ask for other methods of the same problem. Each comes back as a verified derivation of its own, when another method applies.

The definite integral and the integral that comes back are queries too:

integrate(x*exp(x), x = 0..1)
Open in the solver
∫01xex dx\int_{0}^{1} x e^{x} \, dx
integrate(exp(x)*sin(x), x)
Open in the solver
∫exsin⁡(x) dx\int e^{x} \sin(x) \, dx

The examples page has more integrals to try, by topic.