Integral of x cos x: Formula, Steps and Examples
The integral of x cos x is x sin x + cos x + C. See the integration by parts steps, a check, a graph, definite integrals and examples like x² cos x.
Products and integration by parts Updated 3 min read
At a glance
- Antiderivative
- x\sin x + \cos x + C
- Method
- Integration by parts with u = x, dv = \cos x\,dx
- From 0 to π/2
- \frac{\pi}{2} - 1 \approx 0.571
- From 0 to π
- -2
- With cos(kx)
- \int x\cos kx\,dx = \frac{x}{k}\sin kx + \frac{1}{k^2}\cos kx + C
On this page
The integral of x\cos x is x\sin x + \cos x + C. Like x\sin x, it is a power of x times a trig function, so integration by parts with u = x does it in one step.
Graph of x cos x and its antiderivative
How to integrate x cos x step by step
Use integration by parts, \int u\,dv = uv - \int v\,du.
- Choose the parts. u = x and dv = \cos x\,dx.
- Find du and v. du = dx and v = \sin x, from the integral of cos x.
- Apply the formula. \int x\cos x\,dx = x\sin x - \int\sin x\,dx
- Finish. \int\sin x\,dx = -\cos x, and subtracting it gives +\cos x: \int x\cos x\,dx = x\sin x + \cos x + C
u = x is the right choice because its derivative is 1, which wipes out the x. Choosing u = \cos x would raise the power to x^2.
Check by differentiating
The \sin x from the product rule cancels the -\sin x from \cos x.
Definite integrals
Let F(x) = x\sin x + \cos x.
| Integral | Work | Value |
|---|---|---|
| \int_0^{\pi/2} x\cos x\,dx | \left(\frac{\pi}{2} + 0\right) - (0 + 1) | \frac{\pi}{2} - 1 |
| \int_0^{\pi} x\cos x\,dx | (0 - 1) - (0 + 1) | -2 |
| \int_{\pi/2}^{3\pi/2} x\cos x\,dx | \left(-\frac{3\pi}{2}\right) - \frac{\pi}{2} | -2\pi |
| \int_{-a}^{a} x\cos x\,dx | odd integrand | 0 |
The last row uses symmetry: x\cos x is odd (an odd function times an even one), so the areas on the two sides cancel.
Worked examples
Example 1: a scaled angle. \int x\cos 3x\,dx. With u = x and v = \frac{1}{3}\sin 3x:
Example 2: x squared. \int x^2\cos x\,dx. First pass with u = x^2, v = \sin x:
The integral of x sin x is \sin x - x\cos x, so
Example 3: a linear factor. \int(2x - 1)\cos x\,dx. With u = 2x - 1, du = 2\,dx:
Example 4: a Fourier coefficient. In Fourier series you meet integrals like \int_{-\pi}^{\pi}x\cos(nx)\,dx. The integrand is odd, so the answer is 0 for every whole number n, with no parts needed.
Example 5: a hidden product. \int x\cos^2 x\,dx. Write \cos^2 x = \frac{1 + \cos 2x}{2} (see the integral of cos²x), then
Common mistakes
- Writing x\sin x - \cos x. The leftover is -\int\sin x\,dx = -(-\cos x) = +\cos x.
- Mixing it up with x\sin x. Here v = \sin x with no sign change; for x\sin x, v = -\cos x.
- Integrating factor by factor. \frac{x^2}{2}\sin x is not the answer; differentiate it to see why.
- Dropping the \frac{1}{k^2} on the second term when the angle is kx.
For more practice, try the integration by parts practice problems.
Practice it now
Integration by parts
Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.
Practice this lesson