Skip to content
ihateDesmos

Integral of x sin x

Updated 6 November 2026 · Checked numerically by the ihateDesmos engine
The integral of x sin x
∫
xsin(x)
dx =
sin(x)−xcos(x)+C

The integral of x sin x is sin x − x cos x + C. Choose u = x, because differentiating it removes the x.

−6−4−2246−550
Open in calculator
y=xsin(x)
in blue and its integral
y=sin(x)−xcos(x)
(with C = 0) in red.

How to integrate x sin x

Method: integration by parts.

  1. 1
    Choose u = x and dv = sin x dx.
  2. 2
    Then du = dx and v = −cos x.
  3. 3
    Integration by parts gives −x cos x − ∫(−cos x) dx.
  4. 4
    That is −x cos x + ∫cos x dx = −x cos x + sin x.
  5. 5
    So the result is sin x − x cos x + C.

What it means

x sin x oscillates with growing size. Its integral does too, and the x cos x term grows with x.

The integral from 0 to π

Using the antiderivative: F(π) − F(0) = π, which is about π. A direct numerical integration of x sin x gives π, which agrees.

−8−6−4−22468−10−8−6−4−2246810

Check by differentiating

The derivative of the answer should give back the original function. The last column measures that slope directly from the answer, and it matches.

Checking the integral
xx sin xSlope of the answer
−π0−0
−π/2π/2π/2
000
π/2π/2π/2
π0−0

Common mistakes

  • Choosing u = sin x and dv = x dx, which leaves a harder integral.
  • A sign error with −cos x. Writing each step out helps.

Frequently asked questions

What is the integral of x sin x?
The integral of x sin x is sin x − x cos x + C.
What is the integral of x sin x from 0 to π?
π, which is about π.

Keep going

Integrate any function

Type your own function into the integral calculator for the steps, the answer and a graph.

Open the integral calculator