Skip to content
ihateDesmos

Integral of x cos x

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

The integral of x cos x is cos x + x sin x + C. Choose u = x and dv = cos x dx.

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

How to integrate x cos x

Method: integration by parts.

  1. 1
    Choose u = x and dv = cos x dx.
  2. 2
    Then du = dx and v = sin x.
  3. 3
    Integration by parts gives x sin x − ∫sin x dx.
  4. 4
    The integral of sin x is −cos x, so this is x sin x + cos x.
  5. 5
    So the result is cos x + x sin x + C.

What it means

x cos x is an odd function, so its integral is even, and from −a to a the integral is 0.

The integral from 0 to π/2

Using the antiderivative: F(π/2) − F(0) = π/2 − 1, which is about 0.570796. A direct numerical integration of x cos x gives 0.570796, 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 cos xSlope of the answer
−πππ
−π/200
000
π/20−0
π−π−π

Common mistakes

  • Getting the sign of cos x wrong in the last step.

Frequently asked questions

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

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