# Integral of x sin x: Formula, Steps and Examples

> The integral of x sin x is sin x − x cos x + C. See the integration by parts steps, a check by differentiating, a graph and examples like x² sin x.

Source: https://practicecalculus.com/integrals/x-sin-x
Updated: 2026-11-06

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

## At a glance

- **Antiderivative:** $\sin x - x\cos x + C$
- **Method:** Integration by parts with $u = x$, $dv = \sin x\,dx$
- **From 0 to π:** $\pi$
- **From 0 to π/2:** $1$
- **With sin(kx):** $\int x\sin kx\,dx = -\frac{x}{k}\cos kx + \frac{1}{k^2}\sin kx + C$

## Key takeaways

- The integral of $x\sin x$ is $\sin x - x\cos x + C$.
- Use integration by parts with $u = x$ and $dv = \sin x\,dx$, so $v = -\cos x$.
- Watch the signs: $v = -\cos x$, and subtracting $\int -\cos x\,dx$ gives $+\sin x$.
- The humps of $x\sin x$ have areas $\pi$, $3\pi$, $5\pi$ and so on, alternating in sign.

The **integral of $x\sin x$ is $\sin x - x\cos x + C$**. It is a power of $x$ times a trig function, which is a classic integration by parts problem.

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

## Graph of x sin x

```graph
title: 'y = x sin x with the area from 0 to π shaded'
caption: 'The shaded hump has area exactly $\pi$. The next hump, from $\pi$ to $2\pi$, lies below the axis with signed area $-3\pi$, and each later hump grows by $2\pi$.'
x: [-1, 7]
y: [-5.5, 3]
functions:
  - expr: x*sin(x)
    label: y = x sin x
shade:
  expr: x*sin(x)
  from: 0
  to: 3.14159
points:
  - [3.14159, 0, '(π, 0)']
  - [6.28319, 0, '(2π, 0)']
```

## How to integrate x sin x step by step

The [integration by parts](/rules/integration-by-parts-rule) formula is $\int u\,dv = uv - \int v\,du$.

1. **Choose the parts.** $u = x$ and $dv = \sin x\,dx$. Algebraic comes before trig in LIATE.
2. **Find $du$ and $v$.** $du = dx$ and $v = -\cos x$, from the [integral of sin x](/integrals/sin-x).
3. **Apply the formula.**
$$\int x\sin x\,dx = x(-\cos x) - \int(-\cos x)\,dx = -x\cos x + \int\cos x\,dx$$
4. **Finish.** $\int\cos x\,dx = \sin x$, so
$$\int x\sin x\,dx = -x\cos x + \sin x + C$$

If you choose $u = \sin x$ and $dv = x\,dx$ instead, the leftover integral is $\int\frac{x^2}{2}\cos x\,dx$, with a higher power. That is the signal to switch.

## Check by differentiating

$$\frac{d}{dx}\left(\sin x - x\cos x\right) = \cos x - \left(\cos x - x\sin x\right) = x\sin x$$

The $\cos x$ terms cancel, and the [product rule](/rules/product-rule) on $x\cos x$ supplies the $x\sin x$.

## Definite integrals

Let $F(x) = \sin x - x\cos x$.

| Integral | Work | Value |
| --- | --- | --- |
| $\int_0^{\pi/2} x\sin x\,dx$ | $F\!\left(\frac{\pi}{2}\right) - F(0) = 1 - 0$ | $1$ |
| $\int_0^{\pi} x\sin x\,dx$ | $F(\pi) - F(0) = \pi - 0$ | $\pi$ |
| $\int_\pi^{2\pi} x\sin x\,dx$ | $F(2\pi) - F(\pi) = -2\pi - \pi$ | $-3\pi$ |
| $\int_0^{2\pi} x\sin x\,dx$ | $F(2\pi) - F(0)$ | $-2\pi$ |

In general the hump from $k\pi$ to $(k+1)\pi$ has area $(2k+1)\pi$, with sign $(-1)^k$. The total area (not signed) from $0$ to $2\pi$ is $\pi + 3\pi = 4\pi$.

## Worked examples

**Example 1: a scaled angle.** $\int x\sin 2x\,dx$. With $u = x$, $dv = \sin 2x\,dx$, $v = -\frac{1}{2}\cos 2x$:

$$-\frac{x}{2}\cos 2x + \frac{1}{2}\int\cos 2x\,dx = -\frac{x}{2}\cos 2x + \frac{1}{4}\sin 2x + C$$

**Example 2: x squared, with the tabular method.** For $\int x^2\sin x\,dx$, differentiate $x^2$ down to $0$ and integrate $\sin x$ alongside, with alternating signs:

| Sign | Differentiate | Integrate |
| --- | --- | --- |
| $+$ | $x^2$ | $\sin x$ |
| $-$ | $2x$ | $-\cos x$ |
| $+$ | $2$ | $-\sin x$ |
| | $0$ | $\cos x$ |

Multiply along the diagonals:

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

**Example 3: a volume.** Rotating the first hump of $y = \sin x$ (from $0$ to $\pi$) about the $y$-axis, the shell method gives

$$V = 2\pi\int_0^\pi x\sin x\,dx = 2\pi\cdot\pi = 2\pi^2$$

See the [volumes of revolution guide](/blog/volumes-of-revolution) for the setup.

**Example 4: a shifted angle.** $\int x\sin(x + 1)\,dx = \sin(x+1) - x\cos(x+1) + C$, since the inside has slope $1$.

## Common mistakes

1. **Getting $v$ wrong.** $\int\sin x\,dx = -\cos x$, not $\cos x$. Most errors on this problem are sign errors.
2. **Losing the double negative.** $-\int(-\cos x)\,dx = +\int\cos x\,dx$.
3. **Choosing $u = \sin x$.** The leftover integral then has $x^2$ in it.
4. **Forgetting $\frac{1}{k}$ and $\frac{1}{k^2}$** with $\sin kx$. Differentiate your answer to check.

Compare with the [integral of x cos x](/integrals/x-cos-x), which has the same steps with different signs. More practice is in the [integration by parts guide](/blog/integration-by-parts).

## Frequently asked questions

### What is the integral of x sin x?

It is $\sin x - x\cos x + C$.

### What is the integral of x sin x from 0 to π?

It is $\pi$. The antiderivative is $\sin\pi - \pi\cos\pi = \pi$ at the top and $0$ at the bottom.

### What is the integral of x² sin x?

It is $-x^2\cos x + 2x\sin x + 2\cos x + C$. Use parts twice, or the tabular method.

### What is the integral of x sin(2x)?

It is $-\frac{x}{2}\cos 2x + \frac{1}{4}\sin 2x + C$. Use parts with $u = x$ and $v = -\frac{1}{2}\cos 2x$.
