# 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.

[Guides](https://hilberon.com/blog/guides) November 7, 2026 9 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 $u$ and $v$ be differentiable functions of $x$. The product rule says

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

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

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

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

$$
\int u\,dv = uv - \int v\,du.
$$

To use it, split the integrand into two factors. One is $u$, which you differentiate to get $du$. The other, with $dx$, is $dv$, which you integrate to get $v$. The formula then trades the integral you have for $\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.](https://hilberon.com/api/media/7e67fdd20e54bbb9f7ae76054e1df79b.png)

*Figure 1.*

*As $u$ and $v$ both grow along a curve from $(u_1, v_1)$ to $(u_2, v_2)$, the region under the curve is $\int_{u_1}^{u_2} v\,du$ and the region to its left is $\int_{v_1}^{v_2} u\,dv$. Together they fill the large rectangle less the small one, so $\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 $\int v\,du$ is easier than the integral you began with. Two conditions guide the choice:

- $dv$ must be something you can integrate.
- $u$ should become simpler when you differentiate it.

A polynomial loses a degree with each derivative, while $e^x$, $\sin x$ and $\cos x$ keep their form when you integrate them. So for $x e^x$ or $x\cos x$, let $u$ be the polynomial.

A common rule of thumb, LIATE, orders the candidates for $u$: logarithms, inverse trigonometric functions, algebraic functions such as polynomials, trigonometric functions, exponentials. Take $u$ 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 $\int x e^x\,dx$. Let $u = x$ and $dv = e^x\,dx$. Then $du = dx$ and $v = e^x$, and

$$
\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:

$$
\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 = e^x$ without a constant of integration. A constant $k$ added to $v$ would change nothing but the constant of the answer, since $u(v + k) - \int (v + k)\,du = uv - \int v\,du + ku - \int k\,du$ and $\int k\,du = ku + c$. So one $+\,C$ at the end is enough.

## A second example

Take $\int x\cos x\,dx$. Let $u = x$ and $dv = \cos x\,dx$. Then $du = dx$ and $v = \sin x$:

$$
\int x\cos x\,dx = x\sin x - \int \sin x\,dx = x\sin x + \cos x + C.
$$

Check:

$$
\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 x$ and $dv = x\,dx$, we get $du = -\sin x\,dx$ and $v = x^2/2$:

$$
\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 $x^2$ where the old one had $x$. It is harder, not easier, and that is the sign to swap the roles back.

## A factor you cannot see

The integrand $\ln x$ is a product too: $\ln x$ times $1$. For $x > 0$, take $u = \ln x$ and $dv = dx$. Then $du = dx/x$ and $v = x$:

$$
\int \ln x\,dx = x\ln x - \int x\cdot\frac{1}{x}\,dx = x\ln x - x + C.
$$

The derivative of $x\ln x - x$ is $\ln x + 1 - 1 = \ln x$, as it should be.

## When the integral comes back

Let $I = \int e^x\sin x\,dx$. With $u = \sin x$ and $dv = e^x\,dx$:

$$
I = e^x\sin x - \int e^x\cos x\,dx.
$$

Integrate by parts again, with $u = \cos x$ and $dv = e^x\,dx$, so that $du = -\sin x\,dx$:

$$
\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 = e^x\sin x - e^x\cos x - I$, so $2I = e^x(\sin x - \cos x)$ and

$$
\int e^x\sin x\,dx = \frac{e^x(\sin x - \cos x)}{2} + C.
$$

Check: the derivative of $e^x(\sin x - \cos x)$ is $e^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:

$$
\int_a^b u\,dv = \Bigl[uv\Bigr]_a^b - \int_a^b v\,du.
$$

The bracket is $u_2 v_2 - u_1 v_1$ in the picture above, with $(u_1, v_1)$ the values at $a$ and $(u_2, v_2)$ the values at $b$. With the first example:

$$
\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](https://hilberon.com/?q=integrate%28x*cos%28x%29%2C%20x%29)

$$
\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](https://hilberon.com/api/media/c54ee929c32781820125aac767c60c24.png)

*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 = x$, $dv = e^x\,dx$.

For $\int x e^x\,dx$ the first step says: “Integrate by parts with $u = x$ and $dv = e^x\,dx$. Then $du = 1\,dx$ and $v = e^x$, so $\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\,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](https://hilberon.com/?q=integrate%28x*exp%28x%29%2C%20x%20%3D%200..1%29)

$$
\int_{0}^{1} x e^{x} \, dx
$$

`integrate(exp(x)*sin(x), x)`

[Open in the solver](https://hilberon.com/?q=integrate%28exp%28x%29*sin%28x%29%2C%20x%29)

$$
\int e^{x} \sin(x) \, dx
$$

The [examples](https://hilberon.com/examples) page has more integrals to try, by topic.

[All guides](https://hilberon.com/blog/guides)

---
Source: https://hilberon.com/blog/guides/integration-by-parts
